aboutsummaryrefslogtreecommitdiffstats
path: root/setuptools/command
diff options
context:
space:
mode:
Diffstat (limited to 'setuptools/command')
-rw-r--r--setuptools/command/__init__.py2
-rw-r--r--setuptools/command/build_py.py65
-rw-r--r--setuptools/command/depends.py51
3 files changed, 35 insertions, 83 deletions
diff --git a/setuptools/command/__init__.py b/setuptools/command/__init__.py
index 3429634c..86263cfb 100644
--- a/setuptools/command/__init__.py
+++ b/setuptools/command/__init__.py
@@ -8,4 +8,4 @@ __all__ = ['test', 'depends']
distutils.command.__path__.extend(__path__)
distutils.command.__all__.extend(
[cmd for cmd in __all__ if cmd not in distutils.command.__all__]
-)
+ )
diff --git a/setuptools/command/build_py.py b/setuptools/command/build_py.py
index 7d5b6ffd..95e83c30 100644
--- a/setuptools/command/build_py.py
+++ b/setuptools/command/build_py.py
@@ -1,10 +1,11 @@
+import os.path
+
from distutils.command.build_py import build_py as _build_py
from distutils.util import convert_path
from glob import glob
-import os.path
-class build_py(_build_py):
+class build_py(_build_py):
"""Enhanced 'build_py' command that includes data files with packages
The data files are specified via a 'package_data' argument to 'setup()'.
@@ -17,13 +18,10 @@ class build_py(_build_py):
def finalize_options(self):
_build_py.finalize_options(self)
self.package_data = self.distribution.package_data
- self.data_files = self.get_data_files()
-
+ self.data_files = self.get_data_files()
def run(self):
-
"""Build modules, packages, and copy data files to build directory"""
-
if not self.py_modules and not self.packages:
return
@@ -36,21 +34,17 @@ class build_py(_build_py):
# Only compile actual .py files, using our base class' idea of what our
# output files are.
- self.byte_compile(_build_py.get_outputs(self,include_bytecode=0))
-
+ self.byte_compile(_build_py.get_outputs(self, include_bytecode=0))
def get_data_files(self):
-
"""Generate list of '(package,src_dir,build_dir,filenames)' tuples"""
-
data = []
-
for package in self.packages:
# 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('.')))
+ build_dir = os.path.join(*([self.build_lib] + package.split('.')))
# Length of path to strip from found files
plen = len(src_dir)+1
@@ -58,44 +52,30 @@ class build_py(_build_py):
# Strip directory from globbed filenames
filenames = [
file[plen:] for file in self.find_data_files(package, src_dir)
- ]
-
+ ]
data.append( (package, src_dir, build_dir, filenames) )
-
return data
-
def find_data_files(self, package, src_dir):
-
"""Return filenames for package's data files in 'src_dir'"""
-
- globs = self.package_data.get('',[])+self.package_data.get(package,[])
+ globs = (self.package_data.get('', [])
+ + self.package_data.get(package, []))
files = []
-
for pattern in globs:
# Each pattern has to be converted to a platform-specific path
files.extend(glob(os.path.join(src_dir, convert_path(pattern))))
-
return files
-
-
def build_package_data(self):
-
"""Copy data files into build directory"""
-
lastdir = None
-
for package, src_dir, build_dir, filenames in self.data_files:
-
for filename in filenames:
- target = os.path.join(build_dir,filename)
+ target = os.path.join(build_dir, filename)
self.mkpath(os.path.dirname(target))
- self.copy_file(os.path.join(src_dir,filename), target)
-
+ self.copy_file(os.path.join(src_dir, filename), target)
def get_outputs(self, include_bytecode=1):
-
"""Return complete list of files copied to the build directory
This includes both '.py' files and data files, as well as '.pyc' and
@@ -103,21 +83,8 @@ class build_py(_build_py):
the 'install_lib' command to do its job properly, and to generate a
correct installation manifest.)
"""
-
- return _build_py.get_outputs(self,include_bytecode) + [
- os.path.join(build_dir,filename)
- for package,src_dir,build_dir,filenames in self.data_files
- for filename in filenames
- ]
-
-
-
-
-
-
-
-
-
-
-
-
+ return _build_py.get_outputs(self, include_bytecode) + [
+ os.path.join(build_dir, filename)
+ for package, src_dir, build_dir,filenames in self.data_files
+ for filename in filenames
+ ]
diff --git a/setuptools/command/depends.py b/setuptools/command/depends.py
index 9d9c9f43..cd8442b7 100644
--- a/setuptools/command/depends.py
+++ b/setuptools/command/depends.py
@@ -1,9 +1,10 @@
+import os
+import sys
+
from distutils.cmd import Command
-import os, sys
class depends(Command):
-
"""Download and install dependencies, if needed"""
description = "download and install dependencies, if needed"
@@ -13,28 +14,27 @@ class depends(Command):
"directory where dependencies will be downloaded and built"),
('ignore-extra-args', 'i',
"ignore options that won't be passed to child setup scripts"),
- ]
+ ]
path_attrs = [
# Note: these must be in *reverse* order, as they are pushed onto the
# *front* of a copy of sys.path.
- ('install','install_libbase'), # installation base if extra_path
- ('install_lib','install_dir'), # where modules are installed
- ]
+ ('install', 'install_libbase'), # installation base if extra_path
+ ('install_lib', 'install_dir'), # where modules are installed
+ ]
# Command options that can be safely passed to dependencies' setup scripts
safe_opts = {
'install': [
- 'prefix','exec-prefix','home','install-base','install-platbase',
- 'root','optimize','force','verbose','quiet'
- ],
- 'build': ['compiler','debug','force','verbose','quiet'],
- }
+ 'prefix', 'exec-prefix', 'home', 'install-base',
+ 'install-platbase', 'root', 'optimize', 'force', 'verbose', 'quiet'
+ ],
+ 'build': ['compiler', 'debug', 'force', 'verbose', 'quiet'],
+ }
# Options with string arguments that are *not* directories or files, and
# so should *not* have absolute-path fixups applied.
- non_fs_opts = {'build':['compiler'] }
-
+ non_fs_opts = {'build': ['compiler']}
def initialize_options(self):
self.temp = None; self.ignore_extra_args = None
@@ -85,7 +85,7 @@ class depends(Command):
needed = [
dep for dep in self.distribution.requires if self.is_needed(dep)
- ]
+ ]
if not needed:
self.announce("all dependencies are present and up-to-date")
@@ -97,7 +97,7 @@ class depends(Command):
self.announce(
"dependencies will be installed using:\n "+' '.join(argv)+'\n'
- )
+ )
# Alert for unsupported commands/options, unless '-i' was used
if self.unsafe_options:
@@ -109,31 +109,26 @@ class depends(Command):
" force the build to proceed.\nOtherwise, you will need"
" to omit the unsupported options,\nor install the"
" dependencies manually."
- )
-
+ )
# Alert the user to missing items
fmt = "\t%s\t%s\n"
- items = [fmt % (dep.full_name(),dep.homepage) for dep in needed]
+ items = [fmt % (dep.full_name(), dep.homepage) for dep in needed]
items.insert(0,"Please install the following packages *first*:\n")
items.append('')
raise SystemExit('\n'.join(items)) # dump msg to stderr and exit
-
-
def warn_unsafe_options_used(self):
lines = []; write = lines.append
write("the following command options are not supported for building")
write("dependencies, and will be IGNORED:")
for cmd,line in self.unsafe_options.items():
- write('\t%s %s' % (cmd,' '.join(line)))
+ write('\t%s %s' % (cmd, ' '.join(line)))
write('')
self.warn('\n'.join(lines))
-
def is_needed(self,dep):
"""Does the specified dependency need to be installed/updated?"""
-
self.announce("searching for "+dep.full_name())
version = dep.get_version(self.search_path)
@@ -152,13 +147,3 @@ class depends(Command):
else:
self.announce(status+" (update needed)")
return True
-
-
-
-
-
-
-
-
-
-