The 'stdlib compileall' function writes stage directory into *.pyc files
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 77.2k
- Forks
- 36k
- PR merge metrics
- PR metrics pending
Description
Description
I need to install a python package into a stage directory.
The command I run from the source directory is:
pip install {my-pkg-name} --isolated --root=/tmp/stage/dir --prefix=/usr/local --ignore-installed --no-deps
This command installs the package into the right location, but *.cpython-39.pyc files have full paths to *.py files in the stage directory.
If paths of *.py are needed they should be adjusted so that they should begin with prefix (/usr/local). This is because the source directory will be deleted before the package is run.
Pip uses cpython's stdlib compileall function that inserts stage directory paths.
See the original but report for pip: https://github.com/pypa/pip/issues/11317
pip-22.1.2
Python-3.9
FreeBSD 13.1
How to Reproduce
git clone https://github.com/openqasm/openqasm-pygments.git
cd openqasm-pygments
pip install openqasm-pygments --isolated --root=/tmp/openqasm-pygments --prefix=/usr/local --ignore-installed --no-deps
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the pip installation using the openqasm-pygments package, --root=/tmp/openqasm-pygments, and --prefix=/usr/local, then inspect Python's stdlib compileall behavior. Verify where the generated .cpython-39.pyc files record source paths; done means installed bytecode paths no longer include the staging directory and instead begin with the installation prefix.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100