-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.py
More file actions
47 lines (37 loc) · 1.07 KB
/
setup.py
File metadata and controls
47 lines (37 loc) · 1.07 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
import os
import shutil
import subprocess
from distutils.command.build import build
from distutils.errors import CompileError
from setuptools import setup
from setuptools.dist import Distribution
class CustomBuild(build):
def run(self):
current_dir = os.path.dirname(os.path.abspath(__file__))
native_dir = os.path.join(current_dir, 'native')
res = subprocess.run(
[
'cargo',
'build',
'--features', 'c-api',
'--release',
],
cwd=native_dir,
text=True,
)
if res.returncode != 0:
raise CompileError("unable to build the native dependency")
shutil.copy(
os.path.join(native_dir, 'target', 'release', 'libgcdevproxy.so'),
os.path.join(current_dir, 'gcdevproxy'),
)
return super().run()
class BinaryDistribution(Distribution):
def has_ext_modules(self):
return True
setup(
cmdclass={
'build': CustomBuild,
},
distclass=BinaryDistribution,
)