pex
pex copied to clipboard
Passing interpreter when referencing modules on PYTHONPATH
Per @jsirois on #235, opening a new issue.
When using Pex's --python
option to build a package whose setup.py references a module in the same directory (for example, import versioneer
), the build fails.
@jsirois Linked to https://github.com/pantsbuild/pex/blob/master/pex/resolvable.py#L254-L257 . I'd work on a PR myself, but I'm not super familiar with Pex's inner workings. As a workaround, I've disabled versioneer for all of our pex-built projects.
A workaround is to add a MANIFEST.in:
include versioneer.py
include my_app/_version.py
This appears to be related to #340. I've picked that up and will close this if it fixes. I think it does.
This is now fixed.
My test rig:
# Simple project using versioneer 0.16.0 which was latest at the time of the OP.
# /tmp/issues/235
:; tree
.
├── setup.cfg
├── setup.py
├── src
│ └── myproject
│ ├── __init__.py
│ └── _version.py
└── versioneer.py
3 directories, 5 files
# Works with `python setup.py sdist`:
# /tmp/issues/235
:; python setup.py sdist
running sdist
...
UPDATING myproject-0+untagged.3.g20a2625/src/myproject/_version.py
set myproject-0+untagged.3.g20a2625/src/myproject/_version.py to '0+untagged.3.g20a2625'
creating dist
Creating tar archive
removing 'myproject-0+untagged.3.g20a2625' (and everything under it)
# And now works with Pex too:
# /tmp/issues/235
:; pex -V
2.16.1
:; pex . -o myproject.pex
:; ./myproject.pex -c 'from myproject import __version__; print(__version__)'
0+untagged.3.g20a2625
# Even when not in project dir:
# /tmp/issues/235
:; cd
# ~
:; pex /tmp/issues/235 -o myproject-not-in-cwd.pex
# ~
:; ./myproject-not-in-cwd.pex -c 'from myproject import __version__; print(__version__)'
0+untagged.3.g20a2625