https://pantsbuild.org/ logo
#general
Title
# general
h

high-energy-55500

09/30/2022, 4:13 PM
not sure if i’m doing something wrong or if this isn’t supported, but is it possible to add extras to a
python_requirement
target? e.g.
Copy code
python_requirement(
    name="apache-airflow",
    requirements=[
        "apache-airflow[amazon]==2.2.2",
    ],
    modules=["airflow"],
)
this doesn’t seem to include the
amazon
extra (if i run pylint against code that uses this as a dependency, it fails to import
from amazon.providers.amazon
) however, including the extra as a separate package seems to work, e.g.
Copy code
python_requirement(
    name="apache-airflow",
    requirements=[
        "apache-airflow==2.2.2",
        "apache-airflow-providers-amazon==2.4.0",
    ],
    modules=["airflow"],
)
the downside is that i have to manually specify the compatible version of the package, which i’d like to avoid
h

hundreds-father-404

09/30/2022, 4:25 PM
extras should work.. you could try using
-ldebug
to see what Pants is telling Pex to build in its argv, to make sure it is propagating the extra properly
e

enough-analyst-54434

09/30/2022, 5:06 PM
You almost certainly need an explicit dep in the `python_sources`that need this extra. If there is an import you have in your code from that extra, then you may just need a module mapping, but, more likely, the extra just activates code inside apache airflow; so you'll need the explicit dep.
And there may be no way to specify that explicit dep in Pants today! I'm not sure. @hundreds-father-404 would know if there is a way to say ~
dependencies=["requirements#apache-airflow[amazon]"]
.
4 Views