I have a python project with some modules, scripts and optional dependencies:
[project.optional-dependencies]
extra = [ "tqdm", "antspyx>=0.4.2", "scikit-image", "mpi4py", "scipy" ]
[project.scripts]
reg = "myproject._cmd.reg:main"
conv = "myproject._cmd.conv:main"
[tool.setuptools.packages.find]
where = ["src"]
include = ["myproject*"]
Now I would like the scripts to be installed, only for pip install myproject[extra]
. By now, these scripts are installed even for pip install myproject
It would also be nice to be able to split my modules like this. Modules in src/myproject/extra/
should be installed only for pip install myproject[extra]
. If pip install myproject
is called, only modules in src/myproject/modules/
should be installed.
So, how can I declare optional modules and optional scripts in pyproject.toml?
__init__.py
of the sub-package needed the dependency:try: import yourExtraPackage except ImportError: raise SystemExit("ERROR MESSAGE FOR THE USER HERE")
– Boatbill