setuptools¶
Tests¶
Place the tests in the test directory. Per default setuptools adds the
test directory to the source distribution sdist. This can be disabled
in the MANIFEST.in.
Commands dependencies¶
Graph showing the dependencies between the common setuptools commands:
![//
digraph setuptools {
node [fontsize=10]
edge [fontsize=8]
"install" -> "bdist_egg" [label="install"]
"install" -> "install_lib" [label="bdist,bdist_dumb,bdist_wheel"]
"build" -> "build_py"
"build_py" -> "egg_info"
"bdist_egg" -> "egg_info"
"bdist_egg" -> "install_lib"
"install_egg_info" -> "egg_info"
"install_lib" -> "build_py" [label="bdist_egg,install,install_lib"]
"install_lib" -> "install_egg_info" [label="bdist,bdist_dumb,bdist_wheel"]
"install_egg_info" -> "install_scripts"
"bdist_dumb" -> "build"
"bdist_dumb" -> "install"
"bdist_wheel" -> "build"
"bdist_wheel" -> "install"
"bdist" -> "bdist_dumb"
"sdist" -> "egg_info"
"sdist" -> "check"
"develop" -> "build_ext"
"develop" -> "egg_info"
"test" -> "egg_info"
"test" -> "build_ext"
}
// EOF](../_images/graphviz-50bfa51c0dc7c00e1d0b11f9cca07e42e1bcf041.png)
Extend install command¶
Warning
This is a work in progress that needs to be improved on.
This shows how to add a subcommand to the install command. This also shows
how the subcommand can add to the list of files to be installed (packaged in a
bdist).
class install_something(setuptools.Command):
user_options = [
('install-dir=', 'd', "directory to install to"),
]
def initialize_options(self):
self.install_dir = None
def finalize_options(self):
self.outputs = []
self.set_undefined_options(
'install',
('install_lib', 'install_dir'),
)
def run(self):
self.outputs.append('package/something.bin')
self.mkpath(self.install_dir + 'package')
self.copy_file(
'src/package/something.bin',
self.install_dir + 'package/something.bin',
)
def get_outputs(self):
return self.outputs
class install(distutils.command.install.install):
_sub_command = (
'install_something',
None,
)
_sub_commands = distutils.command.install.install.sub_commands
sub_commands = [_sub_command] + _sub_commands