Skip to content

Commit 1a47017

Browse files
committed
Python 2.7 dedicated branch
Python 3 will be supported in master Signed-off-by: Alexey Stepanov <[email protected]>
1 parent 62caf0b commit 1a47017

File tree

4 files changed

+17
-192
lines changed

4 files changed

+17
-192
lines changed

.travis.yml

Lines changed: 9 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -3,61 +3,32 @@ language: python
33
os: linux
44
install:
55
- &upgrade_python_toolset pip install --upgrade pip setuptools wheel
6-
- &install_test_deps pip install --upgrade pytest pytest-sugar
6+
- pip install --upgrade pytest pytest-sugar
77
- &install_deps pip install -r CI_REQUIREMENTS.txt
88
- pip install --upgrade pytest-cov coveralls
99

1010
_python:
1111
- &python27
1212
name: "Python 2.7"
1313
python: 2.7
14-
- &python34
15-
name: "Python 3.4"
16-
python: 3.4
17-
- &python35
18-
name: "Python 3.5"
19-
python: 3.5
2014
- &python36
2115
name: "Python 3.6"
2216
python: 3.6
23-
- &python37
24-
name: "Python 3.7"
25-
python: 3.7
26-
dist: xenial
27-
sudo: true
2817
- &pypy
2918
name: "PyPy"
3019
python: pypy
31-
- &pypy3
32-
name: "PyPy3"
33-
python: pypy3.5
3420

3521
_helpers:
36-
- &install_cython pip install --upgrade Cython
3722
- &build_package python setup.py bdist_wheel
38-
- &install_built pip install advanced_descriptors --no-index -f dist
39-
- &test_no_cov py.test -vv test
40-
- &test_cythonized
41-
stage: Test cythonized
42-
install:
43-
- *upgrade_python_toolset
44-
- *install_test_deps
45-
- *install_deps
46-
- *install_cython
47-
script:
48-
- *build_package
49-
- *install_built
50-
- *test_no_cov
51-
after_success: skip
5223

5324
- &static_analysis
5425
stage: Static analysis
55-
<<: *python37
26+
<<: *python36
5627
after_success: skip
5728

5829
- &code_style_check
5930
stage: Code style check
60-
<<: *python37
31+
<<: *python36
6132
after_success: skip
6233

6334
script:
@@ -72,21 +43,10 @@ jobs:
7243
include:
7344
- stage: test
7445
<<: *python27
75-
- stage: test
76-
<<: *python34
77-
- stage: test
78-
<<: *python35
79-
- stage: test
80-
<<: *python36
81-
- stage: test
82-
<<: *python37
8346
- stage: test
8447
<<: *pypy
85-
- stage: test
86-
<<: *pypy3
8748

8849
- <<: *static_analysis
89-
<<: *python36
9050
name: "PyLint"
9151
install:
9252
- *upgrade_python_toolset
@@ -106,19 +66,10 @@ jobs:
10666
install:
10767
- *upgrade_python_toolset
10868
- *install_deps
109-
- pip install --upgrade "mypy >= 0.620"
69+
- pip install --upgrade "mypy >= 0.630"
11070
script:
11171
- mypy --strict advanced_descriptors
11272

113-
- <<: *test_cythonized
114-
<<: *python34
115-
- <<: *test_cythonized
116-
<<: *python35
117-
- <<: *test_cythonized
118-
<<: *python36
119-
- <<: *test_cythonized
120-
<<: *python37
121-
12273
- <<: *code_style_check
12374
name: "PEP8"
12475
install:
@@ -137,18 +88,15 @@ jobs:
13788
- stage: deploy
13889
# This prevents job from appearing in test plan unless commit is tagged:
13990
if: tag IS present
140-
# Run on pypy to build not cythonized wheel
141-
<<: *pypy3
142-
name: Build universal and cythonized bdist_wheel. Deploy bdist and sdist.
143-
services:
144-
- docker
91+
<<: *pypy
92+
name: Build universal bdist_wheel. Deploy bdist and sdist.
93+
services: []
14594
install:
14695
- *upgrade_python_toolset
147-
script:
148-
- ./tools/run_docker.sh "Advanced_Descriptors"
149-
before_deploy:
15096
- pip install -r build_requirements.txt
97+
script:
15198
- *build_package
99+
before_deploy: []
152100
deploy:
153101
- provider: pypi
154102
# `skip_cleanup: true` is required to preserve binary wheels, built

advanced_descriptors/separate_class_method.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ def __get__(self, instance, owner): # type: (typing.Optional[typing.Any], typin
116116
raise AttributeError()
117117

