Skip to content

Commit

Permalink
pip installable
Browse files Browse the repository at this point in the history
  • Loading branch information
mikekatz04 committed Mar 15, 2024
1 parent 4fff509 commit 01c54a5
Show file tree
Hide file tree
Showing 4 changed files with 150 additions and 89 deletions.
30 changes: 30 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -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/*
25 changes: 25 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -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"
94 changes: 94 additions & 0 deletions scripts/prebuild.py
Original file line number Diff line number Diff line change
@@ -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 <https://www.gnu.org/licenses/>.
"""

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")
90 changes: 1 addition & 89 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"],
Expand Down Expand Up @@ -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 <https://www.gnu.org/licenses/>.
"""

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,
Expand All @@ -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",
Expand All @@ -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")

0 comments on commit 01c54a5

Please sign in to comment.