have setup.py inspect the python version to determine dependencies

Summary:
Our Arch package is broken because it doesn't install asyncio and
pathlib. These shouldn't *need* to be installed, because Arch is running
Python 3.4, but the executable script that setup.py generates is getting
confused. It seems like the right thing to do is to make sure these
extra dependencies never make it into our `install_requires` list in
Python 3.4. I *think* the fact that our setup.py ends up in the source
distribution means that `pip install peru` will still do the right thing
for Python 3.3.

Test Plan: Tested `pip install .` in a python3.3 virtualenv.

Reviewers: sean

Reviewed By: sean

Differential Revision: https://phabricator.buildinspace.com/D151
This commit is contained in:
Jack O'Connor 2014-12-21 14:56:22 -08:00
parent 3f78a3e467
commit b5a3bf112b
1 changed files with 13 additions and 6 deletions

View File

@ -1,5 +1,6 @@
import os import os
import setuptools import setuptools
import sys
# Written according to the docs at # Written according to the docs at
# https://packaging.python.org/en/latest/distributing.html # https://packaging.python.org/en/latest/distributing.html
@ -25,6 +26,17 @@ def get_all_resources_filepaths():
resources_paths.extend(relpaths) resources_paths.extend(relpaths)
return resources_paths return resources_paths
def get_install_requires():
dependencies = ['docopt', 'PyYAML']
# Python 3.3 needs extra libs that aren't installed by default.
if sys.version_info < (3, 3):
raise RuntimeError('The minimum supported Python version is 3.3.')
elif (3, 3) <= sys.version_info < (3, 4):
dependencies.extend(['asyncio', 'pathlib'])
return dependencies
setuptools.setup( setuptools.setup(
name='peru', name='peru',
description='A tool for fetching code', description='A tool for fetching code',
@ -40,10 +52,5 @@ setuptools.setup(
'peru=peru.main:main', 'peru=peru.main:main',
] ]
}, },
install_requires=[ install_requires=get_install_requires(),
'asyncio', # Python 3.3.
'docopt',
'pathlib', # Python 3.3.
'PyYAML',
],
) )