-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathsetup.py
63 lines (53 loc) · 1.83 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
# Copyright 2020-2024 XMOS LIMITED.
# This Software is subject to the terms of the XMOS Public Licence: Version 1.
from distutils.command.build import build
from setuptools.command.develop import develop
import os
import setuptools
import subprocess
import contextlib
import platform
@contextlib.contextmanager
def pushd(new_dir):
previous_dir = os.getcwd()
os.chdir(new_dir)
try:
yield
finally:
os.chdir(previous_dir)
class CustomBuildCommand(build):
"""Customized distutils build command """
def run(self):
# Can't assume a specific build command for Windows, so just build for Linux and Mac
if platform.system() in ['Darwin', 'Linux']:
# Make the host binary
with pushd("host/"):
subprocess.check_output(["cmake", "."])
subprocess.check_output(["make"])
build.run(self)
class CustomDevelopCommand(develop):
"""Customized setuptools develop command """
def run(self):
# Can't assume a specific build command for Windows, so just build for Linux and Mac
if platform.system() in ['Darwin', 'Linux']:
# Make the host binary
with pushd("host/"):
subprocess.check_output(["cmake", "."])
subprocess.check_output(["make"])
develop.run(self)
setuptools.setup(
name="xscope_fileio",
version="1.2.0",
cmdclass={"build": CustomBuildCommand, "develop": CustomDevelopCommand,},
# Note for anyone trying to copy this pattern:
# package_data keys are NAMES OF PACKAGES, not dirs
# So it's "xscope_fileio" not "xscope_fileio/"
package_data={
"xscope_fileio": [
"../host/Makefile",
"../host/xscope_io_host.c",
"../host/xscope_host_endpoint",
]
},
packages=setuptools.find_packages(),
)