Commit 8ed698da authored by Jason R. Coombs's avatar Jason R. Coombs

Extract methods from sdist.add_defaults, allowing subclasses to override or...

Extract methods from sdist.add_defaults, allowing subclasses to override or inject different behaviors.
parent c6f60939
...@@ -220,6 +220,15 @@ class sdist(Command): ...@@ -220,6 +220,15 @@ class sdist(Command):
Warns if (README or README.txt) or setup.py are missing; everything Warns if (README or README.txt) or setup.py are missing; everything
else is optional. else is optional.
""" """
self._add_defaults_standards()
self._add_defaults_optional()
self._add_defaults_python()
self._add_defaults_data_files()
self._add_defaults_ext()
self._add_defaults_c_libs()
self._add_defaults_scripts()
def _add_defaults_standards(self):
standards = [self.READMES, self.distribution.script_name] standards = [self.READMES, self.distribution.script_name]
for fn in standards: for fn in standards:
if isinstance(fn, tuple): if isinstance(fn, tuple):
...@@ -240,11 +249,13 @@ class sdist(Command): ...@@ -240,11 +249,13 @@ class sdist(Command):
else: else:
self.warn("standard file '%s' not found" % fn) self.warn("standard file '%s' not found" % fn)
def _add_defaults_optional(self):
optional = ['test/test*.py', 'setup.cfg'] optional = ['test/test*.py', 'setup.cfg']
for pattern in optional: for pattern in optional:
files = filter(os.path.isfile, glob(pattern)) files = filter(os.path.isfile, glob(pattern))
self.filelist.extend(files) self.filelist.extend(files)
def _add_defaults_python(self):
# build_py is used to get: # build_py is used to get:
# - python modules # - python modules
# - files defined in package_data # - files defined in package_data
...@@ -260,6 +271,7 @@ class sdist(Command): ...@@ -260,6 +271,7 @@ class sdist(Command):
for filename in filenames: for filename in filenames:
self.filelist.append(os.path.join(src_dir, filename)) self.filelist.append(os.path.join(src_dir, filename))
def _add_defaults_data_files(self):
# getting distribution.data_files # getting distribution.data_files
if self.distribution.has_data_files(): if self.distribution.has_data_files():
for item in self.distribution.data_files: for item in self.distribution.data_files:
...@@ -276,14 +288,17 @@ class sdist(Command): ...@@ -276,14 +288,17 @@ class sdist(Command):
if os.path.isfile(f): if os.path.isfile(f):
self.filelist.append(f) self.filelist.append(f)
def _add_defaults_ext(self):
if self.distribution.has_ext_modules(): if self.distribution.has_ext_modules():
build_ext = self.get_finalized_command('build_ext') build_ext = self.get_finalized_command('build_ext')
self.filelist.extend(build_ext.get_source_files()) self.filelist.extend(build_ext.get_source_files())
def _add_defaults_c_libs(self):
if self.distribution.has_c_libraries(): if self.distribution.has_c_libraries():
build_clib = self.get_finalized_command('build_clib') build_clib = self.get_finalized_command('build_clib')
self.filelist.extend(build_clib.get_source_files()) self.filelist.extend(build_clib.get_source_files())
def _add_defaults_scripts(self):
if self.distribution.has_scripts(): if self.distribution.has_scripts():
build_scripts = self.get_finalized_command('build_scripts') build_scripts = self.get_finalized_command('build_scripts')
self.filelist.extend(build_scripts.get_source_files()) self.filelist.extend(build_scripts.get_source_files())
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment