Mercurial > repos > guerler > springsuite
comparison planemo/lib/python3.7/site-packages/setuptools/command/py36compat.py @ 1:56ad4e20f292 draft
"planemo upload commit 6eee67778febed82ddd413c3ca40b3183a3898f1"
author | guerler |
---|---|
date | Fri, 31 Jul 2020 00:32:28 -0400 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
0:d30785e31577 | 1:56ad4e20f292 |
---|---|
1 import os | |
2 from glob import glob | |
3 from distutils.util import convert_path | |
4 from distutils.command import sdist | |
5 | |
6 from setuptools.extern.six.moves import filter | |
7 | |
8 | |
9 class sdist_add_defaults: | |
10 """ | |
11 Mix-in providing forward-compatibility for functionality as found in | |
12 distutils on Python 3.7. | |
13 | |
14 Do not edit the code in this class except to update functionality | |
15 as implemented in distutils. Instead, override in the subclass. | |
16 """ | |
17 | |
18 def add_defaults(self): | |
19 """Add all the default files to self.filelist: | |
20 - README or README.txt | |
21 - setup.py | |
22 - test/test*.py | |
23 - all pure Python modules mentioned in setup script | |
24 - all files pointed by package_data (build_py) | |
25 - all files defined in data_files. | |
26 - all files defined as scripts. | |
27 - all C sources listed as part of extensions or C libraries | |
28 in the setup script (doesn't catch C headers!) | |
29 Warns if (README or README.txt) or setup.py are missing; everything | |
30 else is optional. | |
31 """ | |
32 self._add_defaults_standards() | |
33 self._add_defaults_optional() | |
34 self._add_defaults_python() | |
35 self._add_defaults_data_files() | |
36 self._add_defaults_ext() | |
37 self._add_defaults_c_libs() | |
38 self._add_defaults_scripts() | |
39 | |
40 @staticmethod | |
41 def _cs_path_exists(fspath): | |
42 """ | |
43 Case-sensitive path existence check | |
44 | |
45 >>> sdist_add_defaults._cs_path_exists(__file__) | |
46 True | |
47 >>> sdist_add_defaults._cs_path_exists(__file__.upper()) | |
48 False | |
49 """ | |
50 if not os.path.exists(fspath): | |
51 return False | |
52 # make absolute so we always have a directory | |
53 abspath = os.path.abspath(fspath) | |
54 directory, filename = os.path.split(abspath) | |
55 return filename in os.listdir(directory) | |
56 | |
57 def _add_defaults_standards(self): | |
58 standards = [self.READMES, self.distribution.script_name] | |
59 for fn in standards: | |
60 if isinstance(fn, tuple): | |
61 alts = fn | |
62 got_it = False | |
63 for fn in alts: | |
64 if self._cs_path_exists(fn): | |
65 got_it = True | |
66 self.filelist.append(fn) | |
67 break | |
68 | |
69 if not got_it: | |
70 self.warn("standard file not found: should have one of " + | |
71 ', '.join(alts)) | |
72 else: | |
73 if self._cs_path_exists(fn): | |
74 self.filelist.append(fn) | |
75 else: | |
76 self.warn("standard file '%s' not found" % fn) | |
77 | |
78 def _add_defaults_optional(self): | |
79 optional = ['test/test*.py', 'setup.cfg'] | |
80 for pattern in optional: | |
81 files = filter(os.path.isfile, glob(pattern)) | |
82 self.filelist.extend(files) | |
83 | |
84 def _add_defaults_python(self): | |
85 # build_py is used to get: | |
86 # - python modules | |
87 # - files defined in package_data | |
88 build_py = self.get_finalized_command('build_py') | |
89 | |
90 # getting python files | |
91 if self.distribution.has_pure_modules(): | |
92 self.filelist.extend(build_py.get_source_files()) | |
93 | |
94 # getting package_data files | |
95 # (computed in build_py.data_files by build_py.finalize_options) | |
96 for pkg, src_dir, build_dir, filenames in build_py.data_files: | |
97 for filename in filenames: | |
98 self.filelist.append(os.path.join(src_dir, filename)) | |
99 | |
100 def _add_defaults_data_files(self): | |
101 # getting distribution.data_files | |
102 if self.distribution.has_data_files(): | |
103 for item in self.distribution.data_files: | |
104 if isinstance(item, str): | |
105 # plain file | |
106 item = convert_path(item) | |
107 if os.path.isfile(item): | |
108 self.filelist.append(item) | |
109 else: | |
110 # a (dirname, filenames) tuple | |
111 dirname, filenames = item | |
112 for f in filenames: | |
113 f = convert_path(f) | |
114 if os.path.isfile(f): | |
115 self.filelist.append(f) | |
116 | |
117 def _add_defaults_ext(self): | |
118 if self.distribution.has_ext_modules(): | |
119 build_ext = self.get_finalized_command('build_ext') | |
120 self.filelist.extend(build_ext.get_source_files()) | |
121 | |
122 def _add_defaults_c_libs(self): | |
123 if self.distribution.has_c_libraries(): | |
124 build_clib = self.get_finalized_command('build_clib') | |
125 self.filelist.extend(build_clib.get_source_files()) | |
126 | |
127 def _add_defaults_scripts(self): | |
128 if self.distribution.has_scripts(): | |
129 build_scripts = self.get_finalized_command('build_scripts') | |
130 self.filelist.extend(build_scripts.get_source_files()) | |
131 | |
132 | |
133 if hasattr(sdist.sdist, '_add_defaults_standards'): | |
134 # disable the functionality already available upstream | |
135 class sdist_add_defaults: | |
136 pass |