classification
Title: Option --executable for entry_points
Type: behavior Stage:
Components: Distutils Versions: Python 3.7, Python 3.6, Python 3.5, Python 2.7
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: Michal Cyprian, cstratak, dstufft, eric.araujo
Priority: normal Keywords:

Created on 2017-02-01 10:43 by Michal Cyprian, last changed 2018-07-27 13:12 by berker.peksag.

Messages (3)
msg286612 - (view) Author: Michal Cyprian (Michal Cyprian) Date: 2017-02-01 10:43
1. python3 setup.py build --executable="/usr/bin/binary"
2. python3 setup.py install -O1 --skip-build

These two commands are typically used to build and install Python packages from sources. Let's assume there is a setup.py script of package foo, containing a script foo. The --executable option of build command (1) should set the shebang of the script foo to #!/usr/bin/binary. The problem is that this option doesn't work for scripts listed in setup.py as entry_points, which is the most common way of handling scripts these days.

The idea of the original design was probably to pass the value of --executable to the build_scripts command and set shebang there. However, this command is not executed if the package contains only entry_points.

The scripts listed as entry_points are processed during execution of the install command (2) (specifically, in the easy_install command), which is completely isolated from the build command (1) and doesn't have access to the value specified in the --executable option.

The only reasonable solution that came to my mind was to add the --executable option to the install command as well, pass it to the easy_install command and make the ScriptWriter class use this value.

I prepared a patch that fixes this issue in setuptools [1]. To make it work, a small patch [2] will have to be applied to distutils as well.
Would this or something similar be acceptable for distutils?

I've already sent this proposal to pypa-dev mailing list, they replied that patch will be useful. The patch [2] needs to go to distutils first, to make patch for setuptools work.


[1] https://github.com/mcyprian/python-setuptools/blob/system-python/add-executable-option.patch
[2] https://github.com/mcyprian/python-setuptools/blob/system-python/add-executable-option.patch
msg286921 - (view) Author: Berker Peksag (berker.peksag) * (Python committer) Date: 2017-02-04 07:14
Thanks for the report, Michal. Note that both [1] and [2] point to the same patch. Perhaps you meant to paste a link to a separate patch for distutils?

(I removed 3.3 and 3.4 from the versions field since they are in security-fix-only mode now. I don't know whether this can be applied as a bugfix or not without reading the pypa-dev thread and the patch for distutils so I left rest of it selected.)
msg286931 - (view) Author: Michal Cyprian (Michal Cyprian) Date: 2017-02-04 08:45
Yes, both references in my previous message point to the patch for setuptools, sorry for that. Here [3] is the patch that I prepared for distutils. I marked all the versions, because this functionality is missing in all of them. In my opinion it will be enough to apply this patch to the latest Python3 and Python2 version.

pypa-dev thread is here [4]. The response that I've got is not publicly visible. I am not sure why it was sent directly to my address. I will ask them to make it public. In short this PR will be helpful for setuptools and they asked me to check also how can distlib and pip support this use case.

[3] https://github.com/mcyprian/python3/commit/9f843468a0185516520bb1a70c0de18e7038c0e8#diff-31675636be8fb69017233f887ec14006R1

[4] https://groups.google.com/forum/#!topic/pypa-dev/qP8vcZlEfw8
History
Date User Action Args
2018-07-27 13:12:25berker.peksagsetnosy: - berker.peksag
2017-06-28 13:53:33cstrataksetnosy: + cstratak
2017-02-04 08:45:51Michal Cypriansetmessages: + msg286931
2017-02-04 07:14:22berker.peksagsetnosy: + berker.peksag

messages: + msg286921
versions: - Python 3.3, Python 3.4
2017-02-01 10:43:53Michal Cypriancreate