summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIlya Etingof <etingof@gmail.com>2018-08-06 23:18:42 +0200
committerIlya Etingof <etingof@gmail.com>2018-08-06 23:18:42 +0200
commitbe8d2caccf94ebbe00e11c739fb28a3b70d39ddc (patch)
tree9a9c8093312173c00c90a1fec6a4bba0d19cb67f
parent98e2a3e838bf851667020b54ae8d5bdab157f5ce (diff)
downloadpysnmp-git-be8d2caccf94ebbe00e11c739fb28a3b70d39ddc.tar.gz
Improve package build and dependency tracking
-rw-r--r--CHANGES.txt2
-rw-r--r--setup.py34
2 files changed, 28 insertions, 8 deletions
diff --git a/CHANGES.txt b/CHANGES.txt
index da779c55..1aaaff57 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -2,7 +2,7 @@
Revision 4.4.6, released 2018-08-XX
-----------------------------------
-No changes so far
+- Improved package build and dependency tracking
Revision 4.4.5, released 2018-08-05
-----------------------------------
diff --git a/setup.py b/setup.py
index cfc4d89e..87e56953 100644
--- a/setup.py
+++ b/setup.py
@@ -7,6 +7,7 @@
"""
import sys
import os
+import re
classifiers = """\
Development Status :: 5 - Production/Stable
@@ -55,25 +56,44 @@ if sys.version_info[:2] < (2, 4):
print("ERROR: this package requires Python 2.4 or later!")
sys.exit(1)
+requires = [ln.strip() for ln in open('requirements.txt').readlines()]
+
try:
- from setuptools import setup
+ import setuptools
+
+ setup, Command = setuptools.setup, setuptools.Command
+
+ observed_version = [int(x) for x in setuptools.__version__.split('.')]
+ required_version = [36, 2, 0]
+
+ # NOTE(etingof): require fresh setuptools to build proper wheels
+ # See also: https://hynek.me/articles/conditional-python-dependencies/
+ if ('bdist_wheel' in sys.argv and
+ observed_version < required_version):
+ print("ERROR: your wheels won't come out round with setuptools %s! "
+ "Upgrade to %s and try again." % (
+ '.'.join([str(x) for x in observed_version]),
+ '.'.join([str(x) for x in required_version])))
+ sys.exit(1)
params = {
- 'install_requires': ['pyasn1>=0.2.3', 'pysmi', 'pycryptodomex'],
+ 'install_requires': requires,
'zip_safe': True
}
except ImportError:
- for arg in sys.argv:
- if 'egg' in arg:
- howto_install_setuptools()
- sys.exit(1)
+ if 'bdist_wheel' in sys.argv or 'bdist_egg' in sys.argv:
+ howto_install_setuptools()
+ sys.exit(1)
from distutils.core import setup
params = {}
+
if sys.version_info[:2] > (2, 4):
- params['requires'] = ['pyasn1(>=0.2.3)', 'pysmi', 'pycryptodomex']
+ params['requires'] = [
+ re.sub(r'(.*?)([<>=!~]+)(.*)', r'\g<1>\g<2>(\g<3>)', r) for r in requires
+ ]
doclines = [x.strip() for x in (__doc__ or '').split('\n') if x]