diff --git a/.gitignore b/.gitignore index 1f7b029b..ef2ccce3 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,5 @@ __pycache__ .coverage .tox/ .cache/ + +/hyper/version.py diff --git a/.travis/install.sh b/.travis/install.sh index d7423ce7..56bfca2d 100755 --- a/.travis/install.sh +++ b/.travis/install.sh @@ -7,7 +7,9 @@ if [[ "$HYPER_FAST_PARSE" = true ]]; then pip install pycohttpparser~=1.0 fi -pip install -U setuptools -pip install . +pip install -U pip +pip install -U setuptools wheel build +python3 -m build -nwx . +pip install --upgrade ./dist/*.whl pip install -r test_requirements.txt pip install flake8 diff --git a/hyper/__init__.py b/hyper/__init__.py index 99044881..73a7caaa 100644 --- a/hyper/__init__.py +++ b/hyper/__init__.py @@ -33,4 +33,4 @@ # Set default logging handler. logging.getLogger(__name__).addHandler(logging.NullHandler()) -__version__ = '0.8.0dev0' +from .version import __version__ diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 00000000..63f88577 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,7 @@ +[build-system] +requires = ["setuptools>=44", "wheel", "setuptools_scm[toml]>=3.4.3"] +build-backend = "setuptools.build_meta" + +[tool.setuptools_scm] +write_to = "hyper/version.py" +write_to_template = "__version__ = '{version}'\n" diff --git a/setup.cfg b/setup.cfg index 53d397a8..79244198 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,5 +1,59 @@ +[metadata] +name = hyper +version = attr: setup.__version__ +author = Cory Benfield +author_email = cory@lukasa.co.uk +license = MIT License +description = HTTP/2 Client for Python +long_description = file: README.rst, HISTORY.rst +url = http://hyper.rtfd.org +classifiers = + Development Status :: 3 - Alpha + Intended Audience :: Developers + License :: OSI Approved :: MIT License + Programming Language :: Python + Programming Language :: Python :: 2 + Programming Language :: Python :: 2.7 + Programming Language :: Python :: 3 + Programming Language :: Python :: 3.4 + Programming Language :: Python :: 3.5 + Programming Language :: Python :: Implementation :: CPython + +[options] +packages = + hyper + hyper.http20 + hyper.common + hyper.http11 +install_requires = + h2>=2.4,<3.0,!=2.5.0 + hyperframe>=3.2,<4.0 + rfc3986>=1.1.0,<2.0 + brotlipy>=0.7.0 + pyOpenSSL>=0.15; python_full_version < "2.7.9" # Fallback to good SSL on bad Python versions. + service_identity>=14.0.0; python_full_version < "2.7.9" + cryptography<1.0; platform_python_implementation == "pypy" and python_full_version < "2.7.9" # PyPy with bad SSL modules will likely also need the cryptography module at lower than 1.0, because it doesn't support CFFI v1.0 yet. + enum34>=1.0.4, <2; python_version == "2.7" or python_version == "3.3" + +include_package_data = True +tests_require = pytest; requests; mock + +[options.entry_points] +console_scripts = hyper = hyper.cli:main + +[options.extras_require] +fast = pycohttpparser + +[options.package_data] +"" = + LICENSE + README.rst + CONTRIBUTORS.rst + HISTORY.rst + NOTICES + [wheel] universal = 1 [flake8] -max-complexity = 15 +max-complexity = 15 \ No newline at end of file diff --git a/setup.py b/setup.py deleted file mode 100644 index 94cd8d21..00000000 --- a/setup.py +++ /dev/null @@ -1,102 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- -import os -import re -import sys - -from setuptools import setup -from setuptools.command.test import test as TestCommand - - -class PyTest(TestCommand): - user_options = [('pytest-args=', 'a', "Arguments to pass to py.test")] - - def initialize_options(self): - TestCommand.initialize_options(self) - self.pytest_args = ['test/'] - - def finalize_options(self): - TestCommand.finalize_options(self) - self.test_args = [] - self.test_suite = True - - def run_tests(self): - # import here, cause outside the eggs aren't loaded - import pytest - errno = pytest.main(self.pytest_args) - sys.exit(errno) - - -# Get the version -version_regex = r'__version__ = ["\']([^"\']*)["\']' -with open('hyper/__init__.py', 'r') as f: - text = f.read() - match = re.search(version_regex, text) - - if match: - version = match.group(1) - else: - raise RuntimeError("No version number found!") - -# Stealing this from Kenneth Reitz -if sys.argv[-1] == 'publish': - os.system('python setup.py sdist upload') - sys.exit() - - -packages = [ - 'hyper', - 'hyper.http20', - 'hyper.common', - 'hyper.http11', -] - -setup( - name='hyper', - version=version, - description='HTTP/2 Client for Python', - long_description=open('README.rst').read() + '\n\n' + open('HISTORY.rst').read(), - author='Cory Benfield', - author_email='cory@lukasa.co.uk', - url='http://hyper.rtfd.org', - packages=packages, - package_data={'': ['LICENSE', 'README.rst', 'CONTRIBUTORS.rst', 'HISTORY.rst', 'NOTICES']}, - package_dir={'hyper': 'hyper'}, - include_package_data=True, - license='MIT License', - classifiers=[ - 'Development Status :: 3 - Alpha', - 'Intended Audience :: Developers', - 'License :: OSI Approved :: MIT License', - 'Programming Language :: Python', - 'Programming Language :: Python :: 2', - 'Programming Language :: Python :: 2.7', - 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 3.4', - 'Programming Language :: Python :: 3.5', - 'Programming Language :: Python :: Implementation :: CPython', - ], - install_requires=[ - 'h2>=2.4,<3.0,!=2.5.0', 'hyperframe>=3.2,<4.0', 'rfc3986>=1.1.0,<2.0', 'brotlipy>=0.7.0,<1.0' - ], - tests_require=['pytest', 'requests', 'mock'], - cmdclass={'test': PyTest}, - entry_points={ - 'console_scripts': [ - 'hyper = hyper.cli:main', - ], - }, - extras_require={ - 'fast': ['pycohttpparser'], - # Fallback to good SSL on bad Python versions. - ':python_full_version < "2.7.9"': [ - 'pyOpenSSL>=0.15', 'service_identity>=14.0.0' - ], - # PyPy with bad SSL modules will likely also need the cryptography - # module at lower than 1.0, because it doesn't support CFFI v1.0 yet. - ':platform_python_implementation == "PyPy" and python_full_version < "2.7.9"': [ - 'cryptography<1.0' - ], - ':python_version == "2.7" or python_version == "3.3"': ['enum34>=1.0.4, <2'] - } -)