Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
setuptools
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jérome Perrin
setuptools
Commits
4918afcc
Commit
4918afcc
authored
Jun 15, 2020
by
Jason R. Coombs
Committed by
GitHub
Jun 15, 2020
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2197 from pypa/feature/unified-entry-point
Unify the entry point template.
parents
1d841d78
9db4553f
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
25 deletions
+30
-25
changelog.d/2197.change.rst
changelog.d/2197.change.rst
+1
-0
setuptools/command/easy_install.py
setuptools/command/easy_install.py
+29
-25
No files found.
changelog.d/2197.change.rst
0 → 100644
View file @
4918afcc
Console script wrapper for editable installs now has a unified template and honors importlib_metadata if present for faster script execution on older Pythons.
setuptools/command/easy_install.py
View file @
4918afcc
...
...
@@ -2070,33 +2070,37 @@ class ScriptWriter:
gui apps.
"""
if
sys
.
version_info
>=
(
3
,
8
):
template
=
textwrap
.
dedent
(
r"""
# EASY-INSTALL-ENTRY-SCRIPT: %(spec)r,%(group)r,%(name)r
import re
import sys
from importlib.metadata import distribution
if __name__ == '__main__':
sys.argv[0] = re.sub(r'(-script\
.pyw?|
\.exe)?$', '', sys.argv[0])
for entry_point in distribution(%(spec)r.split('==')[0]).entry_points:
if entry_point.group == %(group)r and entry_point.name == %(name)r:
sys.exit(entry_point.load()())
"""
).
lstrip
()
# noqa: E501
else
:
template
=
textwrap
.
dedent
(
r"""
# EASY-INSTALL-ENTRY-SCRIPT: %(spec)r,%(group)r,%(name)r
__requires__ = %(spec)r
import re
import sys
try:
from importlib.metadata import distribution
except ImportError:
try:
from importlib_metadata import distribution
except ImportError:
from pkg_resources import load_entry_point
def importlib_load_entry_point(spec, group, name):
dist_name, _, _ = spec.partition('==')
matches = (
entry_point
for entry_point in distribution(dist_name).entry_points
if entry_point.group == group and entry_point.name == name
)
return next(matches).load()
globals().setdefault('load_entry_point', importlib_load_entry_point)
if __name__ == '__main__':
sys.argv[0] = re.sub(r'(-script\
.pyw?|
\.exe)?$', '', sys.argv[0])
sys.exit(
load_entry_point(%(spec)r, %(group)r, %(name)r)()
)
"""
).
lstrip
()
# noqa: E501
sys.exit(load_entry_point(%(spec)r, %(group)r, %(name)r)())
"""
).
lstrip
()
command_spec_class
=
CommandSpec
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment