Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pip compiles pyc files for installed scripts #11406

Open
1 task done
SpecLad opened this issue Aug 25, 2022 · 2 comments · May be fixed by #11413
Open
1 task done

pip compiles pyc files for installed scripts #11406

SpecLad opened this issue Aug 25, 2022 · 2 comments · May be fixed by #11413
Labels
state: awaiting PR Feature discussed, PR is needed type: feature request Request for a new feature

Comments

@SpecLad
Copy link
Contributor

SpecLad commented Aug 25, 2022

Description

When pip installs a wheel with custom scripts that have a .py extension, it creates corresponding .pyc files. This pollutes the bin directory, and doesn't accomplish anything, since I don't think Python loads .pyc files for scripts.

Expected behavior

Now granted, the wheel spec does say:

Compile any installed .py to .pyc. (Uninstallers should be smart enough to remove .pyc even if it is not mentioned in RECORD.)

(emphasis mine)

But I think common sense suggests that only .py files in the purelib and platlib directories should be compiled.

pip version

22.2.2

Python version

3.10.4

OS

Ubuntu 22.04

How to Reproduce

Install docutils, then look in the bin directory.

Output

$ python3 -mvenv ./venv
$ ./venv/bin/pip install -U pip
[...]
$ ./venv/bin/pip install docutils
Collecting docutils
  Downloading docutils-0.19-py3-none-any.whl (570 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 570.5/570.5 kB 2.2 MB/s eta 0:00:00
Installing collected packages: docutils
Successfully installed docutils-0.19
$ ls ./venv/bin/__pycache__/
rst2html.cpython-310.pyc   rst2latex.cpython-310.pyc  rst2odt_prepstyles.cpython-310.pyc  rst2xetex.cpython-310.pyc
rst2html4.cpython-310.pyc  rst2man.cpython-310.pyc    rst2pseudoxml.cpython-310.pyc       rst2xml.cpython-310.pyc
rst2html5.cpython-310.pyc  rst2odt.cpython-310.pyc    rst2s5.cpython-310.pyc              rstpep2html.cpython-310.pyc

Code of Conduct

@SpecLad SpecLad added S: needs triage Issues/PRs that need to be triaged type: bug A confirmed bug or unintended behavior labels Aug 25, 2022
@pfmoore
Copy link
Member

pfmoore commented Aug 26, 2022

IMO, this isn't worth worrying about. It should be rare (these days, entry points are recommended over scripts anyway) and it doesn't cause any real problem, just clutter.

Having said that, if someone were to create a PR, it could be considered.

@pfmoore pfmoore added state: awaiting PR Feature discussed, PR is needed type: feature request Request for a new feature and removed type: bug A confirmed bug or unintended behavior S: needs triage Issues/PRs that need to be triaged labels Aug 26, 2022
@q0w q0w linked a pull request Aug 27, 2022 that will close this issue
@SpecLad
Copy link
Contributor Author

SpecLad commented Aug 28, 2022

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
state: awaiting PR Feature discussed, PR is needed type: feature request Request for a new feature
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants