Is it possible to get pants to strip typestub libr...
# general
d
Is it possible to get pants to strip typestub libraries out of the final pex build?
app.py
Copy code
import requests
print(requests.__version__)
pyproject.toml
Copy code
[project]
name = 'test'
dependencies = [
  'requests',
  'types-requests',
]
BUILD
Copy code
python_requirements(
    name="root",
    source="pyproject.toml",
)

python_sources(
    name="0",
)

pex_binary(
    name="app",
    entry_point="app.py",
    layout="loose",
)
Copy code
➜ pants dependencies --transitive app.py
//:root#requests
//:root#types-requests
//pyproject.toml:root
Looking inside the outputted pex binary
types-requests
is packaged, (also in
dist/app.pex/.deps
)
Copy code
jq .requirements dist/app.pex/PEX-INFO
[
  "requests",
  "types-requests"
]
The types aren’t required at all at runtime, only for the
mypy
type checking.
b
I think https://github.com/pantsbuild/pants/issues/15454 is the relevant issue. A work around is to exclude the biggest/worst ones with
!!
. See https://www.pantsbuild.org/2.19/docs/using-pants/key-concepts/targets-and-build-files#dependencies-field “ignore dependencies” section