-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
51 lines (43 loc) · 1.72 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
from collections import defaultdict
from setuptools import setup
from pybind11.setup_helpers import Pybind11Extension
from setuptools.command.build_ext import build_ext
from pathlib import Path
long_description = (Path(__file__).parent / "README.md").read_text()
UNIX_BUILD_ARGS = ["-O3", "-g0", "-s", "--std=c++14",
"-fvisibility=hidden", "-flto", "-fno-fat-lto-objects"]
BUILD_ARGS = defaultdict(lambda: UNIX_BUILD_ARGS)
BUILD_ARGS["msvc"] = ["/O3", "/DNDEBUG", "/arch:AVX"]
BUILD_ARGS["unix"] = UNIX_BUILD_ARGS
UNIX_LINK_ARGS = ["-flto", "-fno-fat-lto-objects"]
GCC_STRIP_FLAG = "-Wl,--strip-all"
LINK_ARGS = defaultdict(lambda: UNIX_LINK_ARGS)
LINK_ARGS["msvc"] = []
LINK_ARGS["unix"] = UNIX_LINK_ARGS
class CustomBuildExt(build_ext):
def build_extensions(self):
compiler = self.compiler.compiler_type
build_args = BUILD_ARGS[compiler]
link_args = LINK_ARGS[compiler]
for ext in self.extensions:
ext.extra_link_args = link_args
ext.extra_compile_args = build_args
if hasattr(self.compiler, "compiler") and self.compiler.compiler[0].endswith("gcc"):
ext.extra_link_args.append(GCC_STRIP_FLAG)
build_ext.build_extensions(self)
ext_modules = [
Pybind11Extension(
"pywuffs",
["src/wuffs-bindings.cpp"],
include_dirs=["libs/wuffs/release/c"]
),
]
setup(name="pywuffs",
version="2.0.0",
description="Python bindings for Wuffs the Library",
author="Georgiy Manuilov",
url="https://github.com/dev0x13/pywuffs",
cmdclass={"build_ext": CustomBuildExt},
long_description=long_description,
long_description_content_type="text/markdown",
ext_modules=ext_modules)