Skip to content

Commit

Permalink
Merge pull request #19 from zopefoundation/deprecated-setuptools-feat…
Browse files Browse the repository at this point in the history
…ures

Drop the use of the deprecated setuptools Features
  • Loading branch information
jamadden committed Jan 20, 2020
2 parents dc0de85 + 19f7797 commit 086085b
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 43 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ before_install:
install:
- pip install -U pip setuptools
- pip install -U coveralls coverage zope.testrunner
- pip install -U coveralls
- pip install -U -e ".[test]"

script:
Expand Down
4 changes: 2 additions & 2 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@ install:
}
- ps: if (-not (Test-Path $env:PYTHON)) { throw "No $env:PYTHON" }
- echo "C:\Program Files\Microsoft SDKs\Windows\v7.1\Bin\SetEnv.cmd" /x64 > "C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\amd64\vcvars64.bat"
- pip install -e .
- pip install -e .[test]

build_script:
- pip install wheel
- python -W ignore setup.py -q bdist_wheel

test_script:
- python setup.py test -q
- zope-testrunner --test-path=src

artifacts:
- path: 'dist\*.whl'
Expand Down
63 changes: 31 additions & 32 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,44 +18,44 @@
##############################################################################
"""Setup for zope.i18nmessageid package
"""
from __future__ import print_function

import os
import sys

from setuptools import setup, find_packages, Extension, Feature
from distutils.command.build_ext import build_ext
from distutils.errors import CCompilerError
from distutils.errors import DistutilsExecError
from distutils.errors import DistutilsPlatformError
import platform

from setuptools import setup, find_packages, Extension

py_impl = getattr(platform, 'python_implementation', lambda: None)
is_pypy = py_impl() == 'PyPy'
is_jython = 'java' in sys.platform

codeoptimization_c = os.path.join('src', 'zope', 'i18nmessageid',
"_zope_i18nmessageid_message.c")
codeoptimization = Feature(
"Optional code optimizations",
standard=True,
ext_modules=[Extension(
codeoptimization = [
Extension(
"zope.i18nmessageid._zope_i18nmessageid_message",
[os.path.normcase(codeoptimization_c)]
)])

extra = {
'extras_require': {
'testing': ['nose', 'coverage'],
'docs': ['Sphinx'],
},
}
),
]

ext_modules = []
if not is_pypy and not is_jython:
# Jython cannot build the C optimizations, while on PyPy they are
# anti-optimizations (the C extension compatibility layer is known-slow,
# and defeats JIT opportunities).
extra['features'] = {'codeoptimization': codeoptimization}
ext_modules = codeoptimization


tests_require = [
'zope.testrunner',
'coverage',
]

def read(*rnames):
with open(os.path.join(os.path.dirname(__file__), *rnames)) as stream:
Expand All @@ -69,34 +69,27 @@ class optional_build_ext(build_ext):
def run(self):
try:
build_ext.run(self)

except DistutilsPlatformError:
# The sys.exc_info()[1] is to preserve compatibility with both
# Python 2.5 and 3.x, which is needed in setup.py.
self._unavailable(sys.exc_info()[1])
except DistutilsPlatformError as e:
self._unavailable(e)

def build_extension(self, ext):
try:
build_ext.build_extension(self, ext)

except (CCompilerError, DistutilsExecError):
# The sys.exc_info()[1] is to preserve compatibility with both
# Python 2.5 and 3.x, which is needed in setup.py.
self._unavailable(sys.exc_info()[1])
except (CCompilerError, DistutilsExecError) as e:
self._unavailable(e)

def _unavailable(self, e):
# Write directly to stderr to preserve compatibility with both
# Python 2.5 and 3.x, which is needed in setup.py.
sys.stderr.write('*' * 80 + '\n')
sys.stderr.write("""WARNING:
print('*' * 80, file=sys.stderr)
print("""WARNING:
An optional code optimization (C extension) could not be compiled.
Optimizations for this package will not be available!
""")
sys.stderr.write(str(e) + '\n')
sys.stderr.write('*' * 80 + '\n')
""", file=sys.stderr)
print(str(e), file=sys.stderr)
print('*' * 80, file=sys.stderr)



setup(
Expand Down Expand Up @@ -141,5 +134,11 @@ def _unavailable(self, e):
test_suite='zope.i18nmessageid.tests.test_suite',
zip_safe=False,
cmdclass={'build_ext': optional_build_ext},
**extra
ext_modules=ext_modules,
tests_require=tests_require,
extras_require={
'testing': tests_require,
'test': tests_require,
'docs': ['Sphinx'],
},
)
11 changes: 3 additions & 8 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ envlist =
py27,py35,py36,py37,py38,pypy,pypy3,coverage,docs

[testenv]
deps =
.[test]
zope.testrunner
extras = test
commands =
zope-testrunner --test-path=src []

Expand All @@ -15,11 +13,8 @@ usedevelop = true
basepython =
python2.7
commands =
nosetests --with-xunit --with-xcoverage
deps =
nose
coverage
nosexcover
coverage run -m zope.testrunner --test-path=src []
coverage report --fail-under=100

[testenv:docs]
basepython =
Expand Down

0 comments on commit 086085b

Please sign in to comment.