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
01121d05
Commit
01121d05
authored
Jun 14, 2020
by
Ofek Lev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Decrease start-up time of editable-installed entry points on newer versions of Python
parent
74de4e98
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
62 additions
and
26 deletions
+62
-26
changelog.d/2194.change.rst
changelog.d/2194.change.rst
+1
-0
setuptools/command/easy_install.py
setuptools/command/easy_install.py
+30
-13
setuptools/tests/test_easy_install.py
setuptools/tests/test_easy_install.py
+31
-13
No files found.
changelog.d/2194.change.rst
0 → 100644
View file @
01121d05
Editable-installed entry points now load significantly faster on Python versions 3.8+.
setuptools/command/easy_install.py
View file @
01121d05
...
...
@@ -2070,19 +2070,36 @@ class ScriptWriter:
gui apps.
"""
template
=
textwrap
.
dedent
(
r"""
# EASY-INSTALL-ENTRY-SCRIPT: %(spec)r,%(group)r,%(name)r
__requires__ = %(spec)r
import re
import sys
from pkg_resources import 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
()
try
:
from
importlib.metadata
import
distribution
# noqa: F401
template
=
textwrap
.
dedent
(
r"""
# EASY-INSTALL-ENTRY-SCRIPT: %(spec)r,%(group)r,%(name)r
__requires__ = %(spec)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).entry_points:
if entry_point.group == %(group)r and entry_point.name == %(name)r:
sys.exit(entry_point.load()())
"""
).
lstrip
()
# noqa: E501
except
ImportError
:
template
=
textwrap
.
dedent
(
r"""
# EASY-INSTALL-ENTRY-SCRIPT: %(spec)r,%(group)r,%(name)r
__requires__ = %(spec)r
import re
import sys
from pkg_resources import 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
command_spec_class
=
CommandSpec
...
...
setuptools/tests/test_easy_install.py
View file @
01121d05
...
...
@@ -71,19 +71,37 @@ class TestEasyInstallTest:
def
test_get_script_args
(
self
):
header
=
ei
.
CommandSpec
.
best
().
from_environment
().
as_header
()
expected
=
header
+
DALS
(
r"""
# EASY-INSTALL-ENTRY-SCRIPT: 'spec','console_scripts','name'
__requires__ = 'spec'
import re
import sys
from pkg_resources import load_entry_point
if __name__ == '__main__':
sys.argv[0] = re.sub(r'(-script\
.pyw?|
\.exe)?$', '', sys.argv[0])
sys.exit(
load_entry_point('spec', 'console_scripts', 'name')()
)
"""
)
# noqa: E501
try
:
from
importlib.metadata
import
distribution
# noqa: F401
expected
=
header
+
DALS
(
r"""
# EASY-INSTALL-ENTRY-SCRIPT: 'spec','console_scripts','name'
__requires__ = 'spec'
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').entry_points:
if entry_point.group == 'console_scripts' and entry_point.name == 'name':
sys.exit(entry_point.load()())
"""
)
# noqa: E501
except
ImportError
:
expected
=
header
+
DALS
(
r"""
# EASY-INSTALL-ENTRY-SCRIPT: 'spec','console_scripts','name'
__requires__ = 'spec'
import re
import sys
from pkg_resources import load_entry_point
if __name__ == '__main__':
sys.argv[0] = re.sub(r'(-script\
.pyw?|
\.exe)?$', '', sys.argv[0])
sys.exit(
load_entry_point('spec', 'console_scripts', 'name')()
)
"""
)
# noqa: E501
dist
=
FakeDist
()
args
=
next
(
ei
.
ScriptWriter
.
get_args
(
dist
))
...
...
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