Skip to content

Commit 803b0f2

Browse files
committed
setup.py: go back to making an universal wheel [GH-1]
1 parent 1fdff54 commit 803b0f2

File tree

4 files changed

+41
-14
lines changed

4 files changed

+41
-14
lines changed

.travis.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,7 @@ matrix:
1818
- python: 3.6
1919
env: TOXENV=lint,docs
2020
- python: 3.6
21-
# requirements.txt installs compdb and its dependencies,
22-
# the ZSH script depends on compdb
23-
install: pip install -r requirements.txt
21+
install: python setup.py install
2422
script: ./contrib/zsh/check-all-helps
2523

2624
install: pip install tox wheel

requirements.txt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
1-
# install the 'abstract' dependencies of setup.py
2-
# -- https://caremad.io/posts/2013/07/setup-vs-requirement/
3-
-e .
1+
# Note: the use of environment marker requires pip >= 7.1.0
2+
configparser; python_version < '3.0'

setup.cfg

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[bdist_wheel]
2+
universal=1

setup.py

Lines changed: 36 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,54 @@
11
#!/usr/bin/env python
22
# -*- coding: utf-8 -*-
33

4+
import setuptools
5+
import sys
6+
47
from codecs import open
8+
from distutils.version import LooseVersion
59
from os import path
610
from setuptools import setup, find_packages
7-
import sys
811

912
local_path = path.abspath(path.dirname(__file__))
1013

14+
# find_packages()'s 'include' parameter has been introduced in setuptools 3.3.
15+
#
16+
# Ubuntu 14:04 comes with 3.3 for the system wide installation,
17+
# but when using virtualenv the setuptools version is 2.2.
18+
# The solution is to upgrade setuptools in the virtualenv.
19+
if LooseVersion(setuptools.__version__) < LooseVersion('3.3'):
20+
print("setuptools version:", str(LooseVersion(setuptools.__version__)))
21+
print("to upgrade with pip, type: pip install -U setuptools")
22+
raise AssertionError("compdb requires setuptools 3.3 higher")
23+
1124
with open(path.join(local_path, 'README.rst'), encoding='utf-8') as f:
1225
long_desc = f.read()
1326

1427
about = {}
1528
with open(path.join(local_path, "compdb", "__about__.py")) as f:
1629
exec(f.read(), about)
1730

18-
dependencies = []
31+
install_requires = []
32+
extras_require = {}
1933

20-
if sys.version_info[0] < 3:
21-
# Would be nicer in 'extra_require' with an environment marker (PEP 496),
22-
# but this requires a more recent version of setuptools
23-
# than provided by Ubuntu 14.04.
24-
dependencies.append('configparser')
34+
# Depending on the setuptools version,
35+
# fill in install_requires or extras_require.
36+
#
37+
# The ideas comes from the following article:
38+
# - https://hynek.me/articles/conditional-python-dependencies/
39+
#
40+
# This handles Ubuntu 14.04, which comes with setuptools 3.3.
41+
# But not everything is handled, a more recent version of setuptools
42+
# is still required to support bdist_wheel.
43+
if LooseVersion(setuptools.__version__) < LooseVersion('18'):
44+
if "bdist_wheel" in sys.argv:
45+
print("setuptools version:", str(LooseVersion(setuptools.__version__)))
46+
print("to upgrade with pip, type: pip install -U setuptools")
47+
raise AssertionError("setuptools >= 18 required for wheels")
48+
if sys.version_info[0] < 3:
49+
install_requires.append('configparser')
50+
else: # setuptools >= 18
51+
extras_require[":python_version<'3.0'"] = ['configparser']
2552

2653
setup(
2754
name=about['__prog__'],
@@ -55,4 +82,5 @@
5582
],
5683
},
5784
python_requires='>=2.7,!=3.0.*,!=3.1.*,!=3.2.*',
58-
install_requires=dependencies)
85+
install_requires=install_requires,
86+
extras_require=extras_require)

0 commit comments

Comments
 (0)