Skip to content

parse g6k.pc for a prefix to use #107

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,4 @@ stamp-h1
/ltmain.sh
/libtool
/test-driver
/g6k.egg-info/
10 changes: 6 additions & 4 deletions kernel/g6k_config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,6 @@
/* Define to 1 if you have the <inttypes.h> header file. */
#undef HAVE_INTTYPES_H

/* Define to 1 if you have the <memory.h> header file. */
#undef HAVE_MEMORY_H

/* Define to 1 to support Multimedia Extensions */
#undef HAVE_MMX

Expand Down Expand Up @@ -136,6 +133,9 @@
/* Define to 1 if you have the <stdint.h> header file. */
#undef HAVE_STDINT_H

/* Define to 1 if you have the <stdio.h> header file. */
#undef HAVE_STDIO_H

/* Define to 1 if you have the <stdlib.h> header file. */
#undef HAVE_STDLIB_H

Expand Down Expand Up @@ -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 */
Expand Down
21 changes: 19 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,23 @@
# `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:
subprocess.check_call(["./configure", f"--prefix={prefix}"])
else:
subprocess.check_call("./configure")

#
# But we only run `make` as part of `build_ext`
Expand Down Expand Up @@ -83,6 +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"]
if prefix:
extra_compile_args += [f"-L{prefix}/lib"]

kwds = {
"language": "c++",
Expand All @@ -96,6 +109,10 @@ def read_from(filename, field, sep):
"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),
Expand Down