From b5a3bf112b85ace6ff5b3a19de0c326e5ee92ba8 Mon Sep 17 00:00:00 2001 From: Jack O'Connor Date: Sun, 21 Dec 2014 14:56:22 -0800 Subject: [PATCH] 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 --- setup.py | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/setup.py b/setup.py index 5610684..2bd4c7c 100644 --- a/setup.py +++ b/setup.py @@ -1,5 +1,6 @@ import os import setuptools +import sys # Written according to the docs at # https://packaging.python.org/en/latest/distributing.html @@ -25,6 +26,17 @@ def get_all_resources_filepaths(): resources_paths.extend(relpaths) 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( name='peru', description='A tool for fetching code', @@ -40,10 +52,5 @@ setuptools.setup( 'peru=peru.main:main', ] }, - install_requires=[ - 'asyncio', # Python 3.3. - 'docopt', - 'pathlib', # Python 3.3. - 'PyYAML', - ], + install_requires=get_install_requires(), )