I’m the author of a package called “my_pkg”, which depends on another package called “dep_pkg”. However, dep_pkg has its own dependency called “huge_pkg”, which is big and complicated to install. In fact, dep_pkg can run fine without huge_pkg.
How can I make it so that running “pip install my_pkg” installs dep_pkg but not huge_pkg?
The authors of dep_pkg are not willing to put huge_pkg in extras_require (because they want it to be installed by default), but they would agree to put an opt-out via env var in setup.py:
if not os.getenv('SKIP_HUGE_PKG'):
install_requires.append('huge_pkg')
My idea was that in my_pkg’s setup.py, I could set the env var before calling setup():
os.environ['SKIP_HUGE_PKG'] = '1'
setup(
name='my_pkg',
install_requires=['dep_pkg'],
)
According to my testing, sometimes this works, sometimes not. It looks like each package’s setup.py command is launched in a subprocess via pip’s call_subprocess
, so env vars don’t carry over.
Any ideas how I can make this work? I know I could tell my users to set SKIP_HUGE_PKG
in their shell before doing pip install my_pkg
, but that has its own drawbacks.
Or is there a way other than using env vars? Like passing some flag in install_requires like no-deps
to install my requirements without their dependencies?
Thank you!