Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Meson #627

Merged
merged 68 commits into from
May 22, 2024
Merged

Meson #627

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
cc9ff5e
restructure and add in meson
katiebreivik May 13, 2024
c29bda8
no longer need the build inplace situation
katiebreivik May 13, 2024
d55e39f
Merge remote-tracking branch 'upstream/develop' into meson
katiebreivik May 13, 2024
6b1d89f
Merge remote-tracking branch 'upstream/develop' into meson
katiebreivik May 13, 2024
e355ed8
update paths
katiebreivik May 13, 2024
a1c6d24
update test imports
katiebreivik May 13, 2024
42a23c4
fix typo in import
katiebreivik May 13, 2024
71c8c32
install cosmic-pop executable and trying to work on evolve import
katiebreivik May 14, 2024
3e29ed7
lots of small updates trying to get imports right
katiebreivik May 14, 2024
28e12d9
fix meson build to have the comprad subroutine included
katiebreivik May 14, 2024
7033e22
trying with different --nocompactunwind flag
katiebreivik May 14, 2024
e1ffbd8
updating ldflags for actions
katiebreivik May 14, 2024
5cd50e7
still trying to get tests path to work
katiebreivik May 14, 2024
efb601e
Update python-package.yml
katiebreivik May 14, 2024
9497fa3
trying to make numpy be required
katiebreivik May 14, 2024
3b23628
Update python-package.yml
katiebreivik May 14, 2024
898fd91
add pickleshare
katiebreivik May 14, 2024
987fa37
working on numpy dependency
katiebreivik May 14, 2024
5f8cb1d
Update python-package.yml
katiebreivik May 14, 2024
cc84f9a
Merge remote-tracking branch 'origin/develop' into meson
katiebreivik May 14, 2024
51235e6
Update python-package.yml
katiebreivik May 14, 2024
d6447a5
Update python-package.yml
katiebreivik May 14, 2024
20aa3f7
still figuring out nummpy?
katiebreivik May 14, 2024
eee4612
Update python-package.yml
katiebreivik May 14, 2024
e018676
Update python-package.yml
katiebreivik May 15, 2024
991a7b6
Update python-package.yml
katiebreivik May 15, 2024
d2a6464
meson build update
katiebreivik May 15, 2024
86f934a
fixing build file
katiebreivik May 15, 2024
f6cb457
trying python dev
katiebreivik May 15, 2024
55b4fbe
python paths?
katiebreivik May 15, 2024
8e8af5f
trying clean build
katiebreivik May 15, 2024
5a38092
wipe wont work
katiebreivik May 15, 2024
347ffca
trying sudo
katiebreivik May 15, 2024
11461f6
different python path
katiebreivik May 15, 2024
e4ef206
debug
katiebreivik May 15, 2024
49c27b0
debug again
katiebreivik May 15, 2024
862807a
wrong build
katiebreivik May 15, 2024
5d8d853
check new path
katiebreivik May 15, 2024
088449c
try again
katiebreivik May 15, 2024
e2030b2
..
katiebreivik May 15, 2024
88a9ce8
ci
katiebreivik May 15, 2024
543e010
go back to pip?
katiebreivik May 15, 2024
c5fcf44
put everything in?
katiebreivik May 15, 2024
78c0cea
new path
katiebreivik May 15, 2024
034d525
new path
katiebreivik May 15, 2024
6094335
echo path
katiebreivik May 15, 2024
245f4bf
update meson
katiebreivik May 15, 2024
dee2bad
updated workflow
katiebreivik May 15, 2024
bdb70d9
trying subdir
katiebreivik May 15, 2024
83efcbc
maybe a working example with multiple paths
katiebreivik May 16, 2024
b314409
still trying
katiebreivik May 17, 2024
7526843
fix compile for tests
katiebreivik May 21, 2024
887b6df
checking path and trying python -m
katiebreivik May 21, 2024
e487b54
checking other path
katiebreivik May 21, 2024
ddce723
trying ls
katiebreivik May 21, 2024
31d62a6
hopefully figured out the paths
katiebreivik May 21, 2024
6e8592d
maybe figured out the path??
katiebreivik May 21, 2024
6716b9e
trying meson build for tests
katiebreivik May 21, 2024
d90469b
trying python -m for tests
katiebreivik May 21, 2024
f98bc65
checking runner path
katiebreivik May 21, 2024
1ff2f76
try install tests
katiebreivik May 21, 2024
24563d5
string typo
katiebreivik May 21, 2024
eb0b090
trying a copy for the tests
katiebreivik May 22, 2024
d693ed9
trying a remove of the init for tests
katiebreivik May 22, 2024
49b0e67
Merge branch 'develop' into meson
katiebreivik May 22, 2024
20d3246
update the action
katiebreivik May 22, 2024
dd31744
remove extra path checks
katiebreivik May 22, 2024
e32ba5e
Update python-package.yml
katiebreivik May 22, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@

