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

Option --executable for entry_points #73597

Closed
MichalCyprian mannequin opened this issue Feb 1, 2017 · 4 comments
Closed

Option --executable for entry_points #73597

MichalCyprian mannequin opened this issue Feb 1, 2017 · 4 comments
Labels
3.7 (EOL) end of life stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@MichalCyprian
Copy link
Mannequin

MichalCyprian mannequin commented Feb 1, 2017

BPO 29411
Nosy @merwok, @dstufft, @stratakis

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:

assignee = None
closed_at = <Date 2020-10-22.21:37:41.218>
created_at = <Date 2017-02-01.10:43:53.126>
labels = ['3.7', 'type-bug', 'library']
title = 'Option --executable for entry_points'
updated_at = <Date 2020-10-22.21:37:41.217>
user = 'https://bugs.python.org/MichalCyprian'

bugs.python.org fields:

activity = <Date 2020-10-22.21:37:41.217>
actor = 'eric.araujo'
assignee = 'none'
closed = True
closed_date = <Date 2020-10-22.21:37:41.218>
closer = 'eric.araujo'
components = ['Distutils']
creation = <Date 2017-02-01.10:43:53.126>
creator = 'Michal Cyprian'
dependencies = []
files = []
hgrepos = []
issue_num = 29411
keywords = []
message_count = 4.0
messages = ['286612', '286921', '286931', '379360']
nosy_count = 4.0
nosy_names = ['eric.araujo', 'dstufft', 'cstratak', 'Michal Cyprian']
pr_nums = []
priority = 'normal'
resolution = 'third party'
stage = 'resolved'
status = 'closed'
superseder = None
type = 'behavior'
url = 'https://bugs.python.org/issue29411'
versions = ['Python 2.7', 'Python 3.5', 'Python 3.6', 'Python 3.7']

@MichalCyprian
Copy link
Mannequin Author

MichalCyprian mannequin commented Feb 1, 2017

  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

@MichalCyprian MichalCyprian mannequin added 3.7 (EOL) end of life stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error labels Feb 1, 2017
@berkerpeksag
Copy link
Member

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.)

@MichalCyprian
Copy link
Mannequin Author

MichalCyprian mannequin commented Feb 4, 2017

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] mcyprian/python3@9f84346#diff-31675636be8fb69017233f887ec14006R1

[4] https://groups.google.com/forum/#!topic/pypa-dev/qP8vcZlEfw8

@merwok
Copy link
Member

merwok commented Oct 22, 2020

Closing this; the distutils patch was never attached here, and now setuptools has its own copy of distutils so if this feature request is pursued all the changes will happen there.

@merwok merwok closed this as completed Oct 22, 2020
@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.7 (EOL) end of life stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

2 participants