-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
43 lines (36 loc) · 1.28 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
import os
from setuptools.command.build_ext import build_ext
from setuptools import setup, Extension, find_packages
from pathlib import Path
csdfgen = Extension("csdfgen", sources=[], depends=["src/c/sdfgen.h"], include_dirs=["src/c/"])
class ZigBuilder(build_ext):
def build_extension(self, ext):
modpath = self.get_ext_fullpath(ext.name).split('/')
modpath = os.path.abspath('/'.join(modpath[0:-1]))
args = [
"zig",
"build",
"c",
"-Doptimize=ReleaseSafe",
"-Dc-dynamic=true",
f"-Dcsdfgen-emit={self.get_ext_filename(ext.name)}",
"--prefix-lib-dir",
f"{modpath}",
]
self.spawn(args)
setup(
name="sdfgen",
version="0.2.0",
url="https://github.com/au-ts/microkit_sdf_gen",
description="Automating the creation of Microkit System Description Files (SDF)",
packages=["sdfgen"],
package_dir={
"sdfgen": "./python"
},
# Necessary for mypy to work for those that import the package
package_data={"sdfgen": ["py.typed"]},
ext_modules=[csdfgen],
cmdclass={"build_ext": ZigBuilder},
long_description=(Path(__file__).parent / "README.md").read_text(encoding="utf-8"),
long_description_content_type="text/markdown",
)