name: Unit Test COSMIC

on: [pull_request, push]
on: [pull_request]

jobs:
build:

runs-on: ubuntu-latest
strategy:
fail-fast: false
Expand All @@ -30,23 +30,25 @@ jobs:
restore-keys: |
${{ runner.os }}-pip-
${{ runner.os }}-
- name: Install dependencies
- name: Install dependencies and package
run: |
sudo apt-get update
sudo apt-get install gfortran swig libhdf5-serial-dev
pip install numpy
sudo apt-get install gfortran swig libhdf5-serial-dev meson python3-dev
pip install numpy ninja pytest
pip install -r requirements.txt
pip install .
python -m pip install .

- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics --exclude docs
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics --exclude docs,versioneer.py,cosmic/_version.py,cosmic/tests,cosmic/*/__init__.py

- name: Test with pytest
run: |
bash ci/compile_benchmark.sh
export PYTHONPATH=$(meson introspect --install-dir)
pytest --cov=./cosmic --cov-report=xml
pytest --cov=./src/cosmic --cov-report=xml

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v1
2 changes: 1 addition & 1 deletion ci/compile_benchmark.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
gfortran -coverage -fprofile-arcs -ftest-coverage -O0 ./cosmic/src/assign_remnant.f ./cosmic/src/benchmarkevolv2.f ./cosmic/src/comenv.f ./cosmic/src/corerd.f ./cosmic/src/deltat.f ./cosmic/src/dgcore.f ./cosmic/src/evolv2.f ./cosmic/src/gntage.f ./cosmic/src/hrdiag.f ./cosmic/src/hrdiag_remnant.f ./cosmic/src/instar.f ./cosmic/src/kick.f ./cosmic/src/mix.f ./cosmic/src/mlwind.f ./cosmic/src/mrenv.f ./cosmic/src/ran3.f ./cosmic/src/rl.f ./cosmic/src/star.f ./cosmic/src/zcnsts.f ./cosmic/src/zfuncs.f ./cosmic/src/concatkstars.f ./cosmic/src/bpp_array.f ./cosmic/src/checkstate.f -o benchmarkevolv2.exe -I cosmic/src -Wl,-rpath,${CONDA_PREFIX}/lib
gfortran -coverage -fprofile-arcs -ftest-coverage -O0 src/cosmic/src/assign_remnant.f src/cosmic/src/benchmarkevolv2.f src/cosmic/src/comenv.f src/cosmic/src/corerd.f src/cosmic/src/deltat.f src/cosmic/src/dgcore.f src/cosmic/src/evolv2.f src/cosmic/src/gntage.f src/cosmic/src/hrdiag.f src/cosmic/src/hrdiag_remnant.f src/cosmic/src/instar.f src/cosmic/src/kick.f src/cosmic/src/mix.f src/cosmic/src/mlwind.f src/cosmic/src/mrenv.f src/cosmic/src/ran3.f src/cosmic/src/rl.f src/cosmic/src/star.f src/cosmic/src/zcnsts.f src/cosmic/src/zfuncs.f src/cosmic/src/concatkstars.f src/cosmic/src/bpp_array.f src/cosmic/src/checkstate.f -o benchmarkevolv2.exe -I src/cosmic/src -Wl,-rpath,${CONDA_PREFIX}/lib
./benchmarkevolv2.exe
18 changes: 0 additions & 18 deletions cosmic/tests/__init__.py

This file was deleted.

2 changes: 1 addition & 1 deletion docs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,6 @@ pseudoxml:

.PHONY: apidoc
apidoc:
sphinx-apidoc -o api/ ../cosmic ../cosmic/tests --no-toc --separate --no-headings --force
sphinx-apidoc -o api/ ../src/cosmic ../src/cosmic/tests --no-toc --separate --no-headings --force
@echo
@echo "APIdoc run is complete."
12 changes: 0 additions & 12 deletions docs/install/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,3 @@ Installation Notes/FAQ

``pip install jupyter ipython``

.. note::

USING COMSIC WHEN BUILT FROM SOURCE

If you want import the fortran wrapped library
from the GITHUB folder itself, i.e.

``from cosmic import _evolvebin``

then you must build the extension locally

``python setup.py build_ext --inplace``
89 changes: 89 additions & 0 deletions meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
project('cosmic',
'c',
'fortran',
version : '3.4.10',
default_options: ['warning_level=0', 'optimization=3'],
)

# Enable fortran and check arguments
# add_languages('fortran', native: false)
ff = meson.get_compiler('fortran')
f_args = ff.get_supported_arguments('-fPIC')
add_project_arguments(f_args, language: 'fortran')

py3 = import('python').find_installation()

numpy_include_dir = run_command(py3, ['-c', 'import numpy; print(numpy.get_include())'], check: true).stdout().strip()
f2py_include_dir = run_command(py3, ['-c', 'import numpy.f2py; print(numpy.f2py.get_include())'], check: true).stdout().strip()
inc_np = include_directories(numpy_include_dir, f2py_include_dir)

f2py_source = custom_target(
'evolvebin-target',
input : ['src/cosmic/src/evolv2.f', 'src/cosmic/src/comprad.f'],
output : ['_evolvebinmodule.c', '_evolvebin-f2pywrappers.f'],
command : [py3, '-m', 'numpy.f2py', '@INPUT@', '-m', '_evolvebin', '--lower', '@OUTDIR']
)

lib_source = [
'src/cosmic/src/hrdiag_remnant.f',
'src/cosmic/src/assign_remnant.f',
'src/cosmic/src/benchmarkevolv2.f',
'src/cosmic/src/corerd.f',
'src/cosmic/src/comenv.f',
'src/cosmic/src/dgcore.f',
'src/cosmic/src/evolv2.f',
'src/cosmic/src/gntage.f',
'src/cosmic/src/instar.f',
'src/cosmic/src/kick.f',
'src/cosmic/src/mix.f',
'src/cosmic/src/mrenv.f',
'src/cosmic/src/ran3.f',
'src/cosmic/src/rl.f',
'src/cosmic/src/concatkstars.f',
'src/cosmic/src/comprad.f',
'src/cosmic/src/bpp_array.f',
'src/cosmic/src/checkstate.f',
'src/cosmic/src/deltat.f',
'src/cosmic/src/mlwind.f',
'src/cosmic/src/hrdiag.f',
'src/cosmic/src/star.f',
'src/cosmic/src/zcnsts.f',
'src/cosmic/src/deltat.f',
'src/cosmic/src/mlwind.f',
'src/cosmic/src/hrdiag.f',
'src/cosmic/src/star.f',
'src/cosmic/src/zcnsts.f',
'src/cosmic/src/zfuncs.f',]

# Detect operating system and set appropriate linker flags
host_system = host_machine.system()

if host_system == 'darwin'
ldflags = ['-Wl,-no_compact_unwind']
else
ldflags = [] # No special flags for other systems
endif

evolvebin_module = py3.extension_module('_evolvebin',
f2py_source,
lib_source,
f2py_include_dir / 'fortranobject.c',
include_directories: inc_np,
link_args: ldflags,
install : true,
install_dir : py3.get_install_dir() / 'cosmic'
)


module_dirs = ['src/cosmic', 'src/cosmic/bse_utils',
'src/cosmic/sample', 'src/cosmic/tests']

# Install modules
foreach mod_dir: module_dirs
install_subdir(mod_dir,
install_dir: py3.get_install_dir())
endforeach


python_script = 'bin/cosmic-pop'
install_data(python_script, install_dir: get_option('bindir'))
45 changes: 45 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
[project]
name = "cosmic"
distname = "cosmic-popsynth"
description = "a Python-interfaced binary population synthesis suite"
authors = [
{ name="Katelyn Breivik", email="katie.breivik@gmail.com" },
{ name="Scott Coughlin" },
{ name="Michael Zevin" },
{ name="Carl L. Rodriguez" },
]
readme = "README.md"


requires-python = ">=3.7"
license = { text = "MIT License" }
classifiers = [
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Developers",
"Intended Audience :: Science/Research",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
"Programming Language :: Python",
]
dynamic = ["version"]
dependencies = ["numpy", "scipy", "astropy", "configparser",
"tqdm", "pandas", "tables", "h5py", "schwimmbad",
"matplotlib", "importlib-metadata"]


[project.optional-dependencies]
test = ["pytest", "pytest-xdist", "pytest-cov", "flake8", "coverage"]
docs = ["sphinx", "numpydoc", "sphinx-bootstrap-theme",
"sphinxcontrib-programoutput", "sphinx-automodapi",
"ipython", "sphinx_rtd_theme", "pickleshare"]



[build-system]
requires = ["meson", "meson-python", "wheel", "numpy", "setuptools"]
build-backend = 'mesonpy'


# pyproject.toml
[tool.setuptools]
write_to = "src/cosmic/_version.py"
19 changes: 0 additions & 19 deletions setup.cfg

This file was deleted.

Loading
Loading