forked from fibercrypto/pyskyfiber
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
130 lines (115 loc) · 4.59 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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
"""
Skycoin python extension
"""
# Always prefer setuptools over distutils
from setuptools import setup, find_packages, Extension
from setuptools.command.build_ext import build_ext
from distutils.errors import DistutilsSetupError
# To use a consistent encoding
from codecs import open
from os import path
import os
import subprocess
import platform
import sys
from skycoin import __version__
script_dirname = path.abspath(path.dirname(__file__))
# Get the long description from the README file
with open(path.join(script_dirname, "README.md"), encoding="utf-8") as f:
long_description = f.read()
class skycoin_build_ext(build_ext, object):
def build_extension(self, ext):
if ext.name != "_skycoin":
# Handle unspecial extensions with the parent class' method
super(skycoin_build_ext, self).build_extension(ext)
else:
# Handle special extension
sources = ext.sources
if sources is None or not isinstance(sources, (list, tuple)):
raise DistutilsSetupError(
"in 'ext_modules' option (extension '%s'), "
"'sources' must be present and must be "
"a list of source filenames" % ext.name
)
sources = list(sources)
if len(sources) > 1:
sources_path = os.path.commonprefix(sources)
else:
sources_path = os.path.dirname(sources[0])
sources_path = os.path.realpath(sources_path)
if not sources_path.endswith(os.path.sep):
sources_path += os.path.sep
if not os.path.exists(sources_path) or not os.path.isdir(sources_path):
raise DistutilsSetupError(
"in 'extensions' option (extension '%s'), "
"the supplied 'sources' base dir "
"must exist" % ext.name
)
make_path = os.path.realpath(os.path.join(sources_path, ".."))
make_process = subprocess.Popen(
"make build-libc-swig",
cwd=make_path,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
shell=True,
)
stdout, stderr = make_process.communicate()
print("stdout:")
sys.stderr.write(str(stdout))
if len(stderr) > 0:
print("stderr:")
sys.stderr.write(str(stderr))
# After making the library build the c library's
# python interface with the parent build_extension method
super(skycoin_build_ext, self).build_extension(ext)
skypath = path.join(*("gopath/src/github.com/skycoin/libskycoin".split("/")))
lib_path = path.join(skypath, "build", "libskycoin")
library_file = path.join(lib_path, "libskycoin.a")
extra_link_args = []
if platform.system() == "Darwin":
extra_link_args += ["-framework", "Foundation", "-framework", "Security"]
extra_link_args.append(library_file)
setup(
name='pyskycoin', # Required
version=__version__, # Required
description="Skycoin Python Library",
long_description=long_description,
long_description_content_type="text/markdown",
url="https://github.com/skycoin/pyskycoin",
author="Ratmil Torres", # Optional
author_email="[email protected]",
setup_requires=["pytest-runner"],
tests_require=["pytest", "urllib3", "certifi"],
classifiers=[
# 3 - Alpha
# 4 - Beta
# 5 - Production/Stable
"Development Status :: 3 - Alpha",
"Intended Audience :: Developers",
"License :: OSI Approved :: MIT License",
"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 :: 3.6",
"Programming Language :: Python :: 3.7",
],
keywords="skycoin crypto coin currency blockchain", # Optional
py_modules=["skycoin"],
packages=find_packages(exclude=["contrib", "docs", "tests"]), # Required
install_requires=[],
extras_require={"dev": ["check-manifest"], "test": ["coverage"]}, # Optional
package_data={},
entry_points={"console_scripts": []},
cmdclass={"build_ext": skycoin_build_ext},
ext_modules=[
Extension(
"_skycoin",
["swig/pyskycoin_wrap.c"],
include_dirs=["swig/include", path.join(skypath, "include")],
extra_link_args=extra_link_args,
depends=[],
)
],
)