Skip to content
Snippets Groups Projects
Commit 7ed811fb authored by David Hendriks's avatar David Hendriks
Browse files

Updatig the files for packaging

parent 50250d93
No related branches found
No related tags found
No related merge requests found
include Makefile include Makefile
include src/*.c
include include/*.h
\ No newline at end of file
...@@ -23,6 +23,7 @@ CC := gcc ...@@ -23,6 +23,7 @@ CC := gcc
LD := gcc LD := gcc
MAKE := /usr/bin/make MAKE := /usr/bin/make
MKDIR_P := mkdir -p MKDIR_P := mkdir -p
PWD := pwd
# Libraries # Libraries
LIBS := -lbinary_c $(shell $(BINARY_C)/binary_c-config --libs) LIBS := -lbinary_c $(shell $(BINARY_C)/binary_c-config --libs)
...@@ -41,6 +42,7 @@ OBJ_FLAGS := -c ...@@ -41,6 +42,7 @@ OBJ_FLAGS := -c
# Shared lib files and flags # Shared lib files and flags
SO_NAME := $(TARGET_LIB_DIR)/libbinary_c_python_api.so SO_NAME := $(TARGET_LIB_DIR)/libbinary_c_python_api.so
SO_FLAGS := -shared SO_FLAGS := -shared
SO_NAME_EXTRA := binarycpython/libbinary_c_python_api.so
all: create_directories create_objects create_library all: create_directories create_objects create_library
...@@ -57,7 +59,9 @@ create_objects_debug: ...@@ -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) $(CC) -DBINARY_C=$(BINARY_C) -DBINARY_C_PYTHON_DEBUG $(CFLAGS) $(INCDIRS) $(C_SRC) -o $(OBJECTS) $(OBJ_FLAGS) $(LIBS)
create_library: 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) $(OBJECTS)
$(CC) -DBINARY_C=$(BINARY_C) $(SO_FLAGS) -o $(SO_NAME_EXTRA) $(OBJECTS)
create_library_debug: create_library_debug:
$(CC) -DBINARY_C=$(BINARY_C) -DBINARY_C_PYTHON_DEBUG $(SO_FLAGS) -o $(SO_NAME) $(OBJECTS) $(CC) -DBINARY_C=$(BINARY_C) -DBINARY_C_PYTHON_DEBUG $(SO_FLAGS) -o $(SO_NAME) $(OBJECTS)
......
...@@ -11,15 +11,21 @@ import setuptools ...@@ -11,15 +11,21 @@ import setuptools
from distutils.core import setup, Extension from distutils.core import setup, Extension
import distutils.command.build 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 # Functions
def readme(): def readme():
"""Opens readme file and returns content""" """Opens readme file and returns content"""
with open("README.md") as file: with open("README") as file:
return file.read() 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(): def license():
"""Opens license file and returns the content""" """Opens license file and returns the content"""
with open("LICENSE.md") as file: with open("LICENSE.md") as file:
...@@ -37,6 +43,7 @@ def check_version(installed_binary_c_version, required_binary_c_versions): ...@@ -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 assert installed_binary_c_version in required_binary_c_versions, message
def execute_make(): def execute_make():
""" """
Function to execute the makefile. Function to execute the makefile.
...@@ -48,12 +55,12 @@ def execute_make(): ...@@ -48,12 +55,12 @@ def execute_make():
make_command = ["make"] make_command = ["make"]
p = subprocess.run(make_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE) p = subprocess.run(make_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
stdout = p.stdout # stdout = normal output stdout = p.stdout # stdout = normal output
stderr = p.stderr # stderr = error output stderr = p.stderr # stderr = error output
if p.returncode != 0: if p.returncode != 0:
print("Something went wrong when executing the makefile:") print("Something went wrong when executing the makefile:")
print(stderr.decode('utf-8')) print(stderr.decode("utf-8"))
print("Aborting") print("Aborting")
sys.exit(-1) sys.exit(-1)
...@@ -62,7 +69,6 @@ def execute_make(): ...@@ -62,7 +69,6 @@ def execute_make():
print("Successfully built the libbinary_c_api.so") print("Successfully built the libbinary_c_api.so")
### ###
REQUIRED_BINARY_C_VERSIONS = ["2.1.7"] REQUIRED_BINARY_C_VERSIONS = ["2.1.7"]
...@@ -160,12 +166,14 @@ INCLUDE_DIRS = ( ...@@ -160,12 +166,14 @@ INCLUDE_DIRS = (
else [] 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 = [ LIBRARY_DIRS = [
os.path.join(BINARY_C_DIR, "src"), os.path.join(BINARY_C_DIR, "src"),
"./", "./",
os.path.join(CWD, "lib/"), os.path.join(CWD, "lib/"),
os.path.join(CWD, "binarycpython/"),
] + BINARY_C_LIBDIRS ] + BINARY_C_LIBDIRS
RUNTIME_LIBRARY_DIRS = [ RUNTIME_LIBRARY_DIRS = [
...@@ -181,7 +189,7 @@ LIBRARIES = list(dict.fromkeys(LIBRARIES)) ...@@ -181,7 +189,7 @@ LIBRARIES = list(dict.fromkeys(LIBRARIES))
LIBRARY_DIRS = list(dict.fromkeys(LIBRARY_DIRS)) LIBRARY_DIRS = list(dict.fromkeys(LIBRARY_DIRS))
RUNTIME_LIBRARY_DIRS = list(dict.fromkeys(RUNTIME_LIBRARY_DIRS)) RUNTIME_LIBRARY_DIRS = list(dict.fromkeys(RUNTIME_LIBRARY_DIRS))
# #
# print('\n') # print('\n')
# print("BINARY_C_CONFIG: ", str(BINARY_C_CONFIG) + "\n") # print("BINARY_C_CONFIG: ", str(BINARY_C_CONFIG) + "\n")
# print("incdirs: ", str(INCLUDE_DIRS) + "\n") # print("incdirs: ", str(INCLUDE_DIRS) + "\n")
...@@ -219,44 +227,49 @@ BINARY_C_PYTHON_API_MODULE = Extension( ...@@ -219,44 +227,49 @@ BINARY_C_PYTHON_API_MODULE = Extension(
# Override build command # Override build command
class CustomBuildCommand(distutils.command.build.build): class CustomBuildCommand(distutils.command.build.build):
def run(self): def run(self):
execute_make() # execute_make()
# Run the original build command # Run the original build command
# print(super().run()) # print(super().run())
distutils.command.build.build.run(self) distutils.command.build.build.run(self)
setup( setup(
name="binarycpython", name="binarycpython",
version="0.2", version="0.2.1",
description=""" description="""
This is a python API for binary_c (versions {}) by David Hendriks, Rob Izzard and collaborators. 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. 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 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 If you want to use a different version of binary_c, download and install a different version of this package
""".format( """.format(
str(REQUIRED_BINARY_C_VERSIONS), str(REQUIRED_BINARY_C_VERSIONS) ",".join(str(REQUIRED_BINARY_C_VERSIONS)),
",".join(str(REQUIRED_BINARY_C_VERSIONS)),
), ),
author="David Hendriks", author="David Hendriks",
author_email="davidhendriks93@gmail.com", 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", url="https://gitlab.eps.surrey.ac.uk/ri0005/binary_c-python",
license="gpl", 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=[ packages=[
"binarycpython", "binarycpython",
"binarycpython.utils", "binarycpython.utils",
"binarycpython.core", "binarycpython.core",
"binarycpython.tests", "binarycpython.tests",
"binarycpython.tests.core", "binarycpython.tests.c_bindings",
], ],
install_requires=["numpy", "pytest", "h5py"], install_requires=["numpy", "pytest", "h5py"],
include_package_data=True, include_package_data=True,
ext_modules=[BINARY_C_PYTHON_API_MODULE], # binary_c must be loaded ext_modules=[BINARY_C_PYTHON_API_MODULE], # binary_c must be loaded
classifiers=[ classifiers=[
"Development Status :: 3 - Alpha", "Development Status :: 3 - Alpha",
"License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)", "License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)",
...@@ -269,7 +282,5 @@ setup( ...@@ -269,7 +282,5 @@ setup(
"Topic :: Scientific/Engineering :: Physics", "Topic :: Scientific/Engineering :: Physics",
"Topic :: Software Development :: Libraries :: Python Modules", "Topic :: Software Development :: Libraries :: Python Modules",
], ],
cmdclass={"build": CustomBuildCommand},
cmdclass={'build': CustomBuildCommand},
) )
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment