Skip to content

Commit

Permalink
Use fastentrypoints.py as workaround for slow start.
Browse files Browse the repository at this point in the history
  • Loading branch information
Fak3 committed Oct 31, 2016
1 parent d480a2a commit 15ad80b
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 0 deletions.
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ global-include *.txt
include LICENSE
include README.md
include tox.ini
include fastentrypoints.py
recursive-include doc *
42 changes: 42 additions & 0 deletions fastentrypoints.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
'''
Monkey patch setuptools to write faster console_scripts with this format:
from mymodule import entry_function
entry_function()
This is better.
'''
from setuptools.command import easy_install


@classmethod
def get_args(cls, dist, header=None):
"""
Yield write_script() argument tuples for a distribution's
console_scripts and gui_scripts entry points.
"""
template = 'import sys\nfrom {0} import {1}\nsys.exit({1}())'
if header is None:
header = cls.get_header()
spec = str(dist.as_requirement())
for type_ in 'console', 'gui':
group = type_ + '_scripts'
for name, ep in dist.get_entry_map(group).items():
cls._ensure_safe_name(name)
script_text = template.format(
ep.module_name, ep.attrs[0])
args = cls._get_script_args(type_, name, header, script_text)
for res in args:
yield res


easy_install.ScriptWriter.get_args = get_args


def main():
import shutil
import sys
dests = sys.argv[1:] if sys.argv[1:] else ['.']
print(__name__)
for dst in dests:
shutil.copy(__file__, dst)
5 changes: 5 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
from os.path import join, dirname

import dpm

# Workaround for slow entry points https://github.com/pypa/setuptools/issues/510
# Taken from https://github.com/ninjaaron/fast-entry_points
import fastentrypoints

from setuptools import setup, find_packages


Expand Down

0 comments on commit 15ad80b

Please sign in to comment.