Skip to content

Commit 999c3d8

Browse files
committed
Use fastentrypoints.py as workaround for slow start.
See pypa/setuptools#510 Addresses openknowledge-archive#23
1 parent d480a2a commit 999c3d8

File tree

2 files changed

+47
-0
lines changed

2 files changed

+47
-0
lines changed

fastentrypoints.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
'''
2+
Monkey patch setuptools to write faster console_scripts with this format:
3+
4+
from mymodule import entry_function
5+
entry_function()
6+
7+
This is better.
8+
'''
9+
from setuptools.command import easy_install
10+
11+
12+
@classmethod
13+
def get_args(cls, dist, header=None):
14+
"""
15+
Yield write_script() argument tuples for a distribution's
16+
console_scripts and gui_scripts entry points.
17+
"""
18+
template = 'import sys\nfrom {0} import {1}\nsys.exit({1}())'
19+
if header is None:
20+
header = cls.get_header()
21+
spec = str(dist.as_requirement())
22+
for type_ in 'console', 'gui':
23+
group = type_ + '_scripts'
24+
for name, ep in dist.get_entry_map(group).items():
25+
cls._ensure_safe_name(name)
26+
script_text = template.format(
27+
ep.module_name, ep.attrs[0])
28+
args = cls._get_script_args(type_, name, header, script_text)
29+
for res in args:
30+
yield res
31+
32+
33+
easy_install.ScriptWriter.get_args = get_args
34+
35+
36+
def main():
37+
import shutil
38+
import sys
39+
dests = sys.argv[1:] if sys.argv[1:] else ['.']
40+
print(__name__)
41+
for dst in dests:
42+
shutil.copy(__file__, dst)

setup.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@
33
from os.path import join, dirname
44

55
import dpm
6+
7+
# Workaround for slow entry points https://github.com/pypa/setuptools/issues/510
8+
# Taken from https://github.com/ninjaaron/fast-entry_points
9+
import fastentrypoints
10+
611
from setuptools import setup, find_packages
712

813

0 commit comments

Comments
 (0)