-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
[BUG] Shebangs replaced by non working ones on install #4934
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
Reverting setuptools with The commit is c712663 |
@jaraco since you have added the commit in question: What is the planned way forward for distributions? We're currently hit by this bug on Arch Linux as well (https://gitlab.archlinux.org/archlinux/packaging/packages/python-setuptools/-/issues/4), which breaks all upcoming package builds that have an entrypoint. Downstreams can currently only work around this issue by adding custom wrapper scripts around setuptools or installer to have functioning scripts (however, this does not scale) 🤔 |
That commit mentions #4863, where Setuptools is has been asked by downstream installers (uv in particular) to provide a consistent, predictable shebang so it can be rewritten by the installer to match the target Python environment.
I believe this statement is incorrect. If you have a project where entry points are affected, please report that separately. The issue reported in this issue (and I believe affected by the indicated commit), pertains to user-provided scripts (such as declared here). For the record, rosmaster probably shouldn't be using I note also that rosmaster is using the explicitly deprecated direct call of
I'm not comfortable with this reproducer. While I respect that it causes the undesirable behavior, it's using tools (rosinstall/catkin) with which I'm unfamiliar and that may have unknown effects on any system I might use to replicate the issue. Can you come up with a reproducer that distills the problem down to something that only involves Setuptools? Don't spend too much time on it, however, if all it does is call My suspicion is that a tool like rosinstall is going to need to adapt and perform the same transformations that tools like uv and pip do when installing scripts. |
@jaraco: You want a minimal reproducer? Here: https://gist.github.com/stefanor/c6a59e920655c95406f9b221dfefb733 (I'm not sure if that's the same issue as the the ROS toolchain hits, but it's the one I described in #4952) |
@jaraco entrypoints are indeed not affected, but @stefanor I remember that |
That should only apply to wheels. not direct @jaraco, consider the following reproducer (thanks @lilydjwg — https://gitlab.archlinux.org/archlinux/packaging/packages/python-setuptools/-/issues/4#note_264683): $ cat setup.py
#!/usr/bin/python
from setuptools import setup
setup(
name = 'test package',
scripts = ['script'],
) $ cat script
#!/usr/bin/python
print('script!') $ python setup.py build
running build
running build_scripts
creating build/scripts-3.13
copying and adjusting script -> build/scripts-3.13
changing mode of build/scripts-3.13/script from 644 to 755 $ python setup.py install --root=destdir/
running install
/usr/lib/python3.13/site-packages/setuptools/_distutils/cmd.py:90: SetuptoolsDeprecationWarning: setup.py install is deprecated.
!!
********************************************************************************
Please avoid running ``setup.py`` directly.
Instead, use pypa/build, pypa/installer or other
standards-based tools.
See https://blog.ganssle.io/articles/2021/10/setup-py-deprecated.html for details.
********************************************************************************
!!
self.initialize_options()
running build
running build_scripts
running install_egg_info
running egg_info
creating test_package.egg-info
writing test_package.egg-info/PKG-INFO
writing dependency_links to test_package.egg-info/dependency_links.txt
writing top-level names to test_package.egg-info/top_level.txt
writing manifest file 'test_package.egg-info/SOURCES.txt'
[04/22/25 06:33:47] ERROR listing git files failed - pretending there aren't any git.py:26
reading manifest file 'test_package.egg-info/SOURCES.txt'
writing manifest file 'test_package.egg-info/SOURCES.txt'
Copying test_package.egg-info to destdir/usr/lib/python3.13/site-packages/test_package-0.0.0-py3.13.egg-info
running install_scripts
creating destdir/usr/bin
copying build/scripts-3.13/script -> destdir/usr/bin
changing mode of destdir/usr/bin/script to 755 $ cat destdir/usr/bin/script
#!python
print('script!') |
FWIW, I was unable to reproduce the issue for entrypoints, only for user scripts. Perhaps the two mechanisms were being confused. |
I agree, the reproducer was not good. It is indeed calling |
Just for completeness, that commit also removed/broke the "--executable" feature of build_scripts. The tests for this feature didn't catch it though: setuptools/setuptools/tests/test_install_scripts.py Lines 23 to 33 in 56962ec
|
Yes, I pointed that out in pypa/distutils#332. |
setuptools version
setuptools==78.1.0
Python version
python 3.10
OS
Ubuntu 22.04 ARM64
Additional environment information
I am building
rosmaster
It creates a package then calls
setup(...)
for the install part.Source: https://github.com/ros/ros_comm/tree/noetic-devel/tools/rosmaster
Description
The shebangs
#!/usr/bin/env python
are being replaced by#!python
making the scripts non working.This seems to be related to
setuptools/setuptools/_distutils/command/build_scripts.py
Lines 105 to 113 in 6ead555
Expected behavior
The shebangs are not modified
How to Reproduce
Output
The text was updated successfully, but these errors were encountered: