Skip to main content

setuptools plugin to configure the dependency among commands

Project description

setuptools-cmd-deps

Continuous Integration pypi

Configure setuptools command dependencies easily.

Why I need this plugin

Once a custom setuptools command is defined and needs to be run before some build-in command, traditionally, there's no simple way and the solution is to override the build-in command, to call the new custom command before the command implemented in the super class.

In this way, having an additional class and digging into setuptools, are just to configure the command order or dependency.

This could be simplified by using setuptools-cmd-deps: enable the plugin and add custom configuration.

Command dependency in the project

If your command is just for the project and it won't be reused, 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, add setuptools-cmd-deps in your dependency list, such as requirements.txt, or Pipfile.

  • If your setup.py supports running out of venv, you may not want these packages to be installed in the system. Then add setuptools-cmd-deps in the setup_requires option of your setuptools.

Define dependency

setuptools.setup(
    cmdclass={'generate_py': GenereatePy},
    cmd_deps={'build_py': ['generate_py']},
)

Command dependency to be shared

If you are developing a setuptools plugin, and want the 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 in the entry_points as follows,

distutils.commands =
    generate_py = command:GeneratePy

and want it always run before build_py. Simply add setuptools.cmd_deps in the entry_points 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 TOML 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

Both cmd1 and cmd2 will be run before command.

Or you can have multiple rules,

setuptools.cmd_deps =
    command_dep1 = command:cmd1
    command_dep2 = command:cmd2

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

setuptools-cmd-deps-1.0.1.tar.gz (13.0 kB view details)

Uploaded Source

Built Distribution

setuptools_cmd_deps-1.0.1-py3-none-any.whl (7.4 kB view details)

Uploaded Python 3

File details

Details for the file setuptools-cmd-deps-1.0.1.tar.gz.

File metadata

  • Download URL: setuptools-cmd-deps-1.0.1.tar.gz
  • Upload date:
  • Size: 13.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.5.9

File hashes

Hashes for setuptools-cmd-deps-1.0.1.tar.gz
Algorithm Hash digest
SHA256 6001a8a5bb4f417e239f1ed86180bad77ccac4aa37232e9371c47c40a63e8f1f
MD5 5b923ae0652b7bdc30c86c2325bec12c
BLAKE2b-256 b704bbf89e7f50fbd55fd0f54692fcde4c33f297a3af7cb3ffd60fe3051c9975

See more details on using hashes here.

File details

Details for the file setuptools_cmd_deps-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: setuptools_cmd_deps-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 7.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.5.9

File hashes

Hashes for setuptools_cmd_deps-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 0e883071e161d4fabbbfc510a31aa94441e83b995553a7e45c7611fd317e7ab2
MD5 98ef13110795054935e718987d72c27f
BLAKE2b-256 306c9fb32399d2e22ac7cfd6f3db5133f5d29a81713d2325388a4c7646007bc8

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page