Skip to content

Commit b2a11b2

Browse files
committed
🚑 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-dev. And avoids newer arrow desupported on Python 3.4. Fixes #274
1 parent 0d81242 commit b2a11b2

File tree

8 files changed

+84
-16
lines changed

8 files changed

+84
-16
lines changed

.moban.cd/moban.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,10 @@ keywords:
1818
- jinja2
1919
- moban
2020
dependencies:
21-
- ruamel.yaml>=0.15.5
21+
- ruamel.yaml>=0.15.5,<=0.15.94;python_version == '3.4'
22+
- ruamel.yaml>=0.15.42;python_version == '3.7'
23+
- ruamel.yaml>=0.15.97;python_version == '3.8'
24+
- ruamel.yaml>=0.15.5;python_version != '3.4' and python_version < '3.7'
2225
- jinja2>=2.7.1
2326
- lml>=0.0.9
2427
- appdirs>=1.2.0
@@ -28,3 +31,5 @@ dependencies:
2831
description: Yet another jinja2 cli command for static text generation
2932
scm_host: github.com
3033
lint_command: make lint install_test format install update
34+
setup_use_markers: true
35+
setup_use_markers_fix: true

.moban.d/travis.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
{% extends 'travis.yml.jj2' %}
22

33
{%block extra_matrix %}
4-
matrix:
5-
include:
6-
- python: 2.7
7-
env: MINREQ=1
4+
env:
5+
- MINREQ=0
6+
- MINREQ=1
87
{%endblock%}
98

109
{%block custom_python_versions%}
@@ -14,5 +13,6 @@ python:
1413
- 3.7
1514
- 3.6
1615
- 3.5
16+
- 3.4
1717
- 2.7
1818
{%endblock%}

.travis.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ python:
1010
- 3.7
1111
- 3.6
1212
- 3.5
13+
- 3.4
1314
- 2.7
14-
matrix:
15-
include:
16-
- python: 2.7
17-
env: MINREQ=1
15+
env:
16+
- MINREQ=0
17+
- MINREQ=1
1818

1919
stages:
2020
- test

min_requirements.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
ruamel.yaml==0.15.5
1+
ruamel.yaml==0.15.5,<=0.15.94;python_version == '3.4'
2+
ruamel.yaml==0.15.42;python_version == '3.7'
3+
ruamel.yaml==0.15.97;python_version == '3.8'
4+
ruamel.yaml==0.15.5;python_version != '3.4' and python_version < '3.7'
25
jinja2==2.7.1
36
lml==0.0.9
47
appdirs==1.2.0

mobanfile

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
requires:
2-
- pypi-mobans-pkg
1+
#requires:
2+
# - type: git
3+
# url: https://github.com/jayvdb/pypi-mobans
4+
# branch: setup-env-markers
35
configuration:
46
template_dir:
5-
- "setupmobans:templates"
7+
- "../pypi-mobans/templates"
68
- ".moban.d"
79
configuration: moban.yml
810
targets:

requirements.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
ruamel.yaml>=0.15.5
1+
ruamel.yaml>=0.15.5,<=0.15.94;python_version == '3.4'
2+
ruamel.yaml>=0.15.42;python_version == '3.7'
3+
ruamel.yaml>=0.15.97;python_version == '3.8'
4+
ruamel.yaml>=0.15.5;python_version != '3.4' and python_version < '3.7'
25
jinja2>=2.7.1
36
lml>=0.0.9
47
appdirs>=1.2.0

setup.py

Lines changed: 54 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#!/usr/bin/env python3
2-
32
# Template by pypi-mobans
43
import codecs
54
import locale
@@ -9,6 +8,15 @@
98
from shutil import rmtree
109

1110
from setuptools import Command, find_packages, setup
11+
from setuptools import __version__ as setuptools_version
12+
from pkg_resources import parse_version
13+
14+
import pkg_resources
15+
16+
try:
17+
import _markerlib.markers
18+
except ImportError:
19+
_markerlib = None
1220

1321
PY2 = sys.version_info[0] == 2
1422
PY26 = PY2 and sys.version_info[1] < 7
@@ -67,7 +75,6 @@
6775
]
6876

6977
INSTALL_REQUIRES = [
70-
"ruamel.yaml>=0.15.5",
7178
"jinja2>=2.7.1",
7279
"lml>=0.0.9",
7380
"appdirs>=1.2.0",
@@ -80,6 +87,10 @@
8087

8188
PACKAGES = find_packages(exclude=["ez_setup", "examples", "tests"])
8289
EXTRAS_REQUIRE = {
90+
":python_version == '3.4'": ["ruamel.yaml>=0.15.5,<=0.15.94"],
91+
":python_version == '3.7'": ["ruamel.yaml>=0.15.42"],
92+
":python_version == '3.8'": ["ruamel.yaml>=0.15.97"],
93+
":python_version != '3.4' and python_version < '3.7'": ["ruamel.yaml>=0.15.5"],
8394
}
8495
# You do not need to read beyond this line
8596
PUBLISH_COMMAND = "{0} setup.py sdist bdist_wheel upload -r pypi".format(sys.executable)
@@ -191,6 +202,47 @@ def filter_out_test_code(file_handle):
191202
yield line
192203

193204

205+
# _markerlib.default_environment() obtains its data from _VARS
206+
# and wraps it in another dict, but _markerlib_evaluate writes
207+
# to the dict while it is iterating the keys, causing an error
208+
# on Python 3 only.
209+
# Replace _markerlib.default_environment to return a custom dict
210+
# that has all the necessary markers, and ignores any writes.
211+
212+
class Python3MarkerDict(dict):
213+
214+
def __setitem__(self, key, value):
215+
pass
216+
217+
def pop(self, i=-1):
218+
return self[i]
219+
220+
221+
if _markerlib and sys.version_info[0] == 3:
222+
env = _markerlib.markers._VARS
223+
for key in list(env.keys()):
224+
new_key = key.replace(".", "_")
225+
if new_key != key:
226+
env[new_key] = env[key]
227+
228+
_markerlib.markers._VARS = Python3MarkerDict(env)
229+
230+
def default_environment():
231+
return _markerlib.markers._VARS
232+
233+
_markerlib.default_environment = default_environment
234+
235+
# Avoid the very buggy pkg_resources.parser, which does not consistently
236+
# recognise the markers needed by this setup.py
237+
# Change this to setuptools 20.10.0 to support all markers.
238+
if pkg_resources:
239+
if parse_version(setuptools_version) < parse_version("18.5"):
240+
MarkerEvaluation = pkg_resources.MarkerEvaluation
241+
242+
del pkg_resources.parser
243+
pkg_resources.evaluate_marker = MarkerEvaluation._markerlib_evaluate
244+
MarkerEvaluation.evaluate_marker = MarkerEvaluation._markerlib_evaluate
245+
194246
if __name__ == "__main__":
195247
setup(
196248
test_suite="tests",

tests/requirements.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,7 @@ black;python_version>="3.6"
77
isort;python_version>="3.6"
88
moban-handlebars
99
pypi-mobans-pkg
10+
# arrow 0.14.0 doesnt support Python 3.4
11+
arrow<0.14.0;python_version=="3.4"
12+
arrow;python_version!="3.4"
1013
jinja2_time

0 commit comments

Comments
 (0)