Am 05.12.2016 um 15:13 schrieb Piotr Ożarowski: > [Malte Forkel, 2016-12-05] >> Why do you recommend putting the requirements into Build-Depends? Most >> of those packages are currently not available on the build system (I'm >> not pbuilder for this). > > because you most probably need it for tests anyway and if tests work > with version >= A, you don't need to translate requirements.txt with > ">A.devRELEASED_TODAY_OR_TOMORROW+post7" > > if they're not packaged, you should start with the ones without > dependencies, even in your local repository.
It is just too easy to disable the tests with pybuild :-) >> How do you think about an additional option for pybuild that would tell >> it to translate all version specifications provided by upstream into >> Depends? > > pybuild doesn't touch versions at all, you mean dh_python3 > See https://anonscm.debian.org/cgit/dh-python/dh-python.git/tree/README.rst > (pybuild is an implementation of dh_auto_foo) > > dh_python3 doesn't have such option, but I guess I can add optional > --assume-upstream-versions-match-debians-and-are-sane (after finding a > better name for it) Right. Sometimes coming up with an appropriate name seems to be more difficult than implementing the functionality in the first place. I made the following changes to pydist.py to include all upstream version information with a minimal debian/py3dist-overrides that only adds missing mappings. Besides implementing a fictional option '--accept-upstream-versions', the changes allow for a version interval to be specified and support the operator '==' (and translate the deprecated operators '<' and '>'). --- pydist.py.orig 2016-08-18 00:27:52.000000000 +0200 +++ pydist.py 2016-12-06 09:19:59.092155732 +0100 @@ -54,9 +54,22 @@ REQUIRES_RE = re.compile(r''' (?P<operator><=?|>=?|==|!=) \s* (?P<version>(\w|[-.])+) + (?: # optional interval minimum/maximum version + \s* + , + \s* + (?P<operator2><=?|>=?|==|!=) + \s* + (?P<version2>(\w|[-.])+) + )? )? \)? # optional closing parenthesis ''', re.VERBOSE) +DEB_VERS_OPS = { + '==': '=', + '<': '<<', + '>': '>>', +} def validate(fpath): @@ -150,9 +163,23 @@ def guess_dependency(impl, req, version= # Debian dependency return item['dependency'] if req_d['version'] and (item['standard'] or item['rules']) and\ - req_d['operator'] not in (None, '==', '!='): + req_d['operator'] not in (None, '!='): + o = _translate_op(req_d['operator']) v = _translate(req_d['version'], item['rules'], item['standard']) - return "%s (%s %s)" % (item['dependency'], req_d['operator'], v) + d = "%s (%s %s)" % (item['dependency'], o, v) + if req_d['version2'] and req_d['operator2'] not in (None,'!='): + o2 = _translate_op(req_d['operator2']) + v2 = _translate(req_d['version2'], item['rules'], item['standard']) + d += ", %s (%s %s)" % (item['dependency'], o2, v2) + return d + elif 'check_accept-upstream-versions_here' and req_d['version'] and \ + req_d['operator'] not in (None,'!='): + o = _translate_op(req_d['operator']) + d = "%s (%s %s)" % (item['dependency'], o, req_d['version']) + if req_d['version2'] and req_d['operator2'] not in (None,'!='): + o2 = _translate_op(req_d['operator2']) + d += ", %s (%s %s)" % (item['dependency'], o2, req_d['version2']) + return d else: if item['dependency'] in bdep: if None in bdep[item['dependency']] and bdep[item['dependency']][None]: @@ -307,3 +334,16 @@ def _translate(version, rules, standard) if standard == 'PEP386': version = PRE_VER_RE.sub(r'~\g<1>', version) return version + + +def _translate_op(operator): + """Translate Python version operator into Debian one. + + >>> _translate_op('==') + '=' + >>> _translate_op('<') + '<<' + >>> _translate_op('<=') + '<=' + """ + return DEB_VERS_OPS.get(operator, operator)