fujiisoup / py3nj

Wigner's 3J, 6J, 9J symbols for python
https://py3nj.readthedocs.io/
Apache License 2.0
18 stars 5 forks source link

Use meson to compile the fortran modules. #24

Closed kalekundert closed 1 year ago

kalekundert commented 1 year ago

This PR moves to the meson build system for compiling the fortran extension modules. I mostly followed the instructions on this page, with some inspiration taken from the scikit-image project. This would fix #22.

Here is an example of the install process:

$ cd /path/to/py3nj
$ python -m venv venv
$ . venv/bin/activate
$ pip install --upgrade pip
$ python --version
Python 3.10.0

$ pip --version
pip 23.2.1 from /home/kale/research/software/forks/py3nj/venv/lib/python3.10/site-packages/pip (python 3.10)

$ pip install .
Processing /home/kale/research/software/forks/py3nj
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Collecting numpy (from py3nj==0.1.2)
  Obtaining dependency information for numpy from https://files.pythonhosted.org/packages/71/3c/3b1981c6a1986adc9ee7db760c0c34ea5b14ac3da9ecfcf1ea2a4ec6c398/numpy-1.25.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata
  Using cached numpy-1.25.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (5.6 kB)
Using cached numpy-1.25.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (18.2 MB)
Building wheels for collected packages: py3nj
  Building wheel for py3nj (pyproject.toml) ... done
  Created wheel for py3nj: filename=py3nj-0.1.2-cp310-cp310-linux_x86_64.whl size=114741 sha256=c4414c46343473a4579435f21a4c264772303c30b6b4f379f4d5c32b3f5dba5b
  Stored in directory: /tmp/pip-ephem-wheel-cache-jyt0ibue/wheels/54/46/c8/698fe6f7850e3962dd32c95d6a4166d337c037a9bcbba56d9b
Successfully built py3nj
Installing collected packages: numpy, py3nj
Successfully installed numpy-1.25.2 py3nj-0.1.2

$ pip install pytest
$ python -m pytest
============================= test session starts ==============================
platform linux -- Python 3.10.0, pytest-7.4.0, pluggy-1.2.0
rootdir: /home/kale/research/software/forks/py3nj
collected 22 items

tests/test_3j.py ............                                            [ 54%]
tests/test_6j.py .......                                                 [ 86%]
tests/test_9j.py ..                                                      [ 95%]
tests/test_cg.py .                                                       [100%]

============================== 22 passed in 1.36s ==============================

Some caveats:

fujiisoup commented 1 year ago

This looks good to me. I enforced pip=23.2.1 explicitly in CI, and it works perfect. If you think it is ready, I will merge it.

kalekundert commented 1 year ago

I think it's ready to merge. Thanks for getting this done so fast!

fujiisoup commented 1 year ago

Merged. Thank you for your contribution!

fujiisoup commented 1 year ago

Now the new version is on Pypi. Thank you again for your contribution.