[Python-checkins]
python/nondist/sandbox/setuptools/setuptools/command
__init__.py, NONE, 1.1 build_ext.py, NONE, 1.1 build_py.py,
NONE, 1.1 depends.py, NONE, 1.1 install.py, NONE,
1.1 install_lib.py, NONE, 1.1 test.py, NONE, 1.1
pje at users.sourceforge.net
pje at users.sourceforge.net
Fri Mar 19 15:53:16 EST 2004
- Previous message: [Python-checkins] python/nondist/sandbox/setuptools/setuptools
__init__.py, NONE, 1.1 depends.py, NONE, 1.1 dist.py, NONE,
1.1 extension.py, NONE, 1.1
- Next message: [Python-checkins]
python/nondist/sandbox/setuptools/setuptools/tests
__init__.py, NONE, 1.1
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /cvsroot/python/python/nondist/sandbox/setuptools/setuptools/command
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31783/setuptools/command
Added Files:
__init__.py build_ext.py build_py.py depends.py install.py
install_lib.py test.py
Log Message:
Initial checkin of setuptools 0.0.1.
--- NEW FILE: __init__.py ---
import distutils.command
__all__ = ['test', 'depends']
# Make our commands available as though they were part of the distutils
distutils.command.__path__.extend(__path__)
distutils.command.__all__.extend(
[cmd for cmd in __all__ if cmd not in distutils.command.__all__]
)
--- NEW FILE: build_ext.py ---
# Attempt to use Pyrex for building extensions, if available
try:
from Pyrex.Distutils.build_ext import build_ext
except ImportError:
from distutils.command.build_ext import build_ext
--- NEW FILE: build_py.py ---
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):
"""Enhanced 'build_py' command that includes data files with packages
The data files are specified via a 'package_data' argument to 'setup()'.
See 'setuptools.dist.Distribution' for more details.
Also, this version of the 'build_py' command allows you to specify both
'py_modules' and 'packages' in the same setup operation.
"""
def finalize_options(self):
_build_py.finalize_options(self)
self.package_data = self.distribution.package_data
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
if self.py_modules:
self.build_modules()
if self.packages:
self.build_packages()
self.build_package_data()
# 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))
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('.')))
# 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)
]
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,[])
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)
self.mkpath(os.path.dirname(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
'.pyo' files if 'include_bytecode' is true. (This method is needed for
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
]
--- NEW FILE: depends.py ---
from distutils.cmd import Command
import os
class depends(Command):
"""Download and install dependencies, if needed"""
description = "download and install dependencies, if needed"
user_options = [
('temp=', 't',
"directory where dependencies will be downloaded and built"),
('ignore-extra-args', 'i',
"ignore options that won't be passed to child setup scripts"),
]
def initialize_options(self):
self.temp = None
self.install_purelib = self.install_platlib = None
self.install_lib = self.install_libbase = None
self.install_scripts = self.install_data = self.install_headers = None
self.compiler = self.debug = self.force = None
def finalize_options(self):
self.set_undefined_options('build',('build_temp', 'temp'))
def run(self):
self.announce("downloading and building here")
--- NEW FILE: install.py ---
from distutils.command.install import install as _install
class install(_install):
"""Build dependencies before installation"""
def has_dependencies(self):
return self.distribution.has_dependencies()
sub_commands = [('depends',has_dependencies)] + _install.sub_commands
--- NEW FILE: install_lib.py ---
from distutils.command.install_lib import install_lib as _install_lib
class install_lib(_install_lib):
"""Don't add compiled flags to filenames of non-Python files"""
def _bytecode_filenames (self, py_filenames):
bytecode_files = []
for py_file in py_filenames:
if not py_file.endswith('.py'):
continue
if self.compile:
bytecode_files.append(py_file + "c")
if self.optimize > 0:
bytecode_files.append(py_file + "o")
return bytecode_files
--- NEW FILE: test.py ---
from distutils.cmd import Command
from distutils.errors import DistutilsOptionError
import sys
class test(Command):
"""Command to run unit tests after installation"""
description = "run unit tests after installation"
user_options = [
('test-module=','m', "Run 'test_suite' in specified module"),
('test-suite=','s',
"Test suite to run (e.g. 'some_module.test_suite')"),
]
test_suite = None
test_module = None
def initialize_options(self):
pass
def finalize_options(self):
if self.test_suite is None:
if self.test_module is None:
self.test_suite = self.distribution.test_suite
else:
self.test_suite = self.test_module+".test_suite"
elif self.test_module:
raise DistutilsOptionError(
"You may specify a module or a suite, but not both"
)
self.test_args = [self.test_suite]
if self.verbose:
self.test_args.insert(0,'--verbose')
def run(self):
# Install before testing
self.run_command('install')
if self.test_suite:
cmd = ' '.join(self.test_args)
if self.dry_run:
self.announce('skipping "unittest %s" (dry run)' % cmd)
else:
self.announce('running "unittest %s"' % cmd)
import unittest
unittest.main(None, None, [unittest.__file__]+self.test_args)
- Previous message: [Python-checkins] python/nondist/sandbox/setuptools/setuptools
__init__.py, NONE, 1.1 depends.py, NONE, 1.1 dist.py, NONE,
1.1 extension.py, NONE, 1.1
- Next message: [Python-checkins]
python/nondist/sandbox/setuptools/setuptools/tests
__init__.py, NONE, 1.1
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the Python-checkins
mailing list