I know that's possible to define optional dependencies in setup.py with extra-require
. Now I'm asking myself if its possible to also mark packages as optional in a way that you can chose which subpackages you want to install? Is there a way to map the optional dependencies to the optional packages.
For example if i have a project called project A and this package structure:
Project
--subPackage 1
--subPackage 2
--subPackage 3
I would like to mark subpackage 2 and 3 as optional so that these packages are not installed by default. But if a subpackage is specified via pip or requirement by project B it should be installed with the dependencies.
So the expected behavior would be for project B should be the following:
setup.py for Project B:
setup(
name='Project B',
version='0.0.0',
install_requires=["ProjectA"])
results in only Project 1 with subpackage 1 is installed. But if i change the install_requires
line to install_requires=["ProjectA[Subpackage2]"]
. Project A is installed with subpackage 1 and 2 with the given requirements for subpackage 1 and 2.
This there a away to crate a setup.py for Project A to archive this behavior ?