setuptools plugin to configure the dependency among commands
Project description
setuptools-cmd-deps
Configure setuptools
command dependencies easily.
Once a custom setuptools
command is defined and needs to be run before some build-in command,
the solution is to override the build-in command to ensure the new custom command is called.
For example, if a custom command genreate_py
is implemented in class GeneratePy
and needs to be run before build_py
,
You need to create you own command class MyBuildPy
and call both generate_py
and build-in build_py
.
Then override build_py
command in the invocation of setuptools.setup
as follows,
class GeneratePy(setuptools.Command):
...
class MyBuildPy(setuptools.command.build_py.build_py):
...
setuptools.setup(
cmdclass={
'generate_py': GenereatePy,
'build_py': MyBuildPy,
},
)
The implementation of MyBuildPy
could be eliminated by using setuptools-cmd-deps
.
Command dependency in the project
If the command is just for the project and it won't be shared,
you could use new setup keyword cmd_deps
to define the dependencies.
Enable setuptools-cmd-deps
-
If your
setup.py
will run only after all depending packages are installed, addsetuptools-cmd-deps
in your dependency list, such asrequirements.txt
, orPipfile
. -
If your
setup.py
supports running out of venv, you may not want these packages to be installed in the system. Then addsetuptools-cmd-deps
in thesetup_requires
option of yoursetuptools
.
Define dependency
setuptools.setup(
cmdclass={'generate_py': GenereatePy},
cmd_deps={'build_py': ['generate_py']},
)
Command dependency to be shared
If you want command definition to be used by other project and run before some command,
specify the dependency in the setuptools.cmd_deps
section in your entry_points
.
Enable setuptools-cmd-deps for the target
Add setuptools-cmd-deps
in the install_requires
option of your setuptools
,
so that any project uses your package, will automatically uses setuptools-cmd-deps
.
Define dependency
Generally speaking, you already have distutils.commands
in your entry_points
.
For example, you defined gernate_py
command as follows,
distutils.commands =
generate_py = command:GeneratePy
and want it always run before build_py
, then add setuptools.cmd_deps
as follows,
setuptools.cmd_deps =
build_py_dep = build_py:generate_py
Note that the name build_py_dep
is not used here.
It is just for the syntax.
For the same reason, if there are multiple dependencies for one command,
it should use dot .
as delimiter,
setuptools.cmd_deps =
command_dep = command:cmd1.cmd2
or you can have multiple rules,
setuptools.cmd_deps =
command_dep1 = command:cmd1
command_dep2 = command:cmd2
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for setuptools-cmd-deps-1.0.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 41bd0894dd61fdd3dafecde07c24e7e2813f66505f020dc5258c1095878de769 |
|
MD5 | 827db52c1b80ef60c12f88620ec2275e |
|
BLAKE2b-256 | d7be440b9d49f7f452d1a0e6b18a59dbffbe874ac5f3dbe924291941fec6d9c2 |
Hashes for setuptools_cmd_deps-1.0.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e1e5b5e84d93017922e36f5184c5a192ad72b9a9a549b24d87218d4ac29d9755 |
|
MD5 | 0c3e0df52fe12d0fa175f07c8ef7d27a |
|
BLAKE2b-256 | 5d117e897e8aca6f972169494bed4ad2d08242530e9b5ce4e416106ac05bfddf |