From 434aef220e6ec7cfc609bce631ef8528c930c20c Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sat, 16 Jan 2016 06:11:13 -0500 Subject: Move trailing comment to docstring --- setuptools/command/build_py.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'setuptools/command/build_py.py') diff --git a/setuptools/command/build_py.py b/setuptools/command/build_py.py index 8a50f032..32e37e52 100644 --- a/setuptools/command/build_py.py +++ b/setuptools/command/build_py.py @@ -59,7 +59,8 @@ class build_py(orig.build_py, Mixin2to3): self.byte_compile(orig.build_py.get_outputs(self, include_bytecode=0)) def __getattr__(self, attr): - if attr == 'data_files': # lazily compute data files + "lazily compute data files" + if attr == 'data_files': self.data_files = files = self._get_data_files() return files return orig.build_py.__getattr__(self, attr) -- cgit v1.2.3 From f55db00043f3f47b7121c42d54433bc80a01c243 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sat, 16 Jan 2016 06:11:54 -0500 Subject: Remove superfluous local variable --- setuptools/command/build_py.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'setuptools/command/build_py.py') diff --git a/setuptools/command/build_py.py b/setuptools/command/build_py.py index 32e37e52..c24646c3 100644 --- a/setuptools/command/build_py.py +++ b/setuptools/command/build_py.py @@ -61,8 +61,8 @@ class build_py(orig.build_py, Mixin2to3): def __getattr__(self, attr): "lazily compute data files" if attr == 'data_files': - self.data_files = files = self._get_data_files() - return files + self.data_files = self._get_data_files() + return self.data_files return orig.build_py.__getattr__(self, attr) def build_module(self, module, module_file, package): -- cgit v1.2.3 From 775cb73ed72e87951254bbbe373951be9caac4df Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sat, 16 Jan 2016 06:16:11 -0500 Subject: Extract function for getting data files for package. --- setuptools/command/build_py.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'setuptools/command/build_py.py') diff --git a/setuptools/command/build_py.py b/setuptools/command/build_py.py index c24646c3..3ddc7673 100644 --- a/setuptools/command/build_py.py +++ b/setuptools/command/build_py.py @@ -75,8 +75,9 @@ class build_py(orig.build_py, Mixin2to3): def _get_data_files(self): """Generate list of '(package,src_dir,build_dir,filenames)' tuples""" self.analyze_manifest() - data = [] - for package in self.packages or (): + return list(map(self._get_pkg_data_files, self.packages or ())) + + def _get_pkg_data_files(self, package): # Locate package source directory src_dir = self.get_package_dir(package) @@ -90,8 +91,7 @@ class build_py(orig.build_py, Mixin2to3): filenames = [ file[plen:] for file in self.find_data_files(package, src_dir) ] - data.append((package, src_dir, build_dir, filenames)) - return data + return package, src_dir, build_dir, filenames def find_data_files(self, package, src_dir): """Return filenames for package's data files in 'src_dir'""" -- cgit v1.2.3 From ddfbfa731e2cf73dc03b5a3345996afac843441e Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sat, 16 Jan 2016 06:16:39 -0500 Subject: Reindent --- setuptools/command/build_py.py | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'setuptools/command/build_py.py') diff --git a/setuptools/command/build_py.py b/setuptools/command/build_py.py index 3ddc7673..5021bd1f 100644 --- a/setuptools/command/build_py.py +++ b/setuptools/command/build_py.py @@ -78,20 +78,20 @@ class build_py(orig.build_py, Mixin2to3): return list(map(self._get_pkg_data_files, self.packages or ())) def _get_pkg_data_files(self, package): - # Locate package source directory - src_dir = self.get_package_dir(package) + # Locate package source directory + src_dir = self.get_package_dir(package) - # Compute package build directory - build_dir = os.path.join(*([self.build_lib] + package.split('.'))) + # Compute package build directory + build_dir = os.path.join(*([self.build_lib] + package.split('.'))) - # Length of path to strip from found files - plen = len(src_dir) + 1 + # Length of path to strip from found files + plen = len(src_dir) + 1 - # Strip directory from globbed filenames - filenames = [ - file[plen:] for file in self.find_data_files(package, src_dir) - ] - return package, src_dir, build_dir, filenames + # Strip directory from globbed filenames + filenames = [ + file[plen:] for file in self.find_data_files(package, src_dir) + ] + return package, src_dir, build_dir, filenames def find_data_files(self, package, src_dir): """Return filenames for package's data files in 'src_dir'""" -- cgit v1.2.3 From 0f590c0d72709128f32c23437fe0183386c69d1c Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sat, 16 Jan 2016 06:33:04 -0500 Subject: Prefer relpath to string slicing for computing a path relative to a base. Fixes #341. --- setuptools/command/build_py.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'setuptools/command/build_py.py') diff --git a/setuptools/command/build_py.py b/setuptools/command/build_py.py index 5021bd1f..0c1026aa 100644 --- a/setuptools/command/build_py.py +++ b/setuptools/command/build_py.py @@ -84,12 +84,10 @@ class build_py(orig.build_py, Mixin2to3): # Compute package build directory build_dir = os.path.join(*([self.build_lib] + package.split('.'))) - # Length of path to strip from found files - plen = len(src_dir) + 1 - # Strip directory from globbed filenames filenames = [ - file[plen:] for file in self.find_data_files(package, src_dir) + os.path.relpath(file, src_dir) + for file in self.find_data_files(package, src_dir) ] return package, src_dir, build_dir, filenames -- cgit v1.2.3 From 8af3b6ef5b4173a0d0d6735147c98c882ae98344 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sat, 16 Jan 2016 06:54:00 -0500 Subject: Always use Python 3 version of map --- setuptools/command/build_py.py | 1 + 1 file changed, 1 insertion(+) (limited to 'setuptools/command/build_py.py') diff --git a/setuptools/command/build_py.py b/setuptools/command/build_py.py index 0c1026aa..8623c777 100644 --- a/setuptools/command/build_py.py +++ b/setuptools/command/build_py.py @@ -9,6 +9,7 @@ import distutils.errors import collections import itertools +from setuptools.extern.six.moves import map try: from setuptools.lib2to3_ex import Mixin2to3 -- cgit v1.2.3