forked from python-hyper/hyper
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathsetup.py
More file actions
118 lines (102 loc) · 3.64 KB
/
setup.py
File metadata and controls
118 lines (102 loc) · 3.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
#!/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)
packages = [
'hyper',
'hyper.http20',
'hyper.common',
'hyper.http11',
]
BASE_DIR = os.path.realpath(os.path.dirname(__file__))
VERSION = "1.0.0"
def replace_version_py(version):
version_py = os.path.join(BASE_DIR, 'hyper', '__init__.py')
new_content = ""
with open(version_py, 'r') as fd:
content = fd.read()
new_content = re.sub(r'[\'"](\d+\.\d+.\d+)[\'"]', "'{}'".format(version), content)
with open(version_py, 'w') as fd:
fd.write(new_content)
def generate_version():
version = VERSION
if os.path.isfile(os.path.join(BASE_DIR, "version.txt")):
with open("version.txt", "r") as fd:
content = fd.read().strip()
if content:
version = content
replace_version_py(version)
return version
def parse_requirements():
reqs = []
if os.path.isfile(os.path.join(BASE_DIR, "requirements.txt")):
with open(os.path.join(BASE_DIR, "requirements.txt"), 'r') as fd:
for line in fd.readlines():
line = line.strip()
if line:
reqs.append(line)
return reqs
setup(
name='hyper-qta',
version=generate_version(),
description='HTTP/2 Client for Python',
long_description=open('README.rst').read() + '\n\n' + open('HISTORY.rst').read(),
author='qta',
url='http://hyper.rtfd.org',
packages=packages,
package_data={'': ['LICENSE', 'README.rst', 'CONTRIBUTORS.rst', 'HISTORY.rst', 'NOTICES', '*.txt', '*.TXT']},
data_files=[(".", ["requirements.txt", "version.txt"])],
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.5',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: Implementation :: CPython',
],
install_requires=parse_requirements(),
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']
}
)