118118
@six.wraps(self.__class_method)
119-
def class_method(*args, **kwargs): # type: (typing.Tuple, typing.Dict) -> typing.Any
119+
def class_method(*args, **kwargs): # type: (typing.Any, typing.Any) -> typing.Any
120120
"""Bound class method."""
121121
return self.__class_method(owner, *args, **kwargs) # type: ignore
122122

setup.py

Lines changed: 2 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,10 @@
1717

1818
import ast
1919
import collections
20-
from distutils.command import build_ext
21-
import distutils.errors
2220
import os.path
23-
import shutil
24-
import sys
25-
26-
try:
27-
from Cython.Build import cythonize
28-
except ImportError:
29-
cythonize = None
3021

3122
import setuptools
3223

33-
PY3 = sys.version_info[:2] > (2, 7)
34-
3524
with open(os.path.join(os.path.dirname(__file__), "advanced_descriptors", "__init__.py")) as f:
3625
source = f.read()
3726

@@ -42,76 +31,12 @@
4231
long_description = f.read()
4332

4433

45-
def _extension(modpath):
46-
"""Make setuptools.Extension."""
47-
return setuptools.Extension(modpath, [modpath.replace(".", "/") + ".py"])
48-
49-
50-
requires_optimization = [
51-
_extension("advanced_descriptors.separate_class_method"),
52-
_extension("advanced_descriptors.advanced_property"),
53-
]
54-
55-
if "win32" != sys.platform:
56-
requires_optimization.append(_extension("advanced_descriptors.__init__"))
57-
58-
ext_modules = (
59-
cythonize(
60-
requires_optimization,
61-
compiler_directives=dict(
62-
always_allow_keywords=True, binding=True, embedsignature=True, overflowcheck=True, language_level=3
63-
),
64-
)
65-
if cythonize is not None and PY3
66-
else []
67-
)
68-
69-
7034
class BuildFailed(Exception):
7135
"""For install clear scripts."""
7236

7337
pass
7438

7539

76-
class AllowFailRepair(build_ext.build_ext):
77-
"""This class allows C extension building to fail and repairs init."""
78-
79-
def run(self):
80-
"""Run."""
81-
try:
82-
build_ext.build_ext.run(self)
83-
84-
# Copy __init__.py back to repair package.
85-
build_dir = os.path.abspath(self.build_lib)
86-
root_dir = os.path.abspath(os.path.join(__file__, ".."))
87-
target_dir = build_dir if not self.inplace else root_dir
88-
89-
src_file = os.path.join("advanced_descriptors", "__init__.py")
90-
91-
src = os.path.join(root_dir, src_file)
92-
dst = os.path.join(target_dir, src_file)
93-
94-
if src != dst:
95-
shutil.copyfile(src, dst)
96-
except (
97-
distutils.errors.DistutilsPlatformError,
98-
getattr(globals()["__builtins__"], "FileNotFoundError", OSError),
99-
):
100-
raise BuildFailed()
101-
102-
def build_extension(self, ext):
103-
"""build_extension."""
104-
try:
105-
build_ext.build_ext.build_extension(self, ext)
106-
except (
107-
distutils.errors.CCompilerError,
108-
distutils.errors.DistutilsExecError,
109-
distutils.errors.DistutilsPlatformError,
110-
ValueError,
111-
):
112-
raise BuildFailed()
113-
114-
11540
# noinspection PyUnresolvedReferences
11641
def get_simple_vars_from_src(src):
11742
"""Get simple (string/number/boolean and None) assigned values from source.
@@ -160,8 +85,6 @@ def get_simple_vars_from_src(src):
16085
OrderedDict([('e', 1), ('f', 1), ('g', 1)])
16186
"""
16287
ast_data = (ast.Str, ast.Num, ast.List, ast.Set, ast.Dict, ast.Tuple)
163-
if PY3:
164-
ast_data += (ast.Bytes, ast.NameConstant)
16588

16689
tree = ast.parse(src)
16790

@@ -196,18 +119,13 @@ def get_simple_vars_from_src(src):
196119
"License :: OSI Approved :: Apache Software License",
197120
"Programming Language :: Python :: 2",
198121
"Programming Language :: Python :: 2.7",
199-
"Programming Language :: Python :: 3",
200-
"Programming Language :: Python :: 3.4",
201-
"Programming Language :: Python :: 3.5",
202-
"Programming Language :: Python :: 3.6",
203-
"Programming Language :: Python :: 3.7",
204122
"Programming Language :: Python :: Implementation :: CPython",
205123
"Programming Language :: Python :: Implementation :: PyPy",
206124
]
207125

208126
keywords = ["descriptor", "property", "classmethod", "development"]
209127

210-
setup_args = dict(
128+
setuptools.setup(
211129
name="Advanced-Descriptors",
212130
author=variables["__author__"],
213131
author_email=variables["__author_email__"],
@@ -221,7 +139,7 @@ def get_simple_vars_from_src(src):
221139
long_description=long_description,
222140
classifiers=classifiers,
223141
keywords=keywords,
224-
python_requires=">=2.7.5,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*",
142+
python_requires=">=2.7.5,<3.0",
225143
# While setuptools cannot deal with pre-installed incompatible versions,
226144
# setting a lower bound is not harmful - it makes error messages cleaner. DO
227145
# NOT set an upper bound on setuptools, as that will lead to uninstallable
@@ -234,14 +152,3 @@ def get_simple_vars_from_src(src):
234152
install_requires=required,
235153
package_data={"advanced_descriptors": ["py.typed"]},
236154
)
237-
if cythonize is not None:
238-
setup_args["ext_modules"] = ext_modules
239-
setup_args["cmdclass"] = dict(build_ext=AllowFailRepair)
240-
241-
try:
242-
setuptools.setup(**setup_args)
243-
except BuildFailed:
244-
print("*" * 80 + "\n" "* Build Failed!\n" "* Use clear scripts version.\n" "*" * 80 + "\n")
245-
del setup_args["ext_modules"]
246-
del setup_args["cmdclass"]
247-
setuptools.setup(**setup_args)

tox.ini

Lines changed: 5 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
[tox]
77
minversion = 2.0
8-
envlist = black, pep8, pylint, mypy, bandit, pep257, py{27,34,35,36,37,py,py3}, py{34,35,36,37}-nocov, docs,
8+
envlist = black, pep8, pylint, mypy, bandit, pep257, py{27,py}, docs,
99
skipsdist = True
1010
skip_missing_interpreters = True
1111

@@ -20,53 +20,19 @@ deps =
2020
pytest-cov
2121
pytest-html
2222
pytest-sugar
23-
py{34,35,36,37}-nocov: Cython
2423
-r{toxinidir}/CI_REQUIREMENTS.txt
2524
py{27,py}: mock
2625

2726
commands =
2827
py.test -vv --junitxml=unit_result.xml --html=report.html --self-contained-html --cov-config .coveragerc --cov-report html --cov=advanced_descriptors {posargs:test}
2928
coverage report --fail-under 89
3029

31-
[testenv:py34-nocov]
32-
usedevelop = False
33-
commands =
34-
python setup.py bdist_wheel
35-
pip install advanced_descriptors --no-index -f dist
36-
py.test -vv {posargs:test}
37-
38-
[testenv:py35-nocov]
39-
usedevelop = False
40-
commands =
41-
python setup.py bdist_wheel
42-
pip install advanced_descriptors --no-index -f dist
43-
py.test -vv {posargs:test}
44-
45-
[testenv:py36-nocov]
46-
usedevelop = False
47-
commands =
48-
python setup.py bdist_wheel
49-
pip install advanced_descriptors --no-index -f dist
50-
py.test -vv {posargs:test}
51-
52-
[testenv:py37-nocov]
53-
usedevelop = False
54-
commands =
55-
python setup.py bdist_wheel
56-
pip install advanced_descriptors --no-index -f dist
57-
py.test -vv {posargs:test}
58-
5930
[testenv:venv]
6031
commands = {posargs:}
6132

6233
[tox:travis]
6334
2.7 = install, py27
64-
3.4 = py34,
65-
3.5 = py35,
66-
3.6 = py36,
67-
3.7 = py37,
6835
pypy = install, pypy,
69-
pypy3 = install, pypy3,
7036

7137
[testenv:pep8]
7238
deps =
@@ -86,6 +52,7 @@ usedevelop = False
8652
commands = pip install ./ -vvv -U
8753

8854
[testenv:pylint]
55+
usedevelop = False
8956
deps =
9057
pylint<2
9158
-r{toxinidir}/CI_REQUIREMENTS.txt
@@ -123,11 +90,13 @@ ignore =
12390
# Multi-line docstring summary should start at the second line
12491

12592
[testenv:docs]
93+
usedevelop = False
12694
deps =
12795
sphinx
12896
commands = python setup.py build_sphinx
12997

13098
[testenv:bandit]
99+
usedevelop = False
131100
deps = bandit
132101
commands = bandit -r advanced_descriptors
133102

@@ -145,6 +114,7 @@ commands =
145114
black advanced_descriptors
146115

147116
[testenv:mypy]
117+
usedevelop = False
148118
deps =
149119
mypy>=0.630
150120
-r{toxinidir}/CI_REQUIREMENTS.txt

0 commit comments

Comments
 (0)