From 9b6c326aaa081b9f1a85db5b1de165fd0048a147 Mon Sep 17 00:00:00 2001 From: "Martin R. Albrecht" Date: Sat, 16 Jul 2022 15:25:55 +0100 Subject: [PATCH 1/3] parse g6k.pc for a prefix to use --- .gitignore | 1 + kernel/g6k_config.h.in | 10 ++++++---- setup.py | 1 + 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 4c4c039e..1639dd47 100644 --- a/.gitignore +++ b/.gitignore @@ -47,3 +47,4 @@ stamp-h1 /ltmain.sh /libtool /test-driver +/g6k.egg-info/ diff --git a/kernel/g6k_config.h.in b/kernel/g6k_config.h.in index a015e31f..bb94da9a 100644 --- a/kernel/g6k_config.h.in +++ b/kernel/g6k_config.h.in @@ -88,9 +88,6 @@ /* Define to 1 if you have the header file. */ #undef HAVE_INTTYPES_H -/* Define to 1 if you have the header file. */ -#undef HAVE_MEMORY_H - /* Define to 1 to support Multimedia Extensions */ #undef HAVE_MMX @@ -136,6 +133,9 @@ /* Define to 1 if you have the header file. */ #undef HAVE_STDINT_H +/* Define to 1 if you have the header file. */ +#undef HAVE_STDIO_H + /* Define to 1 if you have the header file. */ #undef HAVE_STDLIB_H @@ -191,7 +191,9 @@ your system. */ #undef PTHREAD_CREATE_JOINABLE -/* Define to 1 if you have the ANSI C header files. */ +/* Define to 1 if all of the C90 standard headers exist (not just the ones + required in a freestanding environment). This macro is provided for + backward compatibility; new code need not use it. */ #undef STDC_HEADERS /* enable templated dimensions */ diff --git a/setup.py b/setup.py index 09d24c4d..30c91b15 100755 --- a/setup.py +++ b/setup.py @@ -83,6 +83,7 @@ def read_from(filename, field, sep): # extra_compile_args += ["-DCYTHON_TRACE=1"] # there's so many warnings generated here, we need to filter out -Werror extra_compile_args += [opt for opt in read_from("g6k.pc", "Cflags", ": ") if opt != "-Werror"] +extra_compile_args += [f"-L{opt}/lib" for opt in read_from("g6k.pc", "prefix", "=")] kwds = { "language": "c++", From e5e71c6f65b4a9d659b3f4dcf5b888c632197c3c Mon Sep 17 00:00:00 2001 From: "Martin R. Albrecht" Date: Sat, 16 Jul 2022 16:41:33 +0100 Subject: [PATCH 2/3] maybe this? --- setup.py | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/setup.py b/setup.py index 30c91b15..c8a5396a 100755 --- a/setup.py +++ b/setup.py @@ -39,18 +39,28 @@ # `setup,py` consumes files output by `configure` so we insist on running it first. # +if "CONDA_PREFIX" in os.environ: + prefix = os.environ["CONDA_PREFIX"] +elif "VIRTUAL_ENV" in os.environ: + prefix = os.environ["VIRTUAL_ENV"] +elif "LD_LIBRARY_PATH" in os.environ and os.environ["LD_LIBRARY_PATH"].endswith("/lib"): + prefix = os.environ["LD_LIBRARY_PATH"][:-4] +else: + prefix = None + if not os.path.exists("configure"): subprocess.check_call(["autoreconf", "-i"]) if not os.path.exists("Makefile"): - subprocess.check_call("./configure") - + if prefix is not None: + subprocess.check_call(["./configure", f"--prefix={prefix}"]) + else: + subprocess.check_call("./configure") # # But we only run `make` as part of `build_ext` # - class build_ext(build_module.build_ext): def run(self): @@ -83,7 +93,7 @@ def read_from(filename, field, sep): # extra_compile_args += ["-DCYTHON_TRACE=1"] # there's so many warnings generated here, we need to filter out -Werror extra_compile_args += [opt for opt in read_from("g6k.pc", "Cflags", ": ") if opt != "-Werror"] -extra_compile_args += [f"-L{opt}/lib" for opt in read_from("g6k.pc", "prefix", "=")] +extra_compile_args += [f"-L{prefix}/lib"] kwds = { "language": "c++", @@ -94,6 +104,7 @@ def read_from(filename, field, sep): for fn in read_from("kernel/Makefile.am", "libg6k_la_SOURCES", "=") ], "libraries": ["gmp", "pthread"], + "library_dirs": [f"{prefix}/lib"], "include_dirs": [numpy.get_include()], } From 27beabb2a8a18f1b45ad11e3051e17a16d3f9893 Mon Sep 17 00:00:00 2001 From: "Martin R. Albrecht" Date: Sat, 16 Jul 2022 19:43:20 +0100 Subject: [PATCH 3/3] handle prefix=None --- setup.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/setup.py b/setup.py index c8a5396a..89c6d4de 100755 --- a/setup.py +++ b/setup.py @@ -52,7 +52,7 @@ subprocess.check_call(["autoreconf", "-i"]) if not os.path.exists("Makefile"): - if prefix is not None: + if prefix: subprocess.check_call(["./configure", f"--prefix={prefix}"]) else: subprocess.check_call("./configure") @@ -61,6 +61,7 @@ # But we only run `make` as part of `build_ext` # + class build_ext(build_module.build_ext): def run(self): @@ -93,7 +94,8 @@ def read_from(filename, field, sep): # extra_compile_args += ["-DCYTHON_TRACE=1"] # there's so many warnings generated here, we need to filter out -Werror extra_compile_args += [opt for opt in read_from("g6k.pc", "Cflags", ": ") if opt != "-Werror"] -extra_compile_args += [f"-L{prefix}/lib"] +if prefix: + extra_compile_args += [f"-L{prefix}/lib"] kwds = { "language": "c++", @@ -104,10 +106,13 @@ def read_from(filename, field, sep): for fn in read_from("kernel/Makefile.am", "libg6k_la_SOURCES", "=") ], "libraries": ["gmp", "pthread"], - "library_dirs": [f"{prefix}/lib"], "include_dirs": [numpy.get_include()], } +if prefix: + kwds["library_dirs"] = [f"{prefix}/lib"] + + extensions = [ Extension("g6k.siever", ["g6k/siever.pyx"], **kwds), Extension("g6k.siever_params", ["g6k/siever_params.pyx"], **kwds),