This repository has been archived by the owner on Dec 30, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.py
110 lines (87 loc) · 3.34 KB
/
setup.py
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
import os
import shutil
import subprocess
import sys
import setuptools.command.build_py
import setuptools.command.build_ext
# have to exec; can't import the package before it's built.
exec(open("pynng/_version.py", encoding="utf-8").read())
THIS_DIR = os.path.dirname(__file__)
NNG_REVISION = 'd3bd35ab49ad74528fd9e34cce9016d74dd91943'
MBEDTLS_REVISION = '04a049bda1ceca48060b57bc4bcf5203ce591421'
def build_nng_lib():
# cannot import build_pynng at the top level becuase cffi may not be
# installed yet (since it is a dependency, and this script installs
# dependencies). Bootstrapping!
import build_pynng
if len(build_pynng.objects) > 0 and all(map(os.path.exists, build_pynng.objects)):
# the object file we were planning on building already exists; we'll
# just use it!
return
is_64bit = sys.maxsize > 2**32
is_posix_shell = os.getenv("SHELL") is not None or sys.platform != 'win32'
script = os.path.join(THIS_DIR, 'build_nng.sh') if is_posix_shell \
else os.path.join(THIS_DIR, 'build_nng.bat')
cmake_platform = ""
if sys.platform == 'win32':
cmake_platform = "-A x64" if is_64bit else "-A win32"
cmd = [script, NNG_REVISION, MBEDTLS_REVISION, cmake_platform]
if is_posix_shell:
cmd = [shutil.which("sh")] + cmd
subprocess.check_call(cmd)
# TODO: this is basically a hack to get something to run before running cffi
# extnsion builder. subclassing something else would be better!
class BuildPyCommand(setuptools.command.build_py.build_py):
"""Build nng library before anything else."""
def run(self):
build_nng_lib()
super(BuildPyCommand, self).run()
class BuildExtCommand(setuptools.command.build_ext.build_ext):
"""Build nng library before anything else."""
def run(self):
build_nng_lib()
super(BuildExtCommand, self).run()
with open('README.md', 'r', encoding='utf-8') as f:
long_description = f.read()
tests_require = [
'pytest',
'pytest-asyncio',
'pytest-trio',
'trio',
]
setuptools.setup(
cmdclass={
'build_py': BuildPyCommand,
'build_ext': BuildExtCommand,
},
name='pynng-tls',
version=__version__,
author='Cody Piersall',
author_email='[email protected]',
description='Networking made simply using nng (TLS enabled version)',
long_description=long_description,
license='MIT',
keywords='networking nng nanomsg zmq messaging message trio asyncio',
long_description_content_type='text/markdown',
url='https://github.com/codypiersall/pynng',
packages=setuptools.find_packages(),
classifiers=([
'Development Status :: 3 - Alpha',
'Framework :: AsyncIO',
'Framework :: Trio',
'License :: OSI Approved :: MIT License',
'Operating System :: OS Independent',
'Programming Language :: Python :: 3 :: Only',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Topic :: Software Development :: Libraries',
'Topic :: System :: Networking',
]),
setup_requires=['cffi', 'pytest-runner'],
install_requires=['cffi', 'sniffio'],
cffi_modules=['build_pynng.py:ffibuilder'],
tests_require=tests_require,
test_suite='tests',
)