Skip to content

Commit

Permalink
🚑 choose version of ruamel.yaml
Browse files Browse the repository at this point in the history
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 #274
  • Loading branch information
jayvdb committed Jul 13, 2019
1 parent 7dc6379 commit 5e895b6
Show file tree
Hide file tree
Showing 8 changed files with 87 additions and 14 deletions.
7 changes: 6 additions & 1 deletion .moban.cd/moban.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
9 changes: 5 additions & 4 deletions .moban.d/travis.yml
Original file line number Diff line number Diff line change
@@ -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%}
Expand All @@ -13,5 +12,7 @@ python:
- 3.7
- 3.6
- 3.5
- 3.4
- 2.7
- 3.8-dev
{%endblock%}
9 changes: 5 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion min_requirements.txt
Original file line number Diff line number Diff line change
@@ -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
Expand Down
7 changes: 5 additions & 2 deletions mobanfile
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
5 changes: 4 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -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
Expand Down
56 changes: 55 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -67,7 +76,6 @@
]

INSTALL_REQUIRES = [
"ruamel.yaml>=0.15.5",
"jinja2>=2.7.1",
"lml>=0.0.9",
"appdirs>=1.2.0",
Expand All @@ -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)
Expand Down Expand Up @@ -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",
Expand Down
3 changes: 3 additions & 0 deletions tests/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 5e895b6

Please sign in to comment.