From 82cb182fe74cb56a21be8b27844d958c90274167 Mon Sep 17 00:00:00 2001 From: Alec Buckenheimer Date: Tue, 6 Feb 2018 09:57:16 -0500 Subject: [PATCH] added pip requirement to only install ujson and uvloop with cpython on non windows machines --- requirements-dev.txt | 4 ++-- requirements.txt | 4 ++-- setup.py | 18 ++++++------------ 3 files changed, 10 insertions(+), 16 deletions(-) diff --git a/requirements-dev.txt b/requirements-dev.txt index cf00aad4..ecadfc68 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -7,6 +7,6 @@ httptools flake8 pytest==3.3.2 tox -ujson -uvloop +ujson; sys_platform != "windows" and implementation_name == "cpython" +uvloop; sys_platform != "windows" and implementation_name == "cpython" gunicorn diff --git a/requirements.txt b/requirements.txt index e370b52f..fa18eabf 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,5 @@ aiofiles httptools -ujson -uvloop +ujson; sys_platform != "windows" and implementation_name == "cpython" +uvloop; sys_platform != "windows" and implementation_name == "cpython" websockets diff --git a/setup.py b/setup.py index 45aa7b6f..bb8fbe4f 100644 --- a/setup.py +++ b/setup.py @@ -51,8 +51,9 @@ setup_kwargs = { ], } -ujson = 'ujson>=1.35' -uvloop = 'uvloop>=0.5.3' +env_dependency = '; sys_platform != "windows" and implementation_name == "cpython"' +ujson = 'ujson>=1.35' + env_dependency +uvloop = 'uvloop>=0.5.3' + env_dependency requirements = [ 'httptools>=0.0.9', @@ -66,16 +67,9 @@ if strtobool(os.environ.get("SANIC_NO_UJSON", "no")): requirements.remove(ujson) # 'nt' means windows OS -if strtobool(os.environ.get("SANIC_NO_UVLOOP", "no")) or os.name == 'nt': +if strtobool(os.environ.get("SANIC_NO_UVLOOP", "no")): print("Installing without uvLoop") requirements.remove(uvloop) -try: - setup_kwargs['install_requires'] = requirements - setup(**setup_kwargs) -except DistutilsPlatformError as exception: - requirements.remove(ujson) - requirements.remove(uvloop) - print("Installing without uJSON or uvLoop") - setup_kwargs['install_requires'] = requirements - setup(**setup_kwargs) +setup_kwargs['install_requires'] = requirements +setup(**setup_kwargs)