Skip to content
This repository was archived by the owner on Sep 12, 2018. It is now read-only.

Commit c2459a9

Browse files
author
Olivier Gambier
committed
Introduce loose deps
Same as in core, introduce DEPS=loose, which allows for loose dependencies. Docker-DCO-1.1-Signed-off-by: Olivier Gambier <[email protected]> (github: dmp42)
1 parent 4d85654 commit c2459a9

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

setup.py

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
except ImportError:
77
import distutils.core as setuptools
88

9+
import os
10+
import re
911
import sys
1012

1113
ver = sys.version_info
@@ -17,14 +19,27 @@
1719
requirements_txt = open('./requirements/main.txt')
1820
requirements = [line for line in requirements_txt]
1921

20-
if ver[0] == 2:
22+
if ver < (3, 0):
2123
# Python 2 requires lzma backport
2224
requirements.insert(0, 'backports.lzma>=0.0.2')
23-
if ver[1] <= 6:
25+
if ver < (2, 7):
2426
# Python 2.6 requires additional libraries
2527
requirements.insert(0, 'argparse>=1.2.1')
2628
requirements.insert(0, 'importlib>=1.0.3')
2729

30+
# Using this will relax dependencies to semver major matching
31+
if 'DEPS' in os.environ and os.environ['DEPS'].lower() == 'loose':
32+
loose = []
33+
for item in requirements:
34+
d = re.match(r'([^=]+)==([0-9]+)[.]([0-9]+)[.]([0-9]+)', item)
35+
if d:
36+
d = list(d.groups())
37+
name = d.pop(0)
38+
version = d.pop(0)
39+
item = '%s>=%s,<%s' % (name, int(version), int(version) + 1)
40+
loose.insert(0, item)
41+
requirements = loose
42+
2843
# Require core (the reason this is out of req.txt is to ease tox)
2944
requirements.insert(0, 'docker-registry-core>=2,<3')
3045

0 commit comments

Comments
 (0)