]>
crepu.dev Git - config.git/blob - djavu-asus/elpy/rpc-venv/lib/python3.11/site-packages/setuptools/command/py36compat.py
3 from distutils
.util
import convert_path
4 from distutils
.command
import sdist
7 class sdist_add_defaults
:
9 Mix-in providing forward-compatibility for functionality as found in
10 distutils on Python 3.7.
12 Do not edit the code in this class except to update functionality
13 as implemented in distutils. Instead, override in the subclass.
16 def add_defaults(self
):
17 """Add all the default files to self.filelist:
18 - README or README.txt
21 - all pure Python modules mentioned in setup script
22 - all files pointed by package_data (build_py)
23 - all files defined in data_files.
24 - all files defined as scripts.
25 - all C sources listed as part of extensions or C libraries
26 in the setup script (doesn't catch C headers!)
27 Warns if (README or README.txt) or setup.py are missing; everything
30 self
._add
_defaults
_standards
()
31 self
._add
_defaults
_optional
()
32 self
._add
_defaults
_python
()
33 self
._add
_defaults
_data
_files
()
34 self
._add
_defaults
_ext
()
35 self
._add
_defaults
_c
_libs
()
36 self
._add
_defaults
_scripts
()
39 def _cs_path_exists(fspath
):
41 Case-sensitive path existence check
43 >>> sdist_add_defaults._cs_path_exists(__file__)
45 >>> sdist_add_defaults._cs_path_exists(__file__.upper())
48 if not os
.path
.exists(fspath
):
50 # make absolute so we always have a directory
51 abspath
= os
.path
.abspath(fspath
)
52 directory
, filename
= os
.path
.split(abspath
)
53 return filename
in os
.listdir(directory
)
55 def _add_defaults_standards(self
):
56 standards
= [self
.READMES
, self
.distribution
.script_name
]
58 if isinstance(fn
, tuple):
62 if self
._cs
_path
_exists
(fn
):
64 self
.filelist
.append(fn
)
68 self
.warn("standard file not found: should have one of " +
71 if self
._cs
_path
_exists
(fn
):
72 self
.filelist
.append(fn
)
74 self
.warn("standard file '%s' not found" % fn
)
76 def _add_defaults_optional(self
):
77 optional
= ['test/test*.py', 'setup.cfg']
78 for pattern
in optional
:
79 files
= filter(os
.path
.isfile
, glob(pattern
))
80 self
.filelist
.extend(files
)
82 def _add_defaults_python(self
):
83 # build_py is used to get:
85 # - files defined in package_data
86 build_py
= self
.get_finalized_command('build_py')
88 # getting python files
89 if self
.distribution
.has_pure_modules():
90 self
.filelist
.extend(build_py
.get_source_files())
92 # getting package_data files
93 # (computed in build_py.data_files by build_py.finalize_options)
94 for pkg
, src_dir
, build_dir
, filenames
in build_py
.data_files
:
95 for filename
in filenames
:
96 self
.filelist
.append(os
.path
.join(src_dir
, filename
))
98 def _add_defaults_data_files(self
):
99 # getting distribution.data_files
100 if self
.distribution
.has_data_files():
101 for item
in self
.distribution
.data_files
:
102 if isinstance(item
, str):
104 item
= convert_path(item
)
105 if os
.path
.isfile(item
):
106 self
.filelist
.append(item
)
108 # a (dirname, filenames) tuple
109 dirname
, filenames
= item
112 if os
.path
.isfile(f
):
113 self
.filelist
.append(f
)
115 def _add_defaults_ext(self
):
116 if self
.distribution
.has_ext_modules():
117 build_ext
= self
.get_finalized_command('build_ext')
118 self
.filelist
.extend(build_ext
.get_source_files())
120 def _add_defaults_c_libs(self
):
121 if self
.distribution
.has_c_libraries():
122 build_clib
= self
.get_finalized_command('build_clib')
123 self
.filelist
.extend(build_clib
.get_source_files())
125 def _add_defaults_scripts(self
):
126 if self
.distribution
.has_scripts():
127 build_scripts
= self
.get_finalized_command('build_scripts')
128 self
.filelist
.extend(build_scripts
.get_source_files())
131 if hasattr(sdist
.sdist
, '_add_defaults_standards'):
132 # disable the functionality already available upstream
133 class sdist_add_defaults
: # noqa