forked from dahlia/pghstore
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
In setuptools 46.0.0, the project dropped support for "features" and instead we should be using ext_modules. This updates the project to build on setuptools 46.0 and newer. Refs pypa/setuptools#65
- Loading branch information
1 parent
8be93bd
commit 0d75b9c
Showing
1 changed file
with
51 additions
and
94 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,19 @@ | ||
from __future__ import print_function | ||
from distutils.cmd import Command | ||
from distutils.command.build_ext import build_ext | ||
from distutils.errors import (CCompilerError, DistutilsExecError, | ||
DistutilsPlatformError) | ||
from distutils.errors import CCompilerError, DistutilsExecError, DistutilsPlatformError | ||
import os | ||
import os.path | ||
import shutil | ||
import sys | ||
import tempfile | ||
|
||
from setuptools import Extension, Feature, setup | ||
from setuptools import Extension, setup | ||
|
||
# Allow us to import the version string | ||
sys.path.insert(0, os.path.join(os.path.dirname(__file__), 'src')) | ||
from pghstore.version import VERSION | ||
sys.path.insert(0, os.path.join(os.path.dirname(__file__), "src")) | ||
from pghstore.version import VERSION # noqa: E402 | ||
|
||
|
||
try: | ||
readme_f = open('README.rst') | ||
readme_f = open("README.rst") | ||
long_description = readme_f.read() | ||
readme_f.close() | ||
except IOError: | ||
|
@@ -26,55 +22,19 @@ | |
tests_require = None | ||
|
||
|
||
class upload_doc(Command): | ||
"""Uploads the documentation to GitHub pages.""" | ||
|
||
description = __doc__ | ||
user_options = [] | ||
|
||
def initialize_options(self): | ||
pass | ||
|
||
def finalize_options(self): | ||
pass | ||
|
||
def run(self): | ||
path = tempfile.mkdtemp() | ||
build = os.path.join(os.path.dirname(os.path.abspath(__file__)), | ||
'build', 'sphinx', 'html') | ||
os.chdir(path) | ||
os.system('git clone [email protected]:dahlia/pghstore.git .') | ||
os.system('git checkout gh-pages') | ||
os.system('git rm -r .') | ||
os.system('touch .nojekyll') | ||
os.system('cp -r ' + build + '/* .') | ||
os.system('git stage .') | ||
os.system('git commit -a -m "Documentation updated."') | ||
os.system('git push origin gh-pages') | ||
shutil.rmtree(path) | ||
|
||
|
||
# Most of the following codes to allow C extension building to fail were | ||
# copied from MarkupSafe's setup.py script. | ||
# https://github.com/mitsuhiko/markupsafe/blob/master/setup.py | ||
|
||
is_jython = 'java' in sys.platform | ||
is_pypy = hasattr(sys, 'pypy_version_info') | ||
|
||
|
||
speedups = Feature( | ||
'optional C speed-enhancement module', | ||
standard=True, | ||
available=not (is_jython or is_pypy), | ||
ext_modules=[ | ||
Extension('pghstore._speedups', ['src/pghstore/_speedups.c'], | ||
extra_compile_args=['-O3']) | ||
] | ||
) | ||
ext_modules = [ | ||
Extension( | ||
"pghstore._speedups", ["src/pghstore/_speedups.c"], extra_compile_args=["-O3"] | ||
) | ||
] | ||
|
||
|
||
ext_errors = CCompilerError, DistutilsExecError, DistutilsPlatformError | ||
if sys.platform == 'win32' and sys.version_info > (2, 6): | ||
if sys.platform == "win32" and sys.version_info > (2, 6): | ||
# 2.6's distutils.msvc9compiler can raise an IOError when failing to | ||
# find the compiler | ||
ext_errors += (IOError,) | ||
|
@@ -101,68 +61,65 @@ def build_extension(self, ext): | |
raise BuildFailed() | ||
except ValueError: | ||
# this can happen on Windows 64 bit, see Python issue 7511 | ||
if "'path'" in str(sys.exc_info()[1]): # works with Python 2 and 3 | ||
if "'path'" in str(sys.exc_info()[1]): # works with Python 2 and 3 | ||
raise BuildFailed() | ||
raise | ||
|
||
|
||
def run_setup(with_speedups): | ||
setup( | ||
name='pghstore', | ||
packages=['pghstore'], | ||
package_dir={'': 'src'}, | ||
features={'speedups': speedups} if with_speedups else {}, | ||
name="pghstore", | ||
packages=["pghstore"], | ||
package_dir={"": "src"}, | ||
ext_modules=ext_modules, | ||
version=VERSION, | ||
description='PostgreSQL hstore formatter', | ||
description="PostgreSQL hstore formatter", | ||
long_description=long_description, | ||
license='MIT License', | ||
author='Hong Minhee', | ||
author_email='minhee' '@' 'dahlia.kr', | ||
maintainer='Robert Kajic', | ||
maintainer_email='robert' '@' 'kajic.com', | ||
url='https://github.com/dahlia/pghstore', | ||
test_suite='pghstoretests.tests', | ||
install_requires=['six'], | ||
license="MIT License", | ||
author="Hong Minhee", | ||
author_email="minhee" "@" "dahlia.kr", | ||
maintainer="Robert Kajic", | ||
maintainer_email="robert" "@" "kajic.com", | ||
url="https://github.com/dahlia/pghstore", | ||
test_suite="pghstoretests.tests", | ||
install_requires=["six"], | ||
tests_require=tests_require, | ||
platforms=['any'], | ||
cmdclass={ | ||
'build_ext': ve_build_ext, | ||
'upload_doc': upload_doc | ||
}, | ||
platforms=["any"], | ||
cmdclass={"build_ext": ve_build_ext}, | ||
classifiers=[ | ||
'Development Status :: 4 - Beta', | ||
'Intended Audience :: Developers', | ||
'License :: OSI Approved :: MIT License', | ||
'Operating System :: OS Independent', | ||
'Programming Language :: Python :: 2.5', | ||
'Programming Language :: Python :: 2.6', | ||
'Programming Language :: Python :: 2.7', | ||
'Programming Language :: Python :: 2 :: Only', | ||
'Programming Language :: Python :: Implementation :: CPython', | ||
'Programming Language :: Python :: Implementation :: PyPy', | ||
'Programming Language :: Python :: Implementation :: Stackless', | ||
'Topic :: Database', | ||
'Topic :: Software Development :: Libraries :: Python Modules' | ||
] | ||
"Development Status :: 4 - Beta", | ||
"Intended Audience :: Developers", | ||
"License :: OSI Approved :: MIT License", | ||
"Operating System :: OS Independent", | ||
"Programming Language :: Python :: 2.5", | ||
"Programming Language :: Python :: 2.6", | ||
"Programming Language :: Python :: 2.7", | ||
"Programming Language :: Python :: 2 :: Only", | ||
"Programming Language :: Python :: Implementation :: CPython", | ||
"Programming Language :: Python :: Implementation :: PyPy", | ||
"Programming Language :: Python :: Implementation :: Stackless", | ||
"Topic :: Database", | ||
"Topic :: Software Development :: Libraries :: Python Modules", | ||
], | ||
) | ||
|
||
|
||
def try_building_extension(): | ||
try: | ||
run_setup(True) | ||
except BuildFailed: | ||
print('=' * 74) | ||
print('WARNING: The C extension could not be compiled,', end=' ') | ||
print('speedups are not enabled.') | ||
print('Failure information, if any, is above.') | ||
print('Retrying the build without the C extension now.') | ||
print("=" * 74) | ||
print("WARNING: The C extension could not be compiled,", end=" ") | ||
print("speedups are not enabled.") | ||
print("Failure information, if any, is above.") | ||
print("Retrying the build without the C extension now.") | ||
print() | ||
run_setup(False) | ||
print('=' * 74) | ||
print('WARNING: The C extension could not be compiled,', end=' ') | ||
print('speedups are not enabled.') | ||
print('Plain-Python installation succeeded.') | ||
print('=' * 74) | ||
print("=" * 74) | ||
print("WARNING: The C extension could not be compiled,", end=" ") | ||
print("speedups are not enabled.") | ||
print("Plain-Python installation succeeded.") | ||
print("=" * 74) | ||
|
||
|
||
try_building_extension() |