-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.py
More file actions
78 lines (69 loc) · 2.21 KB
/
Copy pathsetup.py
File metadata and controls
78 lines (69 loc) · 2.21 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
# -*- coding: utf-8 -*- vim:sw=2
import os, setuptools, subprocess
from setuptools import Extension
from setuptools.command.build_ext import build_ext as st_build_ext
name = "sollya"
# Homebrew paths
include_dirs = []
library_dirs = []
for p in ["/opt/homebrew/include", "/usr/local/include"]:
if os.path.isdir(p):
include_dirs.append(p)
for p in ["/opt/homebrew/lib", "/usr/local/lib"]:
if os.path.isdir(p):
library_dirs.append(p)
# Also check for sollya-specific Cellar path
sollya_cellar = "/opt/homebrew/Cellar/sollya/8.0_3"
if os.path.isdir(sollya_cellar):
inc = os.path.join(sollya_cellar, "include")
lib = os.path.join(sollya_cellar, "lib")
if os.path.isdir(inc) and inc not in include_dirs:
include_dirs.append(inc)
if os.path.isdir(lib) and lib not in library_dirs:
library_dirs.append(lib)
extensions = [
Extension(
name,
[name + ".pyx"],
libraries=["sollya"],
include_dirs=include_dirs,
library_dirs=library_dirs,
),
Extension(
"sollya_extra_functions",
["sollya_extra_functions.pyx"],
libraries=["sollya"],
include_dirs=include_dirs,
library_dirs=library_dirs,
),
]
class build_ext(st_build_ext, object):
def finalize_options(self):
# Set env vars for gen_ops.py which uses cpp
cppflags = os.environ.get("CPPFLAGS", "")
for d in include_dirs:
cppflags += " -I" + d
os.environ["CPPFLAGS"] = cppflags
ldflags = os.environ.get("LDFLAGS", "")
for d in library_dirs:
ldflags += " -L" + d
os.environ["LDFLAGS"] = ldflags
subprocess.call(["make", "-C", os.path.dirname(os.path.abspath(__file__)), "generated"])
from Cython.Build.Dependencies import cythonize
self.distribution.ext_modules[:] = cythonize(
self.distribution.ext_modules,
language_level="3")
super(build_ext, self).finalize_options()
setuptools.setup(
name=name,
ext_modules=extensions,
version="0.4.0",
description="Cython wrapper for the Sollya library",
url="https://gitlab.com/metalibm-dev/pythonsollya",
author="Nicolas Brunie, Marc Mezzarobba",
license="CeCILL-C V2.1",
author_email="nicolas.brunie@kalray.eu",
setup_requires=["cython"],
install_requires=[],
cmdclass = {"build_ext": build_ext},
)