diff --git a/setup.py b/setup.py index 51eb6934c7706864b1ad2eaedf8ed0e90f619ec3..23e39cdf9c730703e6720b61df9fc5e14fbff6de 100644 --- a/setup.py +++ b/setup.py @@ -16,6 +16,12 @@ if not GSL_DIR: "Warning: GSL_DIR is not set, this might lead to errors along the installation if\ there is no other version of GSL in the include dirs" ) +BINARY_C_DIR = os.getenv("BINARY_C", None) +if not BINARY_C_DIR: + print("Error: the BINARY_C environment variable is not set. Aborting setup") + quit() + + # TODO: write code to know exact parent directory of this file. CWD = os.getcwd() @@ -25,7 +31,7 @@ CWD = os.getcwd() ############################################################ # binary_c must be installed. -BINARY_C_CONFIG = os.environ["BINARY_C"] + "/binary_c-config" +BINARY_C_CONFIG = os.path.join(BINARY_C_DIR, "binary_c-config") BINARY_C_INCDIRS = ( subprocess.run( @@ -62,9 +68,9 @@ DEFINES = ( .stdout.decode("utf-8") .split() ) + LONE = re.compile("^-D(.+)$") PARTNER = re.compile("^-D(.+)=(.+)$") - for x in DEFINES: y = PARTNER.match(x) if y: @@ -75,14 +81,18 @@ for x in DEFINES: BINARY_C_DEFINE_MACROS.extend([(y.group(1), None)]) # add API header file -API_h = os.environ["BINARY_C"] + "/src/API/binary_c_API.h" +API_h = os.path.join(BINARY_C_DIR, "src", "API", "binary_c_API.h") BINARY_C_DEFINE_MACROS.extend([("BINARY_C_API_H", API_h)]) ############################################################ # Setting all directories and LIBRARIES to their final values ############################################################ INCLUDE_DIRS = ( - [os.environ["BINARY_C"] + "/src", os.environ["BINARY_C"] + "/src/API", "include",] + [ + os.path.join(BINARY_C_DIR, "src"), + os.path.join(BINARY_C_DIR, "src", "API"), + "include", + ] + BINARY_C_INCDIRS + [os.path.join(GSL_DIR, "include")] if GSL_DIR @@ -92,14 +102,14 @@ INCLUDE_DIRS = ( LIBRARIES = ["binary_c"] + BINARY_C_LIBS + ["binary_c_api"] LIBRARY_DIRS = [ - os.environ["BINARY_C"] + "/src", + os.path.join(BINARY_C_DIR, "src"), "./", os.path.join(CWD, "lib/"), # os.path.join(CWD, "binarycpython/core/"), ] + BINARY_C_LIBDIRS RUNTIME_LIBRARY_DIRS = [ - os.environ["BINARY_C"] + "/src", + os.path.join(BINARY_C_DIR, "src"), "./", os.path.join(CWD, "lib/"), # os.path.join(CWD, "binarycpython/core/"), @@ -142,6 +152,10 @@ def readme(): with open("README.md") as file: return file.read() +def license(): + """Opens license file and returns the content""" + with open("LICENSE.md") as file: + return file.read() ############################################################ # Making the extension function @@ -152,7 +166,7 @@ setup( version="0.2", description="This is a python API for binary_c by David Hendriks, Rob Izzard and collaborators.\ Based on the initial set up by Jeff andrews", - author=" David Hendriks, Robert Izzard and Jeff Andrews", + author="David Hendriks, Robert Izzard and Jeff Andrews", author_email="davidhendriks93@gmail.com/d.hendriks@surrey.ac.uk,\ r.izzard@surrey.ac.uk/rob.izzard@gmail.com andrews@physics.uoc.gr", long_description=readme(),