-
-
Notifications
You must be signed in to change notification settings - Fork 31.9k
"make altinstall" installs many files with incorrect shebangs #54527
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
Comments
The following files are incorrectly installed with a "#!/usr/bin/env python" shebang when using "make altinstall": usr/lib/python2.7/base64.py These should point to /usr/bin/python2.7 instead. |
Is there any reason for the test files to have a shebang line at all? I think those should be removed, which would cut the problem in half. Also, given "-m", I'm not sure any of the files in the stdlib should have a shebang line. Is there really an expectation that these should be run directly? Is anyone really running UserString.py as a script in order to run its tests? |
Benjamin did some cleanup in this area in at least py3k, so he might have some thoughts, making him nosy. |
Removing shebang lines from svn completely and only *adding* them during installation steps as appropriate may be an interesting approach. (I noted that my grep of my local build found only correct references to python3.2 in the built scripts directory) I'll add the list of Py3k files that are unexpectedly referencing something other than "/usr/bin/env python3" in SVN as well (note that this is a straight grep, without checking to see if any of them are *meant* to be referring to Python 2.x): Doc/distutils/setupscript.rst does not use python3 in the example Lib/test/test_logging.py: #! /usr/bin/env python Lib/cgi.py: #! /usr/bin/env python Mac/BuildScript/build-installer.py: #! /usr/bin/env python Tools/gdb/libpython.py: #! /usr/bin/env python The spec file in Misc/RPM also has multiple references to fixing shebang lines, but I don't know anything about spec files, so I didn't even try to check if it was doing the right thing. |
For the record, my list is from an svn checkout of r86191 |
A few more deeper in the py3k source tree: Doc/tools/docutils/_string_template_compat.py Adding Georg, since this affects the docs as well as the source code. |
You can ignore those under Doc/tools; they are neither part of the distribution and nor installed. |
I agree with Eric's comment about why have shebang lines at all for files in the standard library. There isn't any use case or recommendation for ever putting /path/to/lib/pythonx.x or its subdirectories directly on a shell search path is there? WRT the three files found in the Mac directory, I think all of these should be left alone for right now. Specifically: Mac/BuildScript/build-installer.py Mac/Tools/fixapplepython23.py: Mac/Tools/bundlebuilder.py: #! /usr/bin/env python |
Attached patch fixes shebangs to use python3 in py3k. There are a lot of examples that use a bare “python”; changing all of those would cause merging pains. |
Not strictly related to this issue, but do we want to recommend |
Good call. +1 on removing them. |
I’ve changed my mind. Given the python/python2/python3 drama with distributions, I now think that we should use “python3” in the 3.x docs. Merging is not hard. |
This 3.2 patch updates UNIX rights and shebangs in Tools/scripts. I also edited mailerdaemon, which used a string exception. |
New changeset 65d5ecefd50d by Éric Araujo in branch '3.2': New changeset 5467abaaf5eb by Éric Araujo in branch 'default': |
New changeset 7fb0abf928e0 by Éric Araujo in branch '2.7': |
Éric, what's the status of this? |
The patches I’ve discussed and committed were actually peripheral. The original bug reported here is that shebangs shouldn’t use “/usr/bin/env python” with an altinstall installation, as in that case you’re not creating a python (or python3) binary but a pythonx.y, so the shebangs should refer to that exact x.y versions. The few scripts from Tools/scripts (idle, pydoc, 2to3, python-config) are installed with an x.y suffix and hard-code the Python version and location at build time, by using distutils. (That’s why Nick reports the only matches for “3.2” found by grep are in the build/scripts directory.) The stdlib modules do use “/usr/bin/env python[3]”. I see various ways to handle that: b) Further complicate the build/install machinery to update shebangs in altinstall mode. c) Remove useless shebangs and execute bit in the stdlib. My preference is to do c) for 3.3 and nothing for the stable versions. (About wrongly using python in Python 3 docs: I’ll open another bug for that). |
+1 to "c". |
+1 to 'c', but it should come with an update to PEP-8 to say "don't do that". |
Patch to PEP-8 attached. |
Hmm, my initial reaction is that that specific wording is stronger than I had in mind - there's nothing really wrong with having a shebang line and execute bit set on a top level module and symlinking it from /usr/bin. The problem is that we're doing those things for modules that we *don't* install as binaries, and that's silly (particularly when the shebang lines are wrong on altinstall). However, that concern can specifically by addressed by moving the new section down to be a subheading in the "Rules that apply only to the standard library" section. I'd also mention the justification that this is due to such shebang lines creating a maintenance problem for handling parallel installations of different Python versions. Also, with PEP-397 a viable candidate, we may as well make the wording OS neutral. Something like: ======================= Standard library modules (including test modules) should not be Including shebang lines in standard library modules is an issue, as If a module provides command-line functionality, it can be used with Any installed scripts should use a shebang line of the form::
where The PEP-8 update should be run by the wider audience of python-dev before it gets committed, though. |
Okay. (On that topic, http://lists.debian.org/debian-python/2011/11/msg00058.html may interest you.)
Yep. Attached patch removes them for 3.3.
I’d rather just say that it’s unneeded. With all due respect to the original poster, I don’t think this really caused problems. I will move my addition to the stdlib-only section. I’m not sure about OS-neutrality; the executable bit is Unix-specific and I’d rather use that exact term than a vague “flagged as executable”. I’ll make the part about shebangs neutral however, it won’t be hard. About this part of your proposal:
Due to the use of distutils’ build_scripts that hard-codes one path, I’m not sure it’s time yet to make that recommendation. For packaging, I intend to launch a discussion about that behavior, which is often unhelpful. I really appreciate your taking time to review, and will submit the next revision of the patch here before going to python-dev. |
Hmm, interesting mailing list post - I hadn't thought about how the auto-initialisation of sys.path[0] aligns with the Windows vs Unix difference in PATH handling (i.e. whether or not the current directory is considered to be on PATH), with Python coming down in favour of the usually-more-convenient-but-less-secure Windows approach. We have -S to disable all site processing, -s to disable user site packages and -E to ignore PYTHONPATH and PYTHONHOME - perhaps there should be another flag to skip the auto-initialisation of sys.path[0]. I may include something along those lines in PEP-395. |
I created bpo-13475 to discuss the idea of a command line option to override sys.path[0] initialisation. |
Can I removed the shebangs in the 3.3 stdlib or do I need to go through with the PEP-8 patch on python-dev first? |
I believe this issue was superseded by #118673; feel free to comment or re-open if I'm mistaken. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: