Skip to content

Commit d9cf203

Browse files
authored
fix rust ci, take 2 (#15)
* try not installing rust from `conda-forge` * link libpython on macos * guard against an unset `$CONDA_PREFIX` * more debugging * use the rust toolchain in python, too * use maturin to install the library * set `PYO3_PYTHON` to the python binary in PATH * create the path that is linked into * skip testing on windows * back to setting the absolute python path for pyo3 * skip windows for the python tests, as well * add a rust cache to speed up the builds
1 parent a93d621 commit d9cf203

File tree

3 files changed

+47
-14
lines changed

3 files changed

+47
-14
lines changed

.github/workflows/python-ci.yml

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,19 @@ jobs:
4545
strategy:
4646
fail-fast: false
4747
matrix:
48-
os: ["ubuntu-latest", "macos-latest", "windows-latest"]
48+
os:
49+
- "ubuntu-latest"
50+
- "macos-latest"
51+
# building the proj-sys crate appears to be tricky on windows
52+
# - "windows-latest"
4953
python-version: ["3.10", "3.12"]
5054

5155
steps:
5256
- uses: actions/checkout@v4
5357

58+
- name: Install Rust
59+
uses: dtolnay/rust-toolchain@stable
60+
5461
- name: Setup micromamba
5562
uses: mamba-org/setup-micromamba@v2
5663
with:
@@ -61,16 +68,24 @@ jobs:
6168
create-args: >-
6269
python=${{matrix.python-version}}
6370
71+
- name: Create rust cache
72+
uses: Swatinem/rust-cache@v2
73+
6474
- name: Help finding installed libraries
6575
run: |
6676
pushd $CONDA_PREFIX
6777
echo "PKG_CONFIG_PATH=$(readlink -f lib/pkgconfig)" >> $GITHUB_ENV
6878
echo "LD_LIBRARY_PATH=$(readlink -f lib)" >> $GITHUB_ENV
6979
popd
7080
81+
if [[ -z "$CONDA_PREFIX" ]]; then
82+
echo "CONDA_PREFIX is unset!"
83+
exit 1
84+
fi
85+
7186
- name: Install the package
7287
run: |
73-
python -m pip install --no-deps -e .
88+
maturin develop
7489
7590
- name: Check imports
7691
run: |

.github/workflows/rust-ci.yml

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,11 @@ jobs:
3939
strategy:
4040
fail-fast: false
4141
matrix:
42-
os: ["ubuntu-latest", "windows-latest", "macos-latest"]
42+
os:
43+
- "ubuntu-latest"
44+
# building proj-sys on windows appears to not really be possible
45+
# - "windows-latest"
46+
- "macos-latest"
4347
python-version: ["3.10", "3.12", "3.13"]
4448

4549
env:
@@ -52,6 +56,10 @@ jobs:
5256
steps:
5357
- name: Checkout
5458
uses: actions/checkout@v4
59+
60+
- name: Install Rust
61+
uses: dtolnay/rust-toolchain@stable
62+
5563
- name: Setup micromamba
5664
uses: mamba-org/setup-micromamba@v2
5765
with:
@@ -60,11 +68,9 @@ jobs:
6068
cache-environment: true
6169
cache-environment-key: "${{runner.os}}-${{runner.arch}}-rust-py${{ matrix.python-version }}-${{env.TODAY}}-${{hashFiles(env.CONDA_ENV_FILE)}}"
6270
create-args: >-
63-
rust>=1.83
6471
python=${{ matrix.python-version }}
6572
- name: Create rust cache
6673
uses: Swatinem/rust-cache@v2
67-
6874
- name: Help finding installed libraries
6975
run: |
7076
pushd $CONDA_PREFIX
@@ -74,6 +80,18 @@ jobs:
7480
export PYO3_PYTHON=$(readlink -f bin/python)
7581
popd
7682
83+
if [[ -z "$CONDA_PREFIX" ]]; then
84+
echo "CONDA_PREFIX is unset!";
85+
exit 1
86+
fi
87+
88+
if [[ "${{ matrix.os }}" == "macos-latest" ]]; then
89+
mkdir -p target/debug/deps
90+
ln -s "$CONDA_PREFIX/lib/libpython${{ matrix.python-version }}.dylib" target/debug/deps
91+
ls -l target/debug/deps
92+
ls -l $CONDA_PREFIX/lib
93+
fi
94+
7795
echo "PKG_CONFIG_PATH=$PKG_CONFIG_PATH" >> $GITHUB_ENV
7896
echo "LD_LIBRARY_PATH=$LD_LIBRARY_PATH" >> $GITHUB_ENV
7997
echo "CPATH=$CPATH" >> $GITHUB_ENV
@@ -97,11 +115,6 @@ jobs:
97115
cargo build --tests --keep-going
98116
cargo test --no-fail-fast
99117
100-
- name: Cleanup
101-
run: |
102-
unset LD_LIBRARY_PATH
103-
unset DYLD_LIBRARY_PATH
104-
105118
lint:
106119
name: Lint
107120
runs-on: ubuntu-latest
@@ -120,6 +133,12 @@ jobs:
120133
steps:
121134
- name: Checkout
122135
uses: actions/checkout@v4
136+
137+
- name: Install Rust
138+
uses: dtolnay/rust-toolchain@stable
139+
with:
140+
components: rustfmt, clippy
141+
123142
- name: Setup micromamba
124143
uses: mamba-org/setup-micromamba@v2
125144
with:
@@ -128,10 +147,11 @@ jobs:
128147
cache-environment: true
129148
cache-environment-key: "${{runner.os}}-${{runner.arch}}-rust-${{env.TODAY}}-${{hashFiles(env.CONDA_ENV_FILE)}}"
130149
create-args: >-
131-
rust>=1.83
132150
python=${{ matrix.python-version }}
151+
133152
- name: Create rust cache
134153
uses: Swatinem/rust-cache@v2
154+
135155
- name: Cargo clippy
136156
run: |
137157
cargo clippy --tests -- -D warnings

ci/requirements/environment.yaml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
channels:
22
- conda-forge
33
dependencies:
4-
- rust
4+
- maturin
55
- pkg-config
6-
- cxx-compiler
7-
- c-compiler
86
- proj
97
- sqlite
108
- shapely

0 commit comments

Comments
 (0)