setuptools-dynamic-dependencies
raw JSON → 1.0.0 verified Mon Apr 27 auth: no python
A setuptools plugin that allows dependencies to be specified dynamically based on the package's version number. It enables conditional dependency resolution within setup.py/pyproject.toml using version-range expressions. Current version 1.0.0, requires Python >=3.9, maintained by BeeWare project.
pip install setuptools-dynamic-dependencies Common errors
error ModuleNotFoundError: No module named 'setuptools_dynamic_dependencies' ↓
cause Plugin not installed in the build environment (e.g., in pyproject.toml build-system.requires).
fix
Add 'setuptools-dynamic-dependencies' to build-system.requires in pyproject.toml: [build-system]
requires = ["setuptools", "setuptools-dynamic-dependencies"]
error TypeError: 'NoneType' object is not iterable when calling get_requirements() ↓
cause DynamicDependencies instance created before version is set, leading to missing version context.
fix
Set the package version before instantiating DynamicDependencies (e.g., from your version module).
Warnings
deprecated This plugin is designed for setuptools < 68. Newer setuptools versions (>=68) natively support dynamic dependencies via pyproject.toml. Consider migrating to native setuptools configuration. ↓
fix Remove plugin and define dynamic dependencies natively in pyproject.toml using setuptools directives.
gotcha The plugin resolves dependencies at build time, not install time. It requires the package's version string to be available (e.g., via version.py or hardcoded). If version is imported from a non-existent file during build, it will fail silently or raise an error. ↓
fix Ensure version is defined before calling DynamicDependencies, either hardcoded or via a fallback.
gotcha Version-range expressions use a custom syntax (e.g., '>=1.0,<2.0'). Common range operators (e.g., ~=, !=) are not supported. This can cause confusion when migrating from PEP 440 version specifiers. ↓
fix Read the documentation for supported operators: >, >=, <, <=, ==, and combination with commas.
Imports
- DynamicDependencies
from setuptools_dynamic_dependencies import DynamicDependencies
Quickstart
from setuptools import setup
from setuptools_dynamic_dependencies import DynamicDependencies
dynamic_deps = DynamicDependencies()
# In setup() call:
setup(
name='mypackage',
version='1.0.0',
install_requires=dynamic_deps.get_requirements()
)