use entry_points instead of a pre-written script

Summary:
This was the recommendation of
https://packaging.python.org/en/latest/distributing.html, but I unwisely
ignored it back when I wrote our setup.py. It turns out that getting a
launcher script to work properly on Windows is tricky. The
`entry_points` field generates a platform-appropriate launcher script at
install time, so we get Windows for free.

Previously our launcher script checked the version of Python and printed
a helpful error if it was too low. Because our main.py has `yield from`
syntax in it, printing such an error message isn't possible; we'll crash
with a syntax error first. We could create another file within the
modile (or maybe an __init__.py) to support this, but for now I'm just
dropping the feature.

Test Plan:
Manually played with peru.sh to make sure it still works. Ran
`pip install .` to check that the generated script works. Also tested
that on my Windows VM, and it works great. (It generates an exe file, in
fact.)

Reviewers: sean

Differential Revision: https://phabricator.buildinspace.com/D135
This commit is contained in:
Jack O'Connor 2014-11-26 20:38:26 -05:00
parent 1c6d7c1a55
commit d3d06a0b71
3 changed files with 6 additions and 13 deletions

View File

@ -1,11 +0,0 @@
#! /usr/bin/env python3
import sys
if sys.version_info.major < 3 or sys.version_info.minor < 3:
print("Peru requires Python 3.3 or newer.")
sys.exit(1)
from peru import main
main.main()

View File

@ -27,4 +27,4 @@ repo_root=$(dirname $(realpath $BASH_SOURCE))
source "$repo_root/scripts/env.sh"
"$repo_root/bin/peru" "$@"
python3 -c "import peru.main; peru.main.main()" "$@"

View File

@ -23,7 +23,11 @@ setuptools.setup(
license='MIT',
packages=['peru'],
package_data={'peru': resources_paths},
scripts=['bin/peru'],
entry_points={
'console_scripts': [
'peru=peru.main:main',
]
},
install_requires=[
'docopt',
'PyYAML',