Skip to content

Commit

Permalink
Add dirs
Browse files Browse the repository at this point in the history
  • Loading branch information
TLCFEM committed Dec 16, 2024
1 parent eb36496 commit 2251431
Showing 1 changed file with 26 additions and 11 deletions.
37 changes: 26 additions & 11 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,33 @@
"exprtk-custom-types",
]

def list_files(start_path):
for root, _, files in os.walk(start_path):
level = root.replace(start_path, "").count(os.sep)
indent = " " * 4 * (level)
print("{}{}/".format(indent, os.path.basename(root)))
sub_indent = " " * 4 * (level + 1)
for f in files:
print("{}{}".format(sub_indent, f))
library_dirs = []


if os.path.exists(mpfr_include := "/opt/homebrew/Cellar/mpfr"):
list_files(mpfr_include)
include_dirs.append(mpfr_include)
def add_to_include(target: str, header: str):
if not os.path.exists(target):
return

for root, _, files in os.walk(target):
if any(header in file for file in files):
include_dirs.append(root)
break


def add_to_library(target: str, header: str):
if not os.path.exists(target):
return

for root, _, files in os.walk(target):
if any(header in file for file in files):
library_dirs.append(root)
break

add_to_include("/opt/homebrew/Cellar/mpfr", "mpfr.h")
add_to_include("/opt/homebrew/Cellar/gmp", "gmp.h")

add_to_library("/opt/homebrew/Cellar/mpfr", "libmpfr")
add_to_library("/opt/homebrew/Cellar/gmp", "libgmp")

# noinspection PyTypeChecker
setup(
Expand All @@ -42,6 +56,7 @@ def list_files(start_path):
"_pyvpmr",
["src/VPMR.cpp"],
include_dirs=include_dirs,
library_dirs=library_dirs,
libraries=["mpfr", "gmp", "tbb"],
define_macros=[("PYVPMR", 1)],
extra_compile_args=["-fno-aligned-allocation"]
Expand Down

0 comments on commit 2251431

Please sign in to comment.