python / python/cpython

The 'stdlib compileall' function writes stage directory into *.pyc files

未关闭
#95,502 4 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

topic-installation type-bug
主要语言
Python
星标
77.2k
派生
36k
PR 合并指标
PR 指标待抓取

描述

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

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

首先使用 openqasm-pygments 包、--root=/tmp/openqasm-pygments 和 --prefix=/usr/local 重现 pip 安装,然后检查 Python 的 stdlib compileall 行为。验证生成的 .cpython-39.pyc 文件将源路径记录在何处;当已安装字节码的路径不再包含 staging 目录,而是以安装前缀开头时,即表示完成。

由索引模型根据 Issue 内容生成。

评估

技术栈
python
领域
build-system
Issue 类型
缺陷
难度
4/5
预计耗时
3-5 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
35/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。