How can I handle optional dependencies for Python ...
# general
r
How can I handle optional dependencies for Python requirements in pants? Specifically for the snowflake Python connector, which has an optional dependency on pandas I want to be able to turn on and off.
a
I'm not sure if there's a better way, but we've declared a
python_requirement
ourselves, like:
Copy code
python_requirement(name="foo_with_stuff", requirements="foo[stuff]")
So, when you want to depend on that, you just add
foo_with_stuff
to the list of deps.
If you just put both in a
requirements.txt
file, it ignores the optional stuff and just generates one.
b
What circumstances do you want to be able turn it off and on in? For different imports of it?