Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to package a Python module with extras as default?

My Python package has optional features (extras_require) and I would prefer them to be selected by default.

More specifically, I'd like that pip install mypackage behaves like pip install mypackage[extra] and that I can install a minimal version with something like pip install mypackage[core].

setup(
    name="mypackage",
    ...
    extras_require={
        "extra":  ["extra1>=1.2", "extra2"],
        "core": [],
    }
)

Is it possible to achieve this with a setup script similar to above?

like image 245
DurandA Avatar asked Apr 07 '26 13:04

DurandA


1 Answers

Unfortunately this is not possible with the current state of Python packaging metadata & tooling.

See a long discussion here as to why.

like image 186
Dustin Ingram Avatar answered Apr 10 '26 02:04

Dustin Ingram



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!