-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsetup.py
112 lines (97 loc) · 3.99 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
"""
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:
files = os.listdir(script_dirname)
sys.stderr.write("files before: " + str(files))
print("files before: " + str(files))
make_path = os.path.realpath(script_dirname)
make_process = subprocess.Popen('make build-libc-swig',
cwd=make_path,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
shell=True)
sys.stderr.write("files after: " + str(files))
stdout, stderr = make_process.communicate()
print("stdout:")
sys.stderr.write(str(stdout))
if len(stderr) > 0:
print("stderr:")
sys.stderr.write(str(stderr))
files = os.listdir(script_dirname)
sys.stderr.write("files after: " + str(files))
print("files after: " + str(files))
# 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/fibercrypto/libskyfiber".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='pyskyfiber', # Required
version=__version__, # Required
description="Skycoin Python Library",
long_description=long_description,
long_description_content_type="text/markdown",
url="https://github.com/fibercrypto/pyskyfiber",
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 :: GNU Lesser General Public License v3 (LGPLv3)",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.4",
"Programming Language :: Python :: 3.5",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
],
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=[],
)
],
)