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

updated setup, included a script that checks the version of binary_c vs the required function

parent 2b463b04
No related branches found
No related tags found
No related merge requests found
......@@ -10,6 +10,29 @@ import os
import subprocess
import re
# Functions
def readme():
"""Opens readme file and returns content"""
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()
def check_version(installed_binary_c_version, required_binary_c_version):
"""Function to check the installed version and compare it to the required version"""
message = """
The binary_c version that is installed ({}) does not match the binary_c version ({})
that this release of the binary_c python module requires.
""".format(installed_binary_c_version, required_binary_c_version)
assert installed_binary_c_version == required_binary_c_version, message
###
REQUIRED_BINARY_C_VERSION = '2.1.7'
####
GSL_DIR = os.getenv("GSL_DIR", None)
if not GSL_DIR:
print(
......@@ -21,8 +44,6 @@ 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()
......@@ -33,6 +54,15 @@ CWD = os.getcwd()
# binary_c must be installed.
BINARY_C_CONFIG = os.path.join(BINARY_C_DIR, "binary_c-config")
BINARY_C_VERSION = (
subprocess.run(
[BINARY_C_CONFIG, "version"], stdout=subprocess.PIPE, check=True
)
.stdout.decode("utf-8")
.split()
)
check_version(BINARY_C_VERSION[0], REQUIRED_BINARY_C_VERSION)
BINARY_C_INCDIRS = (
subprocess.run(
[BINARY_C_CONFIG, "incdirs_list"], stdout=subprocess.PIPE, check=True
......@@ -146,17 +176,6 @@ BINARY_C_PYTHON_API_MODULE = Extension(
language="C",
)
def readme():
"""Opens readme file and returns content"""
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
############################################################
......@@ -164,8 +183,14 @@ def license():
setup(
name="binarycpython",
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",
description="""
This is a python API for binary_c (version {})by David Hendriks, Rob Izzard and collaborators.
Based on the initial set up by Jeff andrews.
It is tested and designed to work for version {}, 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(REQUIRED_BINARY_C_VERSION, REQUIRED_BINARY_C_VERSION),
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",
......
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