Skip to content

Commit 246983a

Browse files
authoredJun 1, 2024··
Merge pull request #4 from HaoZeke/buildWheels
BLD: Build wheels
2 parents dfdc39c + be35b81 commit 246983a

22 files changed

+281
-68
lines changed
 

‎.github/workflows/build_wheels.yml

+97
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
# Build on every branch push, tag push, and pull request change:
2+
# Sources:
3+
# https://github.com/pypa/cibuildwheel/blob/main/examples/github-deploy.yml
4+
# https://github.com/airspeed-velocity/asv/blob/main/.github/workflows/build_wheels.yml
5+
# include [wheel build] in the commit to trigger wheel builds
6+
name: Build wheels
7+
on: [push, pull_request, workflow_dispatch]
8+
9+
concurrency:
10+
group: ${{ github.workflow }}-${{ github.ref }}
11+
cancel-in-progress: true
12+
13+
permissions:
14+
contents: read # to fetch code (actions/checkout)
15+
16+
jobs:
17+
get_commit_message:
18+
name: Get commit message
19+
runs-on: ubuntu-latest
20+
if: "github.repository == 'flowy-code/pyflowy'"
21+
outputs:
22+
message: ${{ steps.commit_message.outputs.message }}
23+
steps:
24+
- name: Checkout project
25+
uses: actions/checkout@v4
26+
# Gets the correct commit message for pull request
27+
with:
28+
ref: ${{ github.event.pull_request.head.sha }}
29+
- name: Get commit message
30+
id: commit_message
31+
run: |
32+
set -xe
33+
COMMIT_MSG=$(git log --no-merges -1 --oneline)
34+
echo "message=$COMMIT_MSG" >> $GITHUB_OUTPUT
35+
echo github.ref ${{ github.ref }}
36+
build_wheels:
37+
name: Build wheels
38+
needs: get_commit_message
39+
if: >-
40+
contains(needs.get_commit_message.outputs.message, '[wheel build]') ||
41+
github.event_name == 'schedule' ||
42+
github.event_name == 'workflow_dispatch' ||
43+
(github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') && ( ! endsWith(github.ref, 'dev0')))
44+
runs-on: ${{ matrix.buildplat[0] }}
45+
strategy:
46+
# Ensure that a wheel builder finishes even if another fails
47+
fail-fast: false
48+
matrix:
49+
# From NumPy
50+
# Github Actions doesn't support pairing matrix values together, let's improvise
51+
# https://github.com/github/feedback/discussions/7835#discussioncomment-1769026
52+
buildplat:
53+
# TODO(rg): This needs to be pruned
54+
# This will build all 21 (many,musl)linux related wheels (64, 32), for supported pythons 3.9, 3.10, 3.11, 3.12, pypy 3.9, pypy 3.10
55+
- [ubuntu-20.04, manylinux_x86_64]
56+
# - [ubuntu-20.04, musllinux_x86_64]
57+
# TODO(rg): Handle these later via indirection
58+
# - [macos-12, macosx_x86_64]
59+
# - [macos-12, macosx_arm64]
60+
# - [windows-2019, win_amd64]
61+
python-version: ['3.11'] # This is the python version of the CI, not related to the ones built by cibuildwheel
62+
63+
steps:
64+
- uses: actions/checkout@v4
65+
- name: Echo Python version and build platform
66+
run: echo Building wheel for ${{ matrix.python-version }}-${{ matrix.buildplat[1] }}
67+
- uses: actions/setup-python@v5
68+
with:
69+
python-version: ${{ matrix.python-version }}
70+
- name: Build wheels
71+
uses: pypa/cibuildwheel@v2.16.5
72+
- uses: actions/upload-artifact@v3
73+
with:
74+
path: ./wheelhouse/*.whl
75+
76+
build_sdist:
77+
name: Build source distribution
78+
needs: get_commit_message
79+
if: >-
80+
contains(needs.get_commit_message.outputs.message, '[wheel build]') ||
81+
github.event_name == 'schedule' ||
82+
github.event_name == 'workflow_dispatch' ||
83+
(github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') && ( ! endsWith(github.ref, 'dev0')))
84+
runs-on: ubuntu-latest
85+
steps:
86+
- uses: actions/checkout@v4
87+
88+
- name: Install dependencies
89+
run: sudo apt-get install libnetcdf-dev libfmt-dev libxtensor-dev libxtensor-blas-dev
90+
91+
- name: Build sdist
92+
shell: bash -l {0}
93+
run: pipx run build --sdist
94+
95+
- uses: actions/upload-artifact@v3
96+
with:
97+
path: dist/*.tar.gz

‎.gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# Added
2+
/wheelhouse/
3+
*.whl
4+
15
.cache/
26
build/
37
subprojects/*/

‎README.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
# flowpy
1+
# pyflowy
22
Python bindings for Flowy
33

44
## Installation from Source
55

66
```bash
77
micromamba create -f environment.yml # For the first time only
8-
micromamba activate flowpyenv
8+
micromamba activate pyflowyenv
99
meson setup build # To download flowy and C++ dependencies using meson wrap files
1010
pip install .
1111
```
@@ -17,9 +17,9 @@ micromamba install xtensor-python
1717

1818
Please note, that you will need to delete directories downloaded by `meson` if you want to pull the latest commits of the dependencies. Please do not delete the wrap file for `flowy`. Here's what you should do:
1919
```bash
20-
micromamba activate flowpyenv
20+
micromamba activate pyflowyenv
2121
rm -rf subprojects
2222
git restore subprojects
2323
meson setup build --wipe
2424
pip install -e . --no-build-isolation
25-
```
25+
```

‎environment.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: flowpyenv
1+
name: pyflowyenv
22
channels:
33
- conda-forge
44
dependencies:
@@ -21,4 +21,4 @@ dependencies:
2121
- libnetcdf
2222
- hdf5
2323
- pytest
24-
- meson-python
24+
- meson-python

‎examples/add_lobe_example.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import flowpy as fpy
1+
import pyflowy as pfy
22
import numpy as np
33
import matplotlib.pyplot as plt
44

5-
lobe = fpy.flowpycpp.Lobe()
5+
lobe = pfy.flowycpp.Lobe()
66
lobe.semi_axes = [8, 2]
77
lobe.thickness = 20.0
88
lobe.set_azimuthal_angle(np.pi / 4)
@@ -20,15 +20,15 @@
2020
[[i + j for j in range(len(y_data))] for i in range(len(x_data))]
2121
)
2222

23-
topography = fpy.flowpycpp.Topography(height_data, x_data, y_data)
23+
topography = pfy.flowycpp.Topography(height_data, x_data, y_data)
2424

2525
for p in perimeter:
2626
print(topography.height_and_slope(p))
2727

2828
budding_point = topography.find_preliminary_budding_point(lobe, 30)
2929

3030

31-
new_lobe = fpy.flowpycpp.Lobe()
31+
new_lobe = pfy.flowycpp.Lobe()
3232
new_lobe.set_azimuthal_angle(0)
3333
new_lobe.thickness = 20
3434
new_lobe.center = [20, 10]

‎examples/compute_cell_intersection.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import flowpy as fpy
1+
import pyflowy as pfy
22
import numpy as np
33
import matplotlib.pyplot as plt
44

5-
lobe = fpy.flowpycpp.Lobe()
5+
lobe = pfy.flowycpp.Lobe()
66
lobe.semi_axes = [8, 2]
77
lobe.thickness = 20.0
88
lobe.set_azimuthal_angle(np.pi / 4)
@@ -31,7 +31,7 @@ def add_lobe(lobe, topography, height_data):
3131
[[i + j for j in range(len(y_data))] for i in range(len(x_data))]
3232
)
3333

34-
topography = fpy.flowpycpp.Topography(height_data, x_data, y_data)
34+
topography = pfy.flowycpp.Topography(height_data, x_data, y_data)
3535

3636
bbox = topography.bounding_box(lobe.center, extent[0], extent[1])
3737

@@ -48,4 +48,4 @@ def add_lobe(lobe, topography, height_data):
4848
plt.axhline(y_data[bbox.idx_y_higher], color="black")
4949
plt.plot(perimeter[:, 0], perimeter[:, 1], color="white")
5050

51-
plt.show()
51+
plt.show()

‎examples/create_toy_topographies.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import flowpy as fpy
1+
import pyflowy as pfy
22
import numpy as np
33
import matplotlib.pyplot as plt
44

@@ -13,7 +13,7 @@ def height(x, y):
1313

1414
height_data = np.array([[height(x, y) for y in y_data] for x in x_data])
1515

16-
asc_file = fpy.flowpycpp.AscFile()
16+
asc_file = pfy.flowycpp.AscFile()
1717
asc_file.x_data = x_data
1818
asc_file.y_data = y_data
1919
asc_file.height_data = height_data
@@ -33,7 +33,7 @@ def height(x, y, center):
3333
center = np.array([np.mean(x_data), np.mean(y_data)])
3434
height_data = np.array([[height(x, y, center) for y in y_data] for x in x_data])
3535

36-
asc_file = fpy.flowpycpp.AscFile()
36+
asc_file = pfy.flowycpp.AscFile()
3737
asc_file.x_data = x_data
3838
asc_file.y_data = y_data
3939
asc_file.height_data = height_data
@@ -52,7 +52,7 @@ def height(x, y, center):
5252
center = np.array([np.mean(x_data), np.mean(y_data)])
5353
height_data = np.array([[height(x, y, center) for y in y_data] for x in x_data])
5454

55-
asc_file = fpy.flowpycpp.AscFile()
55+
asc_file = pfy.flowycpp.AscFile()
5656
asc_file.x_data = x_data
5757
asc_file.y_data = y_data
5858
asc_file.height_data = height_data

‎examples/descendent_lobe.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import flowpy as fpy
1+
import pyflowy as pfy
22
import numpy as np
33
import matplotlib.pyplot as plt
44
import math
@@ -22,7 +22,7 @@ def compute_lobe_axes( lobe, slope, input, lobe_dimensions ):
2222
return semi_major_axis, semi_minor_axis
2323

2424
# Input parameters (we just construct this here)
25-
input = fpy.flowpycpp.InputParams()
25+
input = pfy.flowycpp.InputParams()
2626
input.source = "file.asc"
2727
input.total_volume = 20
2828
input.prescribed_avg_lobe_thickness = 1
@@ -38,24 +38,24 @@ def compute_lobe_axes( lobe, slope, input, lobe_dimensions ):
3838
input.aspect_ratio_coeff = 2.0
3939

4040
# Create a Simulation object
41-
simulation = fpy.flowpycpp.Simulation(input, None)
41+
simulation = pfy.flowycpp.Simulation(input, None)
4242
# Topography data
4343
x_data = np.linspace(0, 40, 40)
4444
y_data = np.linspace(0, 20, 20)
4545
height_data = np.zeros(shape=(len(x_data), len(y_data)))
4646
height_data = np.array(
4747
[[i + j for j in range(len(y_data))] for i in range(len(x_data))]
4848
)
49-
topography = fpy.flowpycpp.Topography(height_data, x_data, y_data)
49+
topography = pfy.flowycpp.Topography(height_data, x_data, y_data)
5050
simulation.topography = topography
5151

5252
# Parent lobe
53-
parent_lobe = fpy.flowpycpp.Lobe()
53+
parent_lobe = pfy.flowycpp.Lobe()
5454
parent_lobe.semi_axes = [6, 2]
5555
parent_lobe.thickness = 20.0
5656
parent_lobe.center = [20, 10]
5757
# Descendent lobe
58-
descendent_lobe = fpy.flowpycpp.Lobe()
58+
descendent_lobe = pfy.flowycpp.Lobe()
5959
descendent_lobe.thickness = 20.0
6060

6161
# Find the height and slope at the parent center and perturb the angle accordingly
@@ -100,4 +100,4 @@ def compute_lobe_axes( lobe, slope, input, lobe_dimensions ):
100100

101101
plt.gca().set_box_aspect(1)
102102
plt.show()
103-
plt.savefig("descendent.png", dpi=300)
103+
plt.savefig("descendent.png", dpi=300)

‎examples/line_segment_intersects.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import flowpy as fpy
1+
import pyflowy as pfy
22
import numpy as np
33
import matplotlib.pyplot as plt
44

5-
lobe = fpy.flowpycpp.Lobe()
5+
lobe = pfy.flowycpp.Lobe()
66
lobe.semi_axes = [2, 1]
77
lobe.set_azimuthal_angle(np.pi / 4)
88
lobe.center = [1, 2]

‎examples/raster.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import flowpy as fpy
1+
import pyflowy as pfy
22
import numpy as np
33
import matplotlib.pyplot as plt
44

@@ -11,7 +11,7 @@ def add_lobe(lobe, topography, new_height_data):
1111
new_height_data[indices[0], indices[1]] += fraction * lobe.thickness
1212

1313

14-
lobe = fpy.flowpycpp.Lobe()
14+
lobe = pfy.flowycpp.Lobe()
1515
lobe.semi_axes = [8, 2]
1616
lobe.thickness = 20.0
1717
lobe.set_azimuthal_angle(np.pi / 4)
@@ -27,7 +27,7 @@ def add_lobe(lobe, topography, new_height_data):
2727

2828
height_data = np.array([[0 for j in range(len(y_data))] for i in range(len(x_data))])
2929

30-
topography = fpy.flowpycpp.Topography(height_data, x_data, y_data)
30+
topography = pfy.flowycpp.Topography(height_data, x_data, y_data)
3131

3232
bbox = topography.bounding_box(lobe.center, extent[0], extent[1])
3333

‎examples/run_simulation.py

+5-6
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
1-
import flowpy as fpy
2-
from flowpy import util
3-
# import util
1+
import pyflowy as pfy
2+
from pyflowy import util
43
from pathlib import Path
54

65
util.download_file_from_github( Path("./hawaii/input.toml"), relative_file_path="examples/KILAUEA2014-2015/input.toml" )
76
util.download_file_from_github( Path("./hawaii/test20m.asc"), relative_file_path="examples/KILAUEA2014-2015/test20m.asc" )
87

98
input_folder = Path("./hawaii")
109

11-
input_params = fpy.flowpycpp.parse_config( input_folder/"input.toml" )
10+
input_params = pfy.flowycpp.parse_config( input_folder/"input.toml" )
1211
input_params.output_folder = "./output_test"
1312
input_params.source = input_folder / "test20m.asc"
1413

15-
simulation = fpy.flowpycpp.Simulation(input_params, 1)
16-
simulation.run()
14+
simulation = pfy.flowycpp.Simulation(input_params, 1)
15+
simulation.run()

‎examples/simulation.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import flowpy as fpy
1+
import pyflowy as pfy
22
import numpy as np
33
import matplotlib.pyplot as plt
44
from matplotlib.colors import Normalize
@@ -13,7 +13,7 @@ def compute_descendent_lobe_position( descendent_lobe, parent_lobe, final_buddin
1313
return new_lobe_center
1414

1515
# Input parameters (we just construct this here)
16-
input = fpy.flowpycpp.InputParams()
16+
input = pfy.flowycpp.InputParams()
1717
input.source = "file.asc"
1818
input.total_volume = 20
1919
input.prescribed_lobe_area = 20
@@ -44,15 +44,15 @@ def compute_descendent_lobe_position( descendent_lobe, parent_lobe, final_buddin
4444
input.aspect_ratio_coeff = 2.0
4545

4646
# Create a Simulation object
47-
simulation = fpy.flowpycpp.Simulation(input, None)
47+
simulation = pfy.flowycpp.Simulation(input, None)
4848
# Topography data
4949
x_data = np.linspace(0, 40, 40)
5050
y_data = np.linspace(0, 20, 20)
5151
height_data = np.zeros(shape=(len(x_data), len(y_data)))
5252
height_data = np.array(
5353
[[i + j for j in range(len(y_data))] for i in range(len(x_data))]
5454
)
55-
topography = fpy.flowpycpp.Topography(height_data, x_data, y_data)
55+
topography = pfy.flowycpp.Topography(height_data, x_data, y_data)
5656
simulation.topography = topography
5757

5858
# Reproduce the simulation.run loop
@@ -62,7 +62,7 @@ def compute_descendent_lobe_position( descendent_lobe, parent_lobe, final_buddin
6262
thickness = 1 # All lobes have the same thickness
6363

6464
for idx_lobe in range(input.n_init):
65-
lobe_cur = fpy.flowpycpp.Lobe()
65+
lobe_cur = pfy.flowycpp.Lobe()
6666

6767
simulation.compute_initial_lobe_position( 0, lobe_cur )
6868
lobe_cur_thickness = thickness
@@ -73,7 +73,7 @@ def compute_descendent_lobe_position( descendent_lobe, parent_lobe, final_buddin
7373

7474
# Skip initial lobes and go over the rest
7575
for idx_lobe in range(input.n_init, n_lobes):
76-
lobe_cur = fpy.flowpycpp.Lobe()
76+
lobe_cur = pfy.flowycpp.Lobe()
7777

7878
idx_parent = select_parent_lobe( idx_lobe )
7979
lobe_parent = lobes[idx_parent]
@@ -119,4 +119,4 @@ def compute_descendent_lobe_position( descendent_lobe, parent_lobe, final_buddin
119119

120120
plt.gca().set_box_aspect(1)
121121
plt.show()
122-
plt.savefig("simulation_test.png", dpi=300)
122+
plt.savefig("simulation_test.png", dpi=300)

‎examples/topography_interpolation.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
import flowpy as fpy
1+
import pyflowy as pfy
22
import numpy as np
33
import matplotlib.pyplot as plt
44

5-
asc_file = fpy.flowpycpp.AscFile("topo.asc")
5+
asc_file = pfy.flowycpp.AscFile("topo.asc")
66
height_data = asc_file.height_data
77
x_data = asc_file.x_data
88
y_data = asc_file.y_data
99

10-
topography = fpy.flowpycpp.Topography(
10+
topography = pfy.flowycpp.Topography(
1111
asc_file.height_data, asc_file.x_data, asc_file.y_data
1212
)
1313

@@ -55,4 +55,4 @@
5555
plt.plot(tspace, grad, label="grad")
5656
plt.plot(tspace, slope, label="slope")
5757
plt.legend()
58-
plt.show()
58+
plt.show()

‎flowpy/__init__.py

-1
This file was deleted.

‎meson.build

+13-10
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
1-
project('flowpy', 'cpp',
1+
project('pyflowy', 'cpp',
22
default_options : ['warning_level=3', 'cpp_std=c++20'])
33

44
args = []
55
deps = []
66

77
cppc = meson.get_compiler('cpp')
88

9-
flowy_proj = subproject('flowy')
10-
flowylib = flowy_proj.get_variable('flowylib_shared_dep')
9+
flowy_proj = subproject('flowy', default_options: ['default_library=static',
10+
# Flowy-specific
11+
'build_tests=false',
12+
'build_exe=false'])
13+
flowylib = flowy_proj.get_variable('flowylib_static_dep')
1114
deps += [flowylib]
1215

1316
py = import('python').find_installation('python', modules: ['numpy'])
@@ -29,30 +32,30 @@ deps += [pyb11_dep]
2932

3033
# for the bindings
3134
py.extension_module(
32-
'flowpycpp',
35+
'flowycpp',
3336
sources : [
3437
'python_bindings/bindings.cpp'
3538
],
3639
include_directories: inc_np,
3740
dependencies: deps,
3841
cpp_args : args,
3942
install: true,
40-
subdir: 'flowpy/'
43+
subdir: 'pyflowy/'
4144
)
4245

4346

44-
# flowpy main package
47+
# pyflowy main package
4548
py.install_sources([
46-
'flowpy/__init__.py',
49+
'pyflowy/__init__.py',
4750
],
4851
pure: false, # install next to compiled extension
49-
subdir: 'flowpy'
52+
subdir: 'pyflowy'
5053
)
5154

5255
# Util
5356
py.install_sources([
54-
'flowpy/util.py',
57+
'pyflowy/util.py',
5558
],
5659
pure: false,
57-
subdir: 'flowpy'
60+
subdir: 'pyflowy'
5861
)

‎pyflowy/__init__.py

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from pyflowy import flowycpp

‎flowpy/util.py ‎pyflowy/util.py

File renamed without changes.

‎pyproject.toml

+37-5
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
[project]
2-
name = "flowpy"
2+
name = "pyflowy"
33
version = "0.0.1"
44
description = "Python bindings for flowy"
55
authors = [
66
{name = "Amrita Goswami", email = "amrita16thaug646@gmail.com"},
77
{name = "Moritz Sallermann", email = "moritzsallermann@gmail.com"},
8-
8+
{name = "Rohit Goswami", email = "rgoswami@ieee.org"},
99
]
1010

1111
dependencies = [
@@ -22,12 +22,44 @@ requires = ["pybind11", "meson-python", "numpy"]
2222
build-backend = "mesonpy"
2323
# Important, tells pip how to install the package
2424
[tool.meson-python.args]
25-
setup = ['-Dwrap_mode=forcefallback',
26-
# ^-- collects subprojects, see https://github.com/ERGO-Code/HiGHS/pull/1343#discussion_r1252446966
27-
]
25+
setup = [
26+
'-Dwrap_mode=forcefallback',
27+
# ^-- collects subprojects, see https://github.com/ERGO-Code/HiGHS/pull/1343#discussion_r1252446966
28+
]
2829
# Skip during installation to prevent local RPATH stripping issues
2930
# See: https://github.com/mesonbuild/meson-python/discussions/410
3031
install = ['--skip-subprojects']
3132
# Include so auditwheel on the CI can correctly generate wheels
3233
# See: https://github.com/ERGO-Code/HiGHS/pull/1343/files
3334
dist = ['--include-subprojects']
35+
36+
[tool.cibuildwheel]
37+
build-frontend = "build"
38+
# TODO(rg): Needs an equivalent on windows, use an override
39+
before-build = "bash {project}/tools/wheels/cibw_setup.sh {project}"
40+
test-command = "pytest {project}/tests"
41+
test-requires = "pytest"
42+
build-verbosity = 1
43+
44+
[tool.cibuildwheel.linux]
45+
manylinux-x86_64-image = "manylinux2014"
46+
manylinux-i686-image = "manylinux2014"
47+
repair-wheel-command = "auditwheel repair -w {dest_dir} {wheel}"
48+
49+
# /project will be the $PWD equivalent inside the docker used to build the wheel
50+
[tool.cibuildwheel.linux.environment]
51+
RUNNER_OS="Linux"
52+
[tool.cibuildwheel.macos.environment]
53+
RUNNER_OS="MacOS"
54+
55+
[tool.cibuildwheel.macos]
56+
archs = ["x86_64 arm64"]
57+
repair-wheel-command = [
58+
"delocate-listdeps {wheel}",
59+
"delocate-wheel --require-archs {delocate_archs} -w {dest_dir} {wheel}",
60+
]
61+
62+
63+
# [tool.cibuildwheel.windows]
64+
# before-build = "pip install delvewheel"
65+
# repair-wheel-command = "delvewheel repair -w {dest_dir} {wheel}"

‎python_bindings/bindings.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ using namespace std::string_literals; // For ""s
2929
using namespace pybind11::literals; // For ""_a
3030
namespace py = pybind11; // Convention
3131

32-
PYBIND11_MODULE( flowpycpp, m )
32+
PYBIND11_MODULE( flowycpp, m )
3333
{
3434
xt::import_numpy();
3535
m.doc() = "Python bindings for flowy"; // optional module docstring

‎run_formatter.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
#!/bin/sh
22
find ./python_bindings -regex '.*\.\(cpp\|hpp\|cc\|cxx\)' -exec clang-format -i {} \;
3-
find ./flowpy -regex '.*py' -exec black {} \;
3+
find ./pyflowy -regex '.*py' -exec black {} \;

‎tests/test_lobe.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import pytest
22
import numpy as np
3-
import flowpy as fpy
3+
import pyflowy as pfy
44

55
@pytest.fixture
66
def lobe():
77
'''
88
Creates a lobe which you can reuse.
99
'''
10-
lobe = fpy.flowpycpp.Lobe()
10+
lobe = pfy.flowycpp.Lobe()
1111
lobe.semi_axes = [8, 2]
1212
lobe.thickness = 20.0
1313
lobe.set_azimuthal_angle(np.pi / 4.0)
@@ -18,4 +18,4 @@ def test_lobe(lobe):
1818
'''
1919
Test some lobe functions. TODO: add more tests!
2020
'''
21-
assert lobe.get_azimuthal_angle() == np.pi / 4.0
21+
assert lobe.get_azimuthal_angle() == np.pi / 4.0

‎tools/wheels/cibw_setup.sh

+78
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
#!/bin/bash
2+
3+
# Directories of interest
4+
PROJECT_DIR="${1:-$PWD}"
5+
PYTHON_SITEPKGS=$(python -c 'import site; print(site.getsitepackages()[0])')
6+
7+
# Versions
8+
XTL_VERSION='0.7.7'
9+
XTENSOR_VERSION='0.25.0'
10+
XTENSOR_BLAS_VERSION='0.21.0'
11+
XTENSOR_PYTHON_VERSION='0.27.0'
12+
NETCDF_VERSION='4.9.0'
13+
FMT_VERSION='10.2.1'
14+
COMMON_CMAKE='-DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=Release -DCMAKE_POSITION_INDEPENDENT_CODE=TRUE -DBUILD_SHARED_LIBS=OFF'
15+
16+
# Function to download, extract, and rename directory
17+
download_and_rename() {
18+
local url=$1
19+
local dest_dir=$2
20+
local new_name=$3
21+
22+
curl -L $url | tar -xzC /tmp
23+
mv /tmp/$dest_dir /tmp/$new_name
24+
}
25+
26+
# Grab and install fmt
27+
download_and_rename "https://github.com/fmtlib/fmt/archive/refs/tags/${FMT_VERSION}.tar.gz" "fmt-${FMT_VERSION}" "build-fmt"
28+
cmake -S /tmp/build-fmt -B /tmp/build-fmt/build -DFMT_TEST=OFF ${COMMON_CMAKE}
29+
cmake --build /tmp/build-fmt/build --target install
30+
rm -rf /tmp/build-fmt
31+
32+
# TODO(rg): Probably worthwhile to grab xsimd
33+
# Grab and install xtl
34+
download_and_rename "https://github.com/xtensor-stack/xtl/archive/refs/tags/${XTL_VERSION}.tar.gz" "xtl-${XTL_VERSION}" "build-xtl"
35+
cmake -S /tmp/build-xtl -B /tmp/build-xtl/build ${COMMON_CMAKE}
36+
cmake --build /tmp/build-xtl/build --target install
37+
rm -rf /tmp/build-xtl
38+
39+
# Grab and install xtensor
40+
download_and_rename "https://github.com/xtensor-stack/xtensor/archive/refs/tags/${XTENSOR_VERSION}.tar.gz" "xtensor-${XTENSOR_VERSION}" "build-xtensor"
41+
cmake -S /tmp/build-xtensor -B /tmp/build-xtensor/build ${COMMON_CMAKE}
42+
cmake --build /tmp/build-xtensor/build --target install
43+
rm -rf /tmp/build-xtensor
44+
45+
# Grab and install xtensor-blas from HaoZeke's fork
46+
# Replace with upstream after https://github.com/xtensor-stack/xtensor-blas/pull/243
47+
# Also remove -DVERSION then, when a tagged release is used
48+
download_and_rename "https://github.com/HaoZeke/xtensor-blas/archive/refs/heads/addPkgConfig.tar.gz" "xtensor-blas-addPkgConfig" "build-xtblas"
49+
cmake -S /tmp/build-xtblas -B /tmp/build-xtblas/build -DVERSION=${XTENSOR_BLAS_VERSION} ${COMMON_CMAKE}
50+
cmake --build /tmp/build-xtblas/build --target install
51+
rm -rf /tmp/build-xtblas
52+
53+
# xtensor-python needs these
54+
pip install pybind11 numpy
55+
56+
# Set CMAKE_PREFIX_PATH
57+
export CMAKE_PREFIX_PATH="${CMAKE_PREFIX_PATH}:${PYTHON_SITEPKGS}"
58+
59+
# Grab and install xtensor-python from HaoZeke's fork
60+
# Replace with upstream after https://github.com/xtensor-stack/xtensor-python/pull/243
61+
download_and_rename "https://github.com/HaoZeke/xtensor-python/archive/refs/heads/addPkgConfig.tar.gz" "xtensor-python-addPkgConfig" "build-xtpy"
62+
cmake -S /tmp/build-xtpy -B /tmp/build-xtpy/build ${COMMON_CMAKE}
63+
cmake --build /tmp/build-xtpy/build --target install
64+
rm -rf /tmp/build-xtpy
65+
66+
unset CMAKE_PREFIX_PATH
67+
68+
# Build static NetCDF library
69+
curl -L https://github.com/Unidata/netcdf-c/archive/refs/tags/v${NETCDF_VERSION}.tar.gz | tar -xzC /tmp
70+
mkdir /tmp/build-netcdf
71+
if [ "$(getconf LONG_BIT)" -ge 64 ]; then
72+
CDF5_OPTION='-DENABLE_CDF5=ON'
73+
else
74+
CDF5_OPTION='-DENABLE_CDF5=OFF'
75+
fi
76+
cmake -S /tmp/netcdf-c-${NETCDF_VERSION} -B /tmp/build-netcdf ${COMMON_CMAKE} ${CDF5_OPTION} -DBUILD_TESTING=OFF -DBUILD_TESTSETS=OFF -DBUILD_UTILITIES=OFF -DENABLE_DAP=OFF -DENABLE_NETCDF4=OFF -DENABLE_NETCDF_4=OFF -DENABLE_PLUGINS=OFF
77+
cmake --build /tmp/build-netcdf --target install
78+
rm -rf /tmp/build-netcdf /tmp/netcdf-c-${NETCDF_VERSION}

0 commit comments

Comments
 (0)
Please sign in to comment.