-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsetup.py
55 lines (47 loc) · 1.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
import zipfile
import setuptools
import os
from distutils.core import Extension, setup
import glob
import shutil
import sys
from zipfile import ZipFile
module_name = 'basic_math_operations'
version = '1.0.0'
# Print current directory
print("Current directory: " + os.getcwd())
if (os.path.exists('dist/artifacts/linux-build/libbasic_math_operations-linux.zip') and os.name != 'nt'):
with zipfile.ZipFile('dist/artifacts/linux-build/libbasic_math_operations-linux.zip', 'r') as zfile:
zfile.extract('libbasic_math_operations.a')
shutil.copy("libbasic_math_operations.a",
"src/python-module/libbasic_math_operations.a")
if (os.path.exists('dist/artifacts/windows-build/libbasic_math_operations-windows.a') and os.name == 'nt'):
shutil.copy("dist/artifacts/windows-build/libbasic_math_operations-windows.a",
"src/python-module/libbasic_math_operations.a")
shutil.copy("dist/artifacts/version-info/version.txt",
"src/python-module/version.txt")
with open('version.txt' if os.path.exists('version.txt') else 'src/python-module/version.txt', 'r') as f:
version = f.read()
version.replace('\n', '')
basic_math_operations_module = Extension(
module_name,
sources=['src/python-module/module.c'],
extra_objects=['src/python-module/libbasic_math_operations.a']
)
setup(
name="basic_math_operations",
version=version,
description="Biginteger library written in assembly and C.",
author="avighnac",
author_email="[email protected]",
ext_modules=[basic_math_operations_module],
setup_requires=['wheel'],
include_package_data=True,
packages=['src/python-module'],
package_data={
'src/python-module': ['src/python-module/libbasic_math_operations.a', 'src/python-module/version.txt']},
data_files=[
('src/python-module', ['src/python-module/libbasic_math_operations.a', 'src/python-module/version.txt'])],
)
os.remove('src/python-module/libbasic_math_operations.a')
os.remove('src/python-module/version.txt')