https://pantsbuild.org/ logo
g

green-match-66337

05/13/2022, 7:47 AM
How does pants handle dynamic imports with dependency inference? For example if we use a typing library which is bloated but we don't want that in the package for lambda deployment to minimise artefact size?
c

curved-television-6568

05/13/2022, 8:11 AM
Regarding dynamic imports, there’s some options in this subsystem https://www.pantsbuild.org/docs/reference-python-infer Not sure if that answers your question though. Your example hints at excluding dependencies, that possibly where inferred. You can do that using
!
and
!!
in your dependencies field. See the note at the end of https://www.pantsbuild.org/docs/targets#dependencies-field
👍 1
g

green-match-66337

05/13/2022, 8:57 AM
Thanks! That partially solves it, would be good to be able to dynamically set the
!
based on a setting, will have a look around the docs
r

rhythmic-morning-87313

05/13/2022, 9:18 AM
👍 1
c

curved-television-6568

05/13/2022, 10:51 AM
If there’s a select few imports you don’t want to be inferred by the dependency engine, there’s also a pragma you can apply in code:
Copy code
... # pants: ignore-dep
👍 2
My bad, it is
# pants: no-infer-dep
. It was renamed.
@bitter-ability-32190 did this feature make it into the docs..?
b

bitter-ability-32190

05/13/2022, 11:18 AM
Hmm maybe not?
🙈 1
FYI @hundreds-father-404 the wordsmith 😛