-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsetup.py
More file actions
102 lines (88 loc) · 3.48 KB
/
setup.py
File metadata and controls
102 lines (88 loc) · 3.48 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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os
import re
import shutil
import sys
from distutils import log
import pybind11
from setuptools import Extension, find_packages, setup
from setuptools.command.build_ext import build_ext
POGA_VERSION = "0.1.19"
# obtain workdir
here = os.path.abspath(os.path.dirname(__file__))
class BuildExt(build_ext):
c_opts = {
"msvc": ["/EHsc", "/std:c++17"],
"unix": ["-std=c++17"],
}
if sys.platform == "darwin":
c_opts["unix"] += ["-stdlib=libc++", "-mmacosx-version-min=10.7"]
def build_extensions(self):
ct = self.compiler.compiler_type
opts = self.c_opts.get(ct, [])
for ext in self.extensions:
ext.extra_compile_args = opts
build_ext.build_extensions(self)
def run(self):
build_ext.run(self)
self.copy_shared_libs_to_src()
def copy_shared_libs_to_src(self):
for ext in self.extensions:
full_path = self.get_ext_fullpath(ext.name)
target_dir = os.path.join(here, "src", "poga")
if not os.path.exists(target_dir):
os.makedirs(target_dir)
target_path = os.path.join(target_dir, os.path.basename(full_path))
log.info("Copying %s -> %s", full_path, target_path)
shutil.copyfile(full_path, target_path)
ext_modules = [
Extension(
"poga.libpoga_capi",
[
os.path.join("src", "poga", "capi", "poga_cmodule.cpp"),
os.path.join("src", "poga", "capi", "poga_manager.cpp"),
# Yoga src
os.path.join("src", "poga", "deps", "yoga", "event", "event.cpp"),
os.path.join("src", "poga", "deps", "yoga", "internal", "experiments.cpp"),
os.path.join("src", "poga", "deps", "yoga", "log.cpp"),
os.path.join("src", "poga", "deps", "yoga", "Utils.cpp"),
os.path.join("src", "poga", "deps", "yoga", "YGConfig.cpp"),
os.path.join("src", "poga", "deps", "yoga", "YGEnums.cpp"),
os.path.join("src", "poga", "deps", "yoga", "YGLayout.cpp"),
os.path.join("src", "poga", "deps", "yoga", "YGNode.cpp"),
os.path.join("src", "poga", "deps", "yoga", "YGNodePrint.cpp"),
os.path.join("src", "poga", "deps", "yoga", "YGStyle.cpp"),
os.path.join("src", "poga", "deps", "yoga", "YGValue.cpp"),
os.path.join("src", "poga", "deps", "yoga", "Yoga.cpp"),
],
define_macros=[
("POGA_VERSION_MAJOR", POGA_VERSION.split(".")[0]),
("POGA_VERSION_MINOR", POGA_VERSION.split(".")[1]),
("POGA_VERSION_MICRO", POGA_VERSION.split(".")[2]),
],
include_dirs=[
pybind11.get_include(False),
pybind11.get_include(True),
os.path.join(here, "src", "poga", "deps"),
os.path.join(here, "src", "poga", "deps", "yoga"),
os.path.join(here, "src", "poga", "deps", "yoga", "event"),
os.path.join(here, "src", "poga", "deps", "yoga", "internal"),
os.path.join(here, "src", "poga", "capi"),
],
language="c++",
),
]
if __name__ == "__main__":
if len(sys.argv) == 1:
sys.argv.append("bdist_wheel")
setup(
name="poga",
version=POGA_VERSION,
package_dir={"": "src"},
packages=find_packages(where="src"),
ext_modules=ext_modules,
install_requires=["pybind11>=2.2.0"],
cmdclass={"build_ext": BuildExt},
zip_safe=False,
)