From 7ed811fb690cab897d69b954fb9a79212fdf9919 Mon Sep 17 00:00:00 2001
From: David Hendriks <davidhendriks93@gmail.com>
Date: Wed, 2 Dec 2020 15:16:54 +0000
Subject: [PATCH] Updatig the files for packaging

---
 MANIFEST.in |  2 ++
 Makefile    |  4 ++++
 setup.py    | 63 +++++++++++++++++++++++++++++++----------------------
 3 files changed, 43 insertions(+), 26 deletions(-)

diff --git a/MANIFEST.in b/MANIFEST.in
index 2b0b5ab53..e1a62886c 100644
--- a/MANIFEST.in
+++ b/MANIFEST.in
@@ -1 +1,3 @@
 include Makefile
+include src/*.c
+include include/*.h
\ No newline at end of file
diff --git a/Makefile b/Makefile
index 4c2da1774..c59bda01b 100644
--- a/Makefile
+++ b/Makefile
@@ -23,6 +23,7 @@ CC      			:= gcc
 LD      			:= gcc
 MAKE    			:= /usr/bin/make
 MKDIR_P 			:= mkdir -p
+PWD 				:= pwd
 
 # Libraries
 LIBS 				:= -lbinary_c $(shell $(BINARY_C)/binary_c-config --libs)
@@ -41,6 +42,7 @@ OBJ_FLAGS 			:= -c
 # Shared lib files and flags
 SO_NAME 			:= $(TARGET_LIB_DIR)/libbinary_c_python_api.so
 SO_FLAGS 			:= -shared
+SO_NAME_EXTRA 		:= binarycpython/libbinary_c_python_api.so
 
 all: create_directories create_objects create_library
 
@@ -57,7 +59,9 @@ create_objects_debug:
 	$(CC) -DBINARY_C=$(BINARY_C) -DBINARY_C_PYTHON_DEBUG $(CFLAGS) $(INCDIRS) $(C_SRC) -o $(OBJECTS) $(OBJ_FLAGS) $(LIBS) 
 
 create_library:
+	@echo $(PWD)
 	$(CC) -DBINARY_C=$(BINARY_C) $(SO_FLAGS) -o $(SO_NAME) $(OBJECTS)
+	$(CC) -DBINARY_C=$(BINARY_C) $(SO_FLAGS) -o $(SO_NAME_EXTRA) $(OBJECTS)
 
 create_library_debug:
 	$(CC) -DBINARY_C=$(BINARY_C) -DBINARY_C_PYTHON_DEBUG $(SO_FLAGS) -o $(SO_NAME) $(OBJECTS)
diff --git a/setup.py b/setup.py
index 9397399c4..a02b81944 100644
--- a/setup.py
+++ b/setup.py
@@ -11,15 +11,21 @@ import setuptools
 from distutils.core import setup, Extension
 import distutils.command.build
 
-# TODO: replace the tasks that call binary_c-config with a single function that handles the return status a bit better. 
+# TODO: replace the tasks that call binary_c-config with a single function that handles the return status a bit better.
 
 # Functions
 def readme():
     """Opens readme file and returns content"""
-    with open("README.md") as file:
+    with open("README") as file:
         return file.read()
 
 
+# def readme_rst():
+#     """Opens readme file and returns contents converted to rst"""
+#     with open("README.md") as file:
+#         return md_to_rst.convertMarkdownToRst(file.read())
+
+
 def license():
     """Opens license file and returns the content"""
     with open("LICENSE.md") as file:
@@ -37,6 +43,7 @@ def check_version(installed_binary_c_version, required_binary_c_versions):
     )
     assert installed_binary_c_version in required_binary_c_versions, message
 
+
 def execute_make():
     """
     Function to execute the makefile. 
@@ -48,12 +55,12 @@ def execute_make():
     make_command = ["make"]
 
     p = subprocess.run(make_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
-    stdout = p.stdout # stdout = normal output
-    stderr = p.stderr # stderr = error output
+    stdout = p.stdout  # stdout = normal output
+    stderr = p.stderr  # stderr = error output
 
     if p.returncode != 0:
         print("Something went wrong when executing the makefile:")
-        print(stderr.decode('utf-8'))
+        print(stderr.decode("utf-8"))
         print("Aborting")
         sys.exit(-1)
 
@@ -62,7 +69,6 @@ def execute_make():
         print("Successfully built the libbinary_c_api.so")
 
 
-
 ###
 REQUIRED_BINARY_C_VERSIONS = ["2.1.7"]
 
@@ -160,12 +166,14 @@ INCLUDE_DIRS = (
     else []
 )
 
-LIBRARIES = ["binary_c"] + BINARY_C_LIBS + ["binary_c_python_api"]
+# LIBRARIES = ["binary_c"] + BINARY_C_LIBS + ["binary_c_python_api"]
+LIBRARIES = ["binary_c"] + BINARY_C_LIBS
 
 LIBRARY_DIRS = [
     os.path.join(BINARY_C_DIR, "src"),
     "./",
     os.path.join(CWD, "lib/"),
+    os.path.join(CWD, "binarycpython/"),
 ] + BINARY_C_LIBDIRS
 
 RUNTIME_LIBRARY_DIRS = [
@@ -181,7 +189,7 @@ LIBRARIES = list(dict.fromkeys(LIBRARIES))
 LIBRARY_DIRS = list(dict.fromkeys(LIBRARY_DIRS))
 RUNTIME_LIBRARY_DIRS = list(dict.fromkeys(RUNTIME_LIBRARY_DIRS))
 
-# 
+#
 # print('\n')
 # print("BINARY_C_CONFIG: ", str(BINARY_C_CONFIG) + "\n")
 # print("incdirs: ", str(INCLUDE_DIRS) + "\n")
@@ -219,44 +227,49 @@ BINARY_C_PYTHON_API_MODULE = Extension(
 
 # Override build command
 class CustomBuildCommand(distutils.command.build.build):
-
     def run(self):
-        execute_make()
+        # execute_make()
 
         # Run the original build command
         # print(super().run())
         distutils.command.build.build.run(self)
 
+
 setup(
     name="binarycpython",
-    version="0.2",
+    version="0.2.1",
     description="""
-    This is a python API for binary_c (versions {}) by David Hendriks, Rob Izzard and collaborators.
-    Based on the initial set up by Jeff andrews.
-    It is tested and designed to work for versions {}, we can't guarantee proper functioning for other versions
-
-    If you want to use a different version of binary_c, download and install a different version of this package
-    """.format(
-        str(REQUIRED_BINARY_C_VERSIONS), str(REQUIRED_BINARY_C_VERSIONS)
+This is a python API for binary_c (versions {}) by David Hendriks, Rob Izzard and collaborators.
+Based on the initial set up by Jeff andrews.
+It is tested and designed to work for versions {}, we can't guarantee proper functioning for other versions
+
+If you want to use a different version of binary_c, download and install a different version of this package
+""".format(
+        ",".join(str(REQUIRED_BINARY_C_VERSIONS)),
+        ",".join(str(REQUIRED_BINARY_C_VERSIONS)),
     ),
     author="David Hendriks",
     author_email="davidhendriks93@gmail.com",
-    long_description_content_type='text/markdown',
-    long_description=readme(),
+    # long_description=readme(),
+    long_description="hello",
     url="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c-python",
     license="gpl",
-    keywords = ['binary_c', 'astrophysics', 'stellar evolution', 'population synthesis'],   # Keywords that define your package best
+    keywords=[
+        "binary_c",
+        "astrophysics",
+        "stellar evolution",
+        "population synthesis",
+    ],  # Keywords that define your package best
     packages=[
         "binarycpython",
         "binarycpython.utils",
         "binarycpython.core",
         "binarycpython.tests",
-        "binarycpython.tests.core",
+        "binarycpython.tests.c_bindings",
     ],
     install_requires=["numpy", "pytest", "h5py"],
     include_package_data=True,
     ext_modules=[BINARY_C_PYTHON_API_MODULE],  # binary_c must be loaded
-
     classifiers=[
         "Development Status :: 3 - Alpha",
         "License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)",
@@ -269,7 +282,5 @@ setup(
         "Topic :: Scientific/Engineering :: Physics",
         "Topic :: Software Development :: Libraries :: Python Modules",
     ],
-
-    cmdclass={'build': CustomBuildCommand},
-
+    cmdclass={"build": CustomBuildCommand},
 )
-- 
GitLab