-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathsetup.py
81 lines (68 loc) · 2.87 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
import os
from io import BytesIO
import platform
from zipfile import ZipFile
import urllib.request
from distutils.command.install import install
from setuptools import setup, find_packages
from setuptools.command.develop import develop
class DownloadBinariesAndInstall(install):
def run(self):
super(DownloadBinariesAndInstall, self).run()
install_bin(os.path.join(self.install_purelib, "sensapex"), force=True)
class DownloadBinariesAndDevelop(develop):
def run(self):
super(DownloadBinariesAndDevelop, self).run()
install_bin(os.path.join(self.egg_path, "sensapex"))
def install_bin(path, force=False):
"""Install libum.dll and umpcli.exe to *path*."""
if force or platform.system() == "Windows":
dll_data = download_from_zip(
"https://github.com/sensapex/umsdk/releases/download/v1.400/umsdk-1.400-binaries.zip", ["umsdk-1.400-binaries/x64/libum.dll"]
)[0]
print(f"Install libum.dll to {path}")
with open(os.path.join(path, "libum.dll"), "wb") as install_target:
install_target.write(dll_data)
umpcli_data = download_from_zip(
"http://dist.sensapex.com/misc/umpcli/umpcli-0_957-beta.zip", ["umpcli.exe"]
)[0]
with open(os.path.join(path, "umpcli.exe"), "wb") as install_target:
install_target.write(umpcli_data)
def download_from_zip(url, files):
req = urllib.request.urlopen(url)
content_file = BytesIO(req.read())
data = []
with ZipFile(content_file, "r") as zip_file:
for filename in files:
with zip_file.open(filename) as req_file:
data.append(req_file.read())
return data
this_directory = os.path.abspath(os.path.dirname(__file__))
with open(os.path.join(this_directory, "README.md"), encoding="utf-8") as f:
long_description = f.read()
setup(
author="Luke Campagnola",
author_email="luke.campagnola@gmail.com",
classifiers=[
"Development Status :: 4 - Beta",
"Environment :: Other Environment",
"Intended Audience :: Science/Research",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
"Programming Language :: Python :: 3",
"Programming Language :: Python",
"Topic :: Scientific/Engineering",
"Topic :: Software Development :: Libraries :: Python Modules",
],
cmdclass={"install": DownloadBinariesAndInstall, "develop": DownloadBinariesAndDevelop},
description="Python wrapper for the Sensapex SDK",
install_requires=["numpy", ],
license="MIT",
long_description=long_description,
long_description_content_type="text/markdown",
name="sensapex",
packages=find_packages(),
python_requires=">=3.7",
url="https://github.com/sensapex/sensapex-py",
version="1.400.4", # in lock step with umsdk version. don't forget __version__ and changelog!
)