forked from STMicroelectronics/Mp1AmpSTSDK_Python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.py
More file actions
87 lines (74 loc) · 2.56 KB
/
Copy pathsetup.py
File metadata and controls
87 lines (74 loc) · 2.56 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
from setuptools.command.build_py import build_py
from setuptools import setup, find_packages, Extension
import setuptools
import subprocess
import shlex
import sys
import os
VERSION='0.0.13'
def pre_install():
"""Do the custom compiling of the libsdbsdk.so library from the makefile"""
try:
print("Working dir is " + os.getcwd())
# with open("bluepy/version.h","w") as verfile:
# verfile.write('#define VERSION_STRING "%s"\n' % VERSION)
for cmd in [ "make -C ./mp1ampstsdk clean", "make -C mp1ampstsdk -j1" ]:
print("execute " + cmd)
msgs = subprocess.check_output(shlex.split(cmd), stderr=subprocess.STDOUT)
except subprocess.CalledProcessError as e:
print("Failed to compile sdbsdk. Exiting install.")
print("Command was " + repr(cmd) + " in " + os.getcwd())
print("Return code was %d" % e.returncode)
print("Output was:\n%s" % e.output)
sys.exit(1)
class my_build_py(build_py):
def run(self):
pre_install()
build_py.run(self)
setup_cmdclass = {
'build_py' : my_build_py,
}
# Force package to be *not* pure Python
# Discusssed at issue #158
try:
from wheel.bdist_wheel import bdist_wheel
class sdbsdkBdistWheel(bdist_wheel):
def finalize_options(self):
bdist_wheel.finalize_options(self)
self.root_is_pure = False
setup_cmdclass['bdist_wheel'] = sdbsdkBdistWheel
except ImportError:
pass
with open("README.md", "r", encoding='utf-8') as fh:
long_description = fh.read()
module_1 = Extension(
"libsdbsdk",
include_dirs=["mp1ampstsdk"],
sources = ["mp1ampstsdk/sdbsdk.c"],
library_dirs = ['.'])
setup(
name="mp1ampstsdk",
version=VERSION,
author="Licio Mapelli",
author_email="licio.mapelli@st.com",
description="MP1 OpenAMP RpMsg A7-M4 communication SDK",
long_description="OpenAMP RpMsg Py extension to simplify A7-M4 communications",
long_description_content_type="text/markdown",
url="https://github.com/mapellil/Mp1AmpSTSDK_Python",
keywords=[ 'MP1', 'STM', 'STSDK' ],
#packages=find_packages(),
classifiers=[
"Programming Language :: Python :: 3.5",
"License :: OSI Approved :: MIT License",
"Operating System :: POSIX :: Linux",
"Development Status :: 3 - Alpha"
],
install_requires=['pyserial>=3'],
python_requires='>=3.5',
packages=['mp1ampstsdk'],
package_data={
'mp1ampstsdk': ['sdbsdk.c','sdbsdk.h','Makefile','libsdbsdk.so']
},
cmdclass=setup_cmdclass,
ext_modules=[module_1],
)