Skip to content

Commit 6a0cf9c

Browse files
authored
Fix conda builds (#1776)
* test conda packages in a test environment as part of CI * do not test sleap import using conda build * use github environment variables to define build path for each OS in the matrix and add print statements for testing * figure out paths one OS at a time * github environment variables work in subsequent steps not current step * use local builds first * print env info * try simple environment creation * try conda instead of mamba * fix windows build path * fix windows build path * add comment to reference pull request * remove test stage from conda build for macs and test instead by creating the environment in a workflow * test workflow by pushing to current branch * test conda package on macos runner * Mac build does not need nvidia channel * qudida and albumentations are conda installed now * add comment with original issue * use python 3.9 * use conda match specifications syntax * make print statements more readable for troubleshooting python versioning * clean up build file * update version for pre-release * add TODO * add tests for conda packages before uploading * update ci comments and branches * remove macos test of pip wheel since python 3.9 is not supported by setup-python action
1 parent 43a4f13 commit 6a0cf9c

File tree

9 files changed

+156
-17
lines changed

9 files changed

+156
-17
lines changed

.conda/meta.yaml

+5-3
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,8 @@ requirements:
9191
- conda-forge::ndx-pose
9292
- conda-forge::importlib-metadata ==4.11.4
9393

94-
test:
95-
imports:
96-
- sleap
94+
# This no longer works so we have moved it to the build workflow
95+
# https://github.com/talmolab/sleap/pull/1744
96+
# test:
97+
# imports:
98+
# - sleap

.conda_mac/build.sh

+1-2
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,10 @@
22

33
# Install anything that didn't get conda installed via pip.
44
# We need to turn pip index back on because Anaconda turns it off for some reason.
5-
65
export PIP_NO_INDEX=False
76
export PIP_NO_DEPENDENCIES=False
87
export PIP_IGNORE_INSTALLED=False
98

10-
pip install --no-cache-dir -r requirements.txt --no-binary qudida,albumentations
9+
pip install --no-cache-dir -r requirements.txt
1110

1211
python setup.py install --single-version-externally-managed --record=record.txt

.conda_mac/condarc.yaml

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# This file is not used at the moment, but when github actions can be used to build the package, it needs to be listed.
21
# https://github.com/github/roadmap/issues/528
32

43
channels:

.conda_mac/meta.yaml

+5-5
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ source:
2323

2424
requirements:
2525
host:
26-
- conda-forge::python ~=3.9
26+
- conda-forge::python >=3.9.0, <3.10.0
2727
- anaconda::numpy >=1.19.5,<1.23.0
2828
- conda-forge::setuptools
2929
- conda-forge::packaging
@@ -59,7 +59,7 @@ requirements:
5959
- conda-forge::ndx-pose
6060

6161
run:
62-
- conda-forge::python ~=3.9
62+
- conda-forge::python >=3.9.0, <3.10.0
6363
- conda-forge::attrs >=21.2.0
6464
- conda-forge::cattrs ==1.1.1
6565
- conda-forge::h5py
@@ -89,6 +89,6 @@ requirements:
8989
- conda-forge::albumentations
9090
- conda-forge::ndx-pose
9191

92-
test:
93-
imports:
94-
- sleap
92+
# test:
93+
# imports:
94+
# - sleap

.github/workflows/build.yml

+68
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,74 @@ jobs:
8484
run: |
8585
conda build .conda_mac --output-folder build
8686
87+
# Test built conda package (Ubuntu and Windows)
88+
- name: Test built conda package (Ubuntu and Windows)
89+
if: matrix.os != 'macos-14'
90+
shell: bash -l {0}
91+
run: |
92+
echo "Current build path: $BUILD_PATH"
93+
conda deactivate
94+
95+
echo "Python executable before activating environment:"
96+
which python
97+
echo "Python version before activating environment:"
98+
python --version
99+
echo "Conda info before activating environment:"
100+
conda info
101+
102+
echo "Creating and testing conda environment with sleap package..."
103+
conda create -y -n sleap_test -c file://$BUILD_PATH -c sleap/label/dev -c conda-forge -c nvidia -c anaconda sleap
104+
conda activate sleap_test
105+
106+
echo "Python executable after activating sleap_test environment:"
107+
which python
108+
echo "Python version after activating sleap_test environment:"
109+
python --version
110+
echo "Conda info after activating sleap_test environment:"
111+
conda info
112+
echo "List of installed conda packages in the sleap_test environment:"
113+
conda list
114+
echo "List of installed pip packages in the sleap_test environment:"
115+
pip list
116+
117+
echo "Testing sleap package installation..."
118+
sleap_version=$(python -c "import sleap; print(sleap.__version__)")
119+
echo "Test completed using sleap version: $sleap_version"
120+
121+
# Test built conda package (Mac)
122+
- name: Test built conda package (Mac)
123+
if: matrix.os == 'macos-14'
124+
shell: bash -l {0}
125+
run: |
126+
echo "Current build path: $BUILD_PATH"
127+
conda deactivate
128+
129+
echo "Python executable before activating environment:"
130+
which python
131+
echo "Python version before activating environment:"
132+
python --version
133+
echo "Conda info before activating environment:"
134+
conda info
135+
136+
echo "Creating and testing conda environment with sleap package..."
137+
conda create -y -n sleap_test -c file://$BUILD_PATH -c conda-forge -c anaconda sleap
138+
conda activate sleap_test
139+
140+
echo "Python executable after activating sleap_test environment:"
141+
which python
142+
echo "Python version after activating sleap_test environment:"
143+
python --version
144+
echo "Conda info after activating sleap_test environment:"
145+
conda info
146+
echo "List of installed conda packages in the sleap_test environment:"
147+
conda list
148+
echo "List of installed pip packages in the sleap_test environment:"
149+
pip list
150+
151+
echo "Testing sleap package installation..."
152+
sleap_version=$(python -c "import sleap; print(sleap.__version__)")
153+
echo "Test completed using sleap version: $sleap_version"
154+
87155
# Login to conda (Ubuntu)
88156
- name: Login to Anaconda (Ubuntu)
89157
if: matrix.os == 'ubuntu-22.04'

.github/workflows/build_ci.yml

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Run tests using built conda packages and wheels.
1+
# Run tests using built wheels.
22
name: Build CI (no upload)
33

44
# Run when changes to pip wheel
@@ -79,7 +79,8 @@ jobs:
7979
strategy:
8080
fail-fast: false
8181
matrix:
82-
os: ["ubuntu-22.04", "windows-2022", "macos-14"]
82+
os: ["ubuntu-22.04", "windows-2022"]
83+
# os: ["ubuntu-22.04", "windows-2022", "macos-14"] # removing macos-14 for now since the setup-python action only support py>=3.10, which is breaking this CI.
8384
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstrategymatrixinclude
8485
include:
8586
# Default values

.github/workflows/build_manual.yml

+72-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ on:
1212
branches:
1313
# - develop
1414
- fakebranch
15-
# - talmo/fix-mac-v140
1615

1716
jobs:
1817
build:
@@ -83,20 +82,91 @@ jobs:
8382
shell: bash -l {0}
8483
run: |
8584
conda build .conda --output-folder build
85+
echo "BUILD_PATH=$(pwd)/build" >> "$GITHUB_ENV"
8686
87-
# Build conda package (Windows)
87+
# Build conda package (Windows)
8888
- name: Build conda package (Windows)
8989
if: matrix.os == 'windows-2022'
9090
shell: powershell
9191
run: |
9292
conda build .conda --output-folder build
93+
echo "BUILD_PATH=\$(pwd)\build" >> "$env:GITHUB_ENV"
9394
9495
# Build conda package (Mac)
9596
- name: Build conda package (Mac)
9697
if: matrix.os == 'macos-14'
9798
shell: bash -l {0}
9899
run: |
99100
conda build .conda_mac --output-folder build
101+
echo "BUILD_PATH=$(pwd)/build" >> "$GITHUB_ENV"
102+
103+
# Test built conda package (Ubuntu and Windows)
104+
- name: Test built conda package (Ubuntu and Windows)
105+
if: matrix.os != 'macos-14'
106+
shell: bash -l {0}
107+
run: |
108+
echo "Current build path: $BUILD_PATH"
109+
conda deactivate
110+
111+
echo "Python executable before activating environment:"
112+
which python
113+
echo "Python version before activating environment:"
114+
python --version
115+
echo "Conda info before activating environment:"
116+
conda info
117+
118+
echo "Creating and testing conda environment with sleap package..."
119+
conda create -y -n sleap_test -c file://$BUILD_PATH -c sleap/label/dev -c conda-forge -c nvidia -c anaconda sleap
120+
conda activate sleap_test
121+
122+
echo "Python executable after activating sleap_test environment:"
123+
which python
124+
echo "Python version after activating sleap_test environment:"
125+
python --version
126+
echo "Conda info after activating sleap_test environment:"
127+
conda info
128+
echo "List of installed conda packages in the sleap_test environment:"
129+
conda list
130+
echo "List of installed pip packages in the sleap_test environment:"
131+
pip list
132+
133+
echo "Testing sleap package installation..."
134+
sleap_version=$(python -c "import sleap; print(sleap.__version__)")
135+
echo "Test completed using sleap version: $sleap_version"
136+
137+
# Test built conda package (Mac)
138+
- name: Test built conda package (Mac)
139+
if: matrix.os == 'macos-14'
140+
shell: bash -l {0}
141+
run: |
142+
echo "Current build path: $BUILD_PATH"
143+
conda deactivate
144+
145+
echo "Python executable before activating environment:"
146+
which python
147+
echo "Python version before activating environment:"
148+
python --version
149+
echo "Conda info before activating environment:"
150+
conda info
151+
152+
echo "Creating and testing conda environment with sleap package..."
153+
conda create -y -n sleap_test -c file://$BUILD_PATH -c conda-forge -c anaconda sleap
154+
conda activate sleap_test
155+
156+
echo "Python executable after activating sleap_test environment:"
157+
which python
158+
echo "Python version after activating sleap_test environment:"
159+
python --version
160+
echo "Conda info after activating sleap_test environment:"
161+
conda info
162+
echo "List of installed conda packages in the sleap_test environment:"
163+
conda list
164+
echo "List of installed pip packages in the sleap_test environment:"
165+
pip list
166+
167+
echo "Testing sleap package installation..."
168+
sleap_version=$(python -c "import sleap; print(sleap.__version__)")
169+
echo "Test completed using sleap version: $sleap_version"
100170

101171
# # Login to conda (Ubuntu)
102172
# - name: Login to Anaconda (Ubuntu)

requirements.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# This file contains the minimal requirements to be installed via pip when using conda.
22

33
# No conda packages for these
4-
imgstore<0.3.0 # 0.3.3 results in https://github.com/O365/python-o365/issues/591
4+
imgstore<0.3.0 # 0.3.3 results in https://github.com/O365/python-o365/issues/591 which is from https://github.com/regebro/tzlocal/issues/112 when tzlocal is v3.0
55
nixio>=1.5.3 # Constrain put on by @jgrewe from G-Node
66
qimage2ndarray # ==1.9.0
77
segmentation-models

sleap/version.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"""
1313

1414

15-
__version__ = "1.4.0"
15+
__version__ = "1.4.0a0"
1616

1717

1818
def versions():

0 commit comments

Comments
 (0)