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

setup.py does not use build_scripts, therefore lacking shebang replacement #2891

Closed
bdbaddog opened this issue Jan 2, 2018 · 1 comment
Closed
Labels
bug Packaging Support for packaging tools in SCons

Comments

@bdbaddog
Copy link
Contributor

bdbaddog commented Jan 2, 2018

This issue was originally created at: 2013-02-06 03:55:07.
This issue was reported by: mgorny.
mgorny said at 2013-02-06 03:55:07

The build_scripts command of distutils replaces shebangs of installed scripts with the Python
version used to build the package. SCons does not use it but installs the scripts directly,
therefore having their shebangs left unfixed.

This results in a failure to 'plainly' run SCons on a system that has Python3 used by default:

$ scons
scons: *** SCons version 2.2.0 does not run under Python version 3.2.3.
Python 3.0 and later are not yet supported.

While proper shebang substitution would result in SCons being run with Python 2.7 (as the user
expects it to be).

I'd like to request either using build_scripts to fix shebangs unconditionally or providing an
option to do so.

alastairt said at 2013-04-29 09:22:21

Fix for scons.setup.py.

This bug occurs as self.scripts returns ['script/scons', 'script/sconsign',
'script/scons-time', 'script/scons.bat']
But this is not where build_scripts has put them.

If we look at
To mirror
/opt/lib/python2.7/distutils/command/build_scripts.py:copy_scripts

   for script in self.scripts:
       adjust = 0
       script = convert_path(script)
       outfile = os.path.join(self.build_dir, os.path.basename(script))

Thus the setup.py install_scripts should be using the paths as above.

N.B. self.scripts == self.distribution.scripts == self.get_inputs()

Patch to fix this issue.
+from distutils.util import convert_path

setup.py: line 299: install_scripts.run
-inputs = self.get_inputs()
+inputs = [os.path.join(self.build_dir, os.path.basename(convert_path(script)))
for script in self.get_inputs()]

@bdbaddog
Copy link
Contributor Author

bdbaddog commented Dec 9, 2019

closing in favor of #3451

@bdbaddog bdbaddog closed this as completed Dec 9, 2019
algitbot pushed a commit to alpinelinux/aports that referenced this issue May 4, 2020
Before this change:

    $ dabuild sh
    $ sudo apk add scons >/dev/null && scons --version
    env: can't execute 'python': No such file or directory

After this change:

    $ dabuild sh
    $ sudo apk add scons >/dev/null && scons --version
    SCons by Steven Knight et al.:
            script: v3.1.2.bee7caf9defd6e108fc2998a2520ddb36a967691, 2019-12-17 02:07:09, by bdeegan on octodog
            engine: v3.1.2.bee7caf9defd6e108fc2998a2520ddb36a967691, 2019-12-17 02:07:09, by bdeegan on octodog
            engine path: ['/usr/lib/scons/SCons']
    Copyright (c) 2001 - 2019 The SCons Foundation

See also SCons/scons#2891 and Fedora's
approach around line 140 of
https://apps.fedoraproject.org/packages/python3-scons/sources/spec/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Packaging Support for packaging tools in SCons
Projects
User Pain Points # 1
  
Awaiting triage
Development

No branches or pull requests

1 participant