From 01c54a579a0dd55234fea1a1bebdb966fe9e0b6c Mon Sep 17 00:00:00 2001 From: mikekatz04 Date: Fri, 15 Mar 2024 18:13:20 -0500 Subject: [PATCH] pip installable --- MANIFEST.in | 30 +++++++++++++++ pyproject.toml | 25 ++++++++++++ scripts/prebuild.py | 94 +++++++++++++++++++++++++++++++++++++++++++++ setup.py | 90 +------------------------------------------ 4 files changed, 150 insertions(+), 89 deletions(-) create mode 100644 MANIFEST.in create mode 100644 pyproject.toml create mode 100644 scripts/prebuild.py diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 0000000..8665e9b --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1,30 @@ +# Include the README +include README + +# Include the license file +include LICENCE +include THIRD.txt + +# Include dependencies +include requirements*.txt + +# Include makefile +include Makefile + +# Include docs +recursive-include docs + +# Include Changelog +include CHANGELOG + +# Include tests +recursive-include tests/testsuites * + +# Include scripts +recursive-include scripts * + +# Include tuto +include tutorial/*.ipynb + +# Include include files +include include/* diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..3b08b9f --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,25 @@ + +[build-system] +requires = ["setuptools", "wheel", "Cython", "numpy"] +build-backend = 'setuptools.build_meta' + +[tool.poetry] +name = "bbhx" +version = "1.0.7" +description = "A package for LISA Data Analysis" +license = "GPL" +classifiers = ["Programming Language :: Python :: 3", "Operating System :: OS Independent"] +homepage = "https://github.com/mikekatz04/LISAanalysistools" +authors = ["Michael L. Katz"] +readme = "README.md" + +[tool.poetry.dependencies] +python = "*" +# astropy = "==5.2.1" +# corner = "==2.2.1" +# healpy = "==1.16.2" +# "ligo.skymap" = "==1.0.4" +# matplotlib = "==3.6.3" +# pandas = "==1.5.2" +# seaborn = "==0.12.2" +# tables = "==3.8.0" diff --git a/scripts/prebuild.py b/scripts/prebuild.py new file mode 100644 index 0000000..30abc5c --- /dev/null +++ b/scripts/prebuild.py @@ -0,0 +1,94 @@ +import shutil +import requests + + +fps_cu_to_cpp = [ + "PhenomHM", + "Response", + "Interpolate", + "WaveformBuild", + "Likelihood", +] +fps_pyx = ["phenomhm", "response", "interpolate", "waveformbuild", "likelihood"] + +for fp in fps_cu_to_cpp: + shutil.copy("src/" + fp + ".cu", "src/" + fp + ".cpp") + +for fp in fps_pyx: + shutil.copy("src/" + fp + ".pyx", "src/" + fp + "_cpu.pyx") + + +# setup version file +with open("README.md", "r") as fh: + lines = fh.readlines() + +for line in lines: + if line.startswith("Current Version"): + version_string = line.split("Current Version: ")[1].split("\n")[0] + +with open("bbhx/_version.py", "w") as f: + f.write("__version__ = '{}'".format(version_string)) + + +initial_text_for_constants_file = """ +# Collection of citations for modules in bbhx package + +# Copyright (C) 2020 Michael L. Katz +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + + +""" + +initial_text_for_constants_file2 = """ + +Constants +******************************* + +The module :code:`bbhx.utils.constants` houses the constants used throughout the package. + +Constants list: + +""" + +fp_out_name = "bbhx/utils/constants.py" +fp_out_name2 = "docs/source/user/constants.rst" +fp_in_name = "include/constants.h" + +# develop few.utils.constants.py +with open(fp_out_name, "w") as fp_out: + with open(fp_out_name2, "w") as fp_out2: + fp_out.write(initial_text_for_constants_file) + fp_out2.write(initial_text_for_constants_file2) + with open(fp_in_name, "r") as fp_in: + lines = fp_in.readlines() + for line in lines: + if len(line.split()) == 3: + if line.split()[0] == "#define": + try: + _ = float(line.split()[2]) + string_out = ( + line.split()[1] + " = " + line.split()[2] + "\n" + ) + fp_out.write(string_out) + fp_out2.write(f"\t* {string_out}") + + except ValueError as e: + continue + +# for fp in fps_cu_to_cpp: +# os.remove("src/" + fp + ".cpp") + +# for fp in fps_pyx: +# os.remove("src/" + fp + "_cpu.pyx") diff --git a/setup.py b/setup.py index 2727a98..a444c9a 100644 --- a/setup.py +++ b/setup.py @@ -272,20 +272,6 @@ def build_extensions(self): ) # gpu_extensions.append(Extension(extension_name, **temp_dict)) -fps_cu_to_cpp = [ - "PhenomHM", - "Response", - "Interpolate", - "WaveformBuild", - "Likelihood", -] -fps_pyx = ["phenomhm", "response", "interpolate", "waveformbuild", "likelihood"] - -for fp in fps_cu_to_cpp: - shutil.copy("src/" + fp + ".cu", "src/" + fp + ".cpp") - -for fp in fps_pyx: - shutil.copy("src/" + fp + ".pyx", "src/" + fp + "_cpu.pyx") cpu_extension = dict( libraries=["gsl", "gslcblas", "gomp", "lapack"], @@ -329,63 +315,6 @@ def build_extensions(self): **cpu_extension, ) -initial_text_for_constants_file = """ -# Collection of citations for modules in bbhx package - -# Copyright (C) 2020 Michael L. Katz -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - - -""" - -initial_text_for_constants_file2 = """ - -Constants -******************************* - -The module :code:`bbhx.utils.constants` houses the constants used throughout the package. - -Constants list: - -""" - -fp_out_name = "bbhx/utils/constants.py" -fp_out_name2 = "docs/source/user/constants.rst" -fp_in_name = "include/constants.h" - -# develop few.utils.constants.py -with open(fp_out_name, "w") as fp_out: - with open(fp_out_name2, "w") as fp_out2: - fp_out.write(initial_text_for_constants_file) - fp_out2.write(initial_text_for_constants_file2) - with open(fp_in_name, "r") as fp_in: - lines = fp_in.readlines() - for line in lines: - if len(line.split()) == 3: - if line.split()[0] == "#define": - try: - _ = float(line.split()[2]) - string_out = ( - line.split()[1] + " = " + line.split()[2] + "\n" - ) - fp_out.write(string_out) - fp_out2.write(f"\t* {string_out}") - - except ValueError as e: - continue - extensions = [ pyPhenomHM_cpu_ext, @@ -404,17 +333,6 @@ def build_extensions(self): pyLikelihood_ext, ] + extensions -# setup version file -with open("README.md", "r") as fh: - lines = fh.readlines() - -for line in lines: - if line.startswith("Current Version"): - version_string = line.split("Current Version: ")[1].split("\n")[0] - -with open("bbhx/_version.py", "w") as f: - f.write("__version__ = '{}'".format(version_string)) - setup( name="bbhx", author="Michael Katz", @@ -425,12 +343,6 @@ def build_extensions(self): cmdclass={"build_ext": custom_build_ext}, # Since the package has c code, the egg cannot be zipped zip_safe=False, - version=version_string, + version="1.0.7", python_requires=">=3.6", ) - -for fp in fps_cu_to_cpp: - os.remove("src/" + fp + ".cpp") - -for fp in fps_pyx: - os.remove("src/" + fp + "_cpu.pyx")