From 5e895b6a9e3a7b06c3cbd3ea651b197990366c33 Mon Sep 17 00:00:00 2001 From: John Vandenberg Date: Mon, 8 Jul 2019 10:21:33 +0700 Subject: [PATCH] :ambulance: choose version of ruamel.yaml Re-adds Python 3.4 support, broken by ruamel.yaml desupporting it in version 0.15.94. Also adds minimum version for ruamel-yaml on Python 3.7 and 3.8, and re-adds Python 3.8-dev to the Travis matrix recently removed in ec48af4 due to temporary build failures. And avoids newer arrow desupported on Python 3.4. Fixes https://github.com/moremoban/moban/issues/274 --- .moban.cd/moban.yml | 7 +++++- .moban.d/travis.yml | 9 ++++--- .travis.yml | 9 ++++--- min_requirements.txt | 5 +++- mobanfile | 7 ++++-- requirements.txt | 5 +++- setup.py | 56 +++++++++++++++++++++++++++++++++++++++++- tests/requirements.txt | 3 +++ 8 files changed, 87 insertions(+), 14 deletions(-) diff --git a/.moban.cd/moban.yml b/.moban.cd/moban.yml index 0ff2e3d6..6d06c031 100644 --- a/.moban.cd/moban.yml +++ b/.moban.cd/moban.yml @@ -18,7 +18,10 @@ keywords: - jinja2 - moban dependencies: - - ruamel.yaml>=0.15.5 + - ruamel.yaml>=0.15.5,<=0.15.94;python_version == '3.4' + - ruamel.yaml>=0.15.42;python_version == '3.7' + - ruamel.yaml>=0.15.5;python_version != '3.4' and python_version < '3.7' + - ruamel.yaml>=0.15.98;python_version == '3.8' - jinja2>=2.7.1 - lml>=0.0.9 - appdirs>=1.2.0 @@ -28,3 +31,5 @@ dependencies: description: Yet another jinja2 cli command for static text generation scm_host: github.com lint_command: make lint install_test format install update +setup_use_markers: true +setup_use_markers_fix: true diff --git a/.moban.d/travis.yml b/.moban.d/travis.yml index 01e298ba..91ba2fd4 100644 --- a/.moban.d/travis.yml +++ b/.moban.d/travis.yml @@ -1,10 +1,9 @@ {% extends 'travis.yml.jj2' %} {%block extra_matrix %} -matrix: - include: - - python: 2.7 - env: MINREQ=1 +env: + - MINREQ=0 + - MINREQ=1 {%endblock%} {%block custom_python_versions%} @@ -13,5 +12,7 @@ python: - 3.7 - 3.6 - 3.5 + - 3.4 - 2.7 + - 3.8-dev {%endblock%} diff --git a/.travis.yml b/.travis.yml index e5734eba..4e5a12ef 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,11 +9,12 @@ python: - 3.7 - 3.6 - 3.5 + - 3.4 - 2.7 -matrix: - include: - - python: 2.7 - env: MINREQ=1 + - 3.8-dev +env: + - MINREQ=0 + - MINREQ=1 stages: - test diff --git a/min_requirements.txt b/min_requirements.txt index 4e76ef0a..faee8d8f 100644 --- a/min_requirements.txt +++ b/min_requirements.txt @@ -1,4 +1,7 @@ -ruamel.yaml==0.15.5 +ruamel.yaml==0.15.5,<=0.15.94;python_version == '3.4' +ruamel.yaml==0.15.42;python_version == '3.7' +ruamel.yaml==0.15.5;python_version != '3.4' and python_version < '3.7' +ruamel.yaml==0.15.98;python_version == '3.8' jinja2==2.7.1 lml==0.0.9 appdirs==1.2.0 diff --git a/mobanfile b/mobanfile index 2360459b..a20f25a1 100644 --- a/mobanfile +++ b/mobanfile @@ -1,8 +1,11 @@ requires: - - pypi-mobans-pkg + - type: git + url: https://github.com/moremoban/pypi-mobans + submodule: true + branch: dev configuration: template_dir: - - "setupmobans:templates" + - "pypi-mobans:templates" - ".moban.d" configuration: moban.yml targets: diff --git a/requirements.txt b/requirements.txt index b835604e..2305c66a 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,7 @@ -ruamel.yaml>=0.15.5 +ruamel.yaml>=0.15.5,<=0.15.94;python_version == '3.4' +ruamel.yaml>=0.15.42;python_version == '3.7' +ruamel.yaml>=0.15.5;python_version != '3.4' and python_version < '3.7' +ruamel.yaml>=0.15.98;python_version == '3.8' jinja2>=2.7.1 lml>=0.0.9 appdirs>=1.2.0 diff --git a/setup.py b/setup.py index d9b773c2..d6525362 100644 --- a/setup.py +++ b/setup.py @@ -9,6 +9,15 @@ from shutil import rmtree from setuptools import Command, find_packages, setup +from setuptools import __version__ as setuptools_version +from pkg_resources import parse_version + +import pkg_resources + +try: + import _markerlib.markers +except ImportError: + _markerlib = None PY2 = sys.version_info[0] == 2 PY26 = PY2 and sys.version_info[1] < 7 @@ -67,7 +76,6 @@ ] INSTALL_REQUIRES = [ - "ruamel.yaml>=0.15.5", "jinja2>=2.7.1", "lml>=0.0.9", "appdirs>=1.2.0", @@ -80,6 +88,10 @@ PACKAGES = find_packages(exclude=["ez_setup", "examples", "tests"]) EXTRAS_REQUIRE = { + ":python_version == '3.4'": ["ruamel.yaml>=0.15.5,<=0.15.94"], + ":python_version == '3.7'": ["ruamel.yaml>=0.15.42"], + ":python_version != '3.4' and python_version < '3.7'": ["ruamel.yaml>=0.15.5"], + ":python_version == '3.8'": ["ruamel.yaml>=0.15.98"], } # You do not need to read beyond this line PUBLISH_COMMAND = "{0} setup.py sdist bdist_wheel upload -r pypi".format(sys.executable) @@ -191,6 +203,48 @@ def filter_out_test_code(file_handle): yield line +# _markerlib.default_environment() obtains its data from _VARS +# and wraps it in another dict, but _markerlib_evaluate writes +# to the dict while it is iterating the keys, causing an error +# on Python 3 only. +# Replace _markerlib.default_environment to return a custom dict +# that has all the necessary markers, and ignores any writes. + +class Python3MarkerDict(dict): + + def __setitem__(self, key, value): + pass + + def pop(self, i=-1): + return self[i] + + +if _markerlib and sys.version_info[0] == 3: + env = _markerlib.markers._VARS + for key in list(env.keys()): + new_key = key.replace(".", "_") + if new_key != key: + env[new_key] = env[key] + + _markerlib.markers._VARS = Python3MarkerDict(env) + + def default_environment(): + return _markerlib.markers._VARS + + _markerlib.default_environment = default_environment + +# Avoid the very buggy pkg_resources.parser, which does not consistently +# recognise the markers needed by this setup.py +# See https://github.com/pypa/packaging/issues/72 for details +# Change this to setuptools 20.10.0 to support all markers. +if pkg_resources: + if parse_version(setuptools_version) < parse_version("18.5"): + MarkerEvaluation = pkg_resources.MarkerEvaluation + + del pkg_resources.parser + pkg_resources.evaluate_marker = MarkerEvaluation._markerlib_evaluate + MarkerEvaluation.evaluate_marker = MarkerEvaluation._markerlib_evaluate + if __name__ == "__main__": setup( test_suite="tests", diff --git a/tests/requirements.txt b/tests/requirements.txt index 2e86b007..c27cb7fb 100644 --- a/tests/requirements.txt +++ b/tests/requirements.txt @@ -7,4 +7,7 @@ black;python_version>="3.6" isort;python_version>="3.6" moban-handlebars pypi-mobans-pkg +# arrow 0.14.0 doesnt support Python 3.4 +arrow<0.14.0;python_version=="3.4" +arrow;python_version!="3.4" jinja2_time