From 146aa31a13cec4c8917ee8e253ff4ffc630cb525 Mon Sep 17 00:00:00 2001 From: Matt W Date: Tue, 22 Jan 2019 15:20:35 -0800 Subject: [PATCH] Use PEP 508 URL formatting for easier Pip install (#471) Thanks to https://github.com/pypa/pip/issues/4187#issuecomment-452862842, we can finally install Kingpin easily with a simple `pip install` command. --- docs/installation.rst | 6 +++--- requirements.txt | 2 +- setup.py | 15 ++++++++++----- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/docs/installation.rst b/docs/installation.rst index 7e6942a3..4cf31710 100644 --- a/docs/installation.rst +++ b/docs/installation.rst @@ -6,7 +6,7 @@ The simplest installation method is via .. code-block:: bash - $ pip install --process-dependency-links kingpin + $ pip install kingpin Note, we *strongly* recommend running the code inside a Python virtual environment. All of our examples below will show how to do this. @@ -28,7 +28,7 @@ Github Checkout/Install Receiving objects: 100% (1824/1824), 283.35 KiB, done. Resolving deltas: 100% (1330/1330), done. (.venv)$ cd kingpin/ - (.venv)$ python setup.py install + (.venv)$ pip install . zip_safe flag not set; analyzing archive contents... ... @@ -42,7 +42,7 @@ Direct PIP Install Installing setuptools, pip...done. $ source .venv/bin/activate (.venv) $ git clone https://github.com/Nextdoor/kingpin - (.venv)$ pip install --process-dependency-links git+https://github.com/Nextdoor/kingpin.git + (.venv)$ pip install git+https://github.com/Nextdoor/kingpin.git Downloading/unpacking git+https://github.com/Nextdoor/kingpin.git Cloning https://github.com/Nextdoor/kingpin.git (to master) to /var/folders/j6/qyd2dp6n3f156h6xknndt35m00010b/T/pip-H9LwNt-build ... diff --git a/requirements.txt b/requirements.txt index 76651aa9..475d945b 100644 --- a/requirements.txt +++ b/requirements.txt @@ -30,7 +30,7 @@ retrying # # NOTE: Version specified in the setup.py file # NOTE: mock is used inside the rightscale actor -python-rightscale>=0.1.7 +python-rightscale @ https://github.com/diranged/python-rightscale-1/tarball/nextdoor#egg=python-rightscale-0.1.7 mock==1.0.1 # kingpin.actors.aws diff --git a/setup.py b/setup.py index 52e4a133..333f26be 100644 --- a/setup.py +++ b/setup.py @@ -37,6 +37,14 @@ def maybe_rm(path): os.remove(path) +def read_requirements(requirements): + """Parse requirements from requirements.txt.""" + reqs_path = requirements + with open(reqs_path, 'r') as f: + requirements = [line.rstrip() for line in f] + return requirements + + class Pep8Command(Command): description = 'Pep8 Lint Checks' user_options = [] @@ -161,12 +169,9 @@ def run(self): keywords='apache', packages=find_packages(), test_suite='nose.collector', - tests_require=open('%s/requirements.test.txt' % DIR).readlines(), + tests_require=read_requirements('%s/requirements.test.txt' % DIR), setup_requires=[], - install_requires=open('%s/requirements.txt' % DIR).readlines(), - dependency_links=[ - 'https://github.com/diranged/python-rightscale-1/tarball/nextdoor#egg=python-rightscale-0.1.7' - ], + install_requires=read_requirements('%s/requirements.txt' % DIR), entry_points={ 'console_scripts': [ 'kingpin = kingpin.bin.deploy:begin'