Skip to content

Commit

Permalink
Fix conda builds (#1776)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
eberrigan committed May 20, 2024
1 parent 43a4f13 commit 6a0cf9c
Show file tree
Hide file tree
Showing 9 changed files with 156 additions and 17 deletions.
8 changes: 5 additions & 3 deletions .conda/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ requirements:
- conda-forge::ndx-pose
- conda-forge::importlib-metadata ==4.11.4

test:
imports:
- sleap
# This no longer works so we have moved it to the build workflow
# https://github.com/talmolab/sleap/pull/1744
# test:
# imports:
# - sleap
3 changes: 1 addition & 2 deletions .conda_mac/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@

# Install anything that didn't get conda installed via pip.
# We need to turn pip index back on because Anaconda turns it off for some reason.

export PIP_NO_INDEX=False
export PIP_NO_DEPENDENCIES=False
export PIP_IGNORE_INSTALLED=False

pip install --no-cache-dir -r requirements.txt --no-binary qudida,albumentations
pip install --no-cache-dir -r requirements.txt

python setup.py install --single-version-externally-managed --record=record.txt
1 change: 0 additions & 1 deletion .conda_mac/condarc.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# This file is not used at the moment, but when github actions can be used to build the package, it needs to be listed.
# https://github.com/github/roadmap/issues/528

channels:
Expand Down
10 changes: 5 additions & 5 deletions .conda_mac/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ source:

requirements:
host:
- conda-forge::python ~=3.9
- conda-forge::python >=3.9.0, <3.10.0
- anaconda::numpy >=1.19.5,<1.23.0
- conda-forge::setuptools
- conda-forge::packaging
Expand Down Expand Up @@ -59,7 +59,7 @@ requirements:
- conda-forge::ndx-pose

run:
- conda-forge::python ~=3.9
- conda-forge::python >=3.9.0, <3.10.0
- conda-forge::attrs >=21.2.0
- conda-forge::cattrs ==1.1.1
- conda-forge::h5py
Expand Down Expand Up @@ -89,6 +89,6 @@ requirements:
- conda-forge::albumentations
- conda-forge::ndx-pose

test:
imports:
- sleap
# test:
# imports:
# - sleap
68 changes: 68 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,74 @@ jobs:
run: |
conda build .conda_mac --output-folder build
# Test built conda package (Ubuntu and Windows)
- name: Test built conda package (Ubuntu and Windows)
if: matrix.os != 'macos-14'
shell: bash -l {0}
run: |
echo "Current build path: $BUILD_PATH"
conda deactivate
echo "Python executable before activating environment:"
which python
echo "Python version before activating environment:"
python --version
echo "Conda info before activating environment:"
conda info
echo "Creating and testing conda environment with sleap package..."
conda create -y -n sleap_test -c file://$BUILD_PATH -c sleap/label/dev -c conda-forge -c nvidia -c anaconda sleap
conda activate sleap_test
echo "Python executable after activating sleap_test environment:"
which python
echo "Python version after activating sleap_test environment:"
python --version
echo "Conda info after activating sleap_test environment:"
conda info
echo "List of installed conda packages in the sleap_test environment:"
conda list
echo "List of installed pip packages in the sleap_test environment:"
pip list
echo "Testing sleap package installation..."
sleap_version=$(python -c "import sleap; print(sleap.__version__)")
echo "Test completed using sleap version: $sleap_version"
# Test built conda package (Mac)
- name: Test built conda package (Mac)
if: matrix.os == 'macos-14'
shell: bash -l {0}
run: |
echo "Current build path: $BUILD_PATH"
conda deactivate
echo "Python executable before activating environment:"
which python
echo "Python version before activating environment:"
python --version
echo "Conda info before activating environment:"
conda info
echo "Creating and testing conda environment with sleap package..."
conda create -y -n sleap_test -c file://$BUILD_PATH -c conda-forge -c anaconda sleap
conda activate sleap_test
echo "Python executable after activating sleap_test environment:"
which python
echo "Python version after activating sleap_test environment:"
python --version
echo "Conda info after activating sleap_test environment:"
conda info
echo "List of installed conda packages in the sleap_test environment:"
conda list
echo "List of installed pip packages in the sleap_test environment:"
pip list
echo "Testing sleap package installation..."
sleap_version=$(python -c "import sleap; print(sleap.__version__)")
echo "Test completed using sleap version: $sleap_version"
# Login to conda (Ubuntu)
- name: Login to Anaconda (Ubuntu)
if: matrix.os == 'ubuntu-22.04'
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/build_ci.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Run tests using built conda packages and wheels.
# Run tests using built wheels.
name: Build CI (no upload)

# Run when changes to pip wheel
Expand Down Expand Up @@ -79,7 +79,8 @@ jobs:
strategy:
fail-fast: false
matrix:
os: ["ubuntu-22.04", "windows-2022", "macos-14"]
os: ["ubuntu-22.04", "windows-2022"]
# 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.
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstrategymatrixinclude
include:
# Default values
Expand Down
74 changes: 72 additions & 2 deletions .github/workflows/build_manual.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ on:
branches:
# - develop
- fakebranch
# - talmo/fix-mac-v140

jobs:
build:
Expand Down Expand Up @@ -83,20 +82,91 @@ jobs:
shell: bash -l {0}
run: |
conda build .conda --output-folder build
echo "BUILD_PATH=$(pwd)/build" >> "$GITHUB_ENV"
# Build conda package (Windows)
# Build conda package (Windows)
- name: Build conda package (Windows)
if: matrix.os == 'windows-2022'
shell: powershell
run: |
conda build .conda --output-folder build
echo "BUILD_PATH=\$(pwd)\build" >> "$env:GITHUB_ENV"
# Build conda package (Mac)
- name: Build conda package (Mac)
if: matrix.os == 'macos-14'
shell: bash -l {0}
run: |
conda build .conda_mac --output-folder build
echo "BUILD_PATH=$(pwd)/build" >> "$GITHUB_ENV"
# Test built conda package (Ubuntu and Windows)
- name: Test built conda package (Ubuntu and Windows)
if: matrix.os != 'macos-14'
shell: bash -l {0}
run: |
echo "Current build path: $BUILD_PATH"
conda deactivate
echo "Python executable before activating environment:"
which python
echo "Python version before activating environment:"
python --version
echo "Conda info before activating environment:"
conda info

echo "Creating and testing conda environment with sleap package..."
conda create -y -n sleap_test -c file://$BUILD_PATH -c sleap/label/dev -c conda-forge -c nvidia -c anaconda sleap
conda activate sleap_test

echo "Python executable after activating sleap_test environment:"
which python
echo "Python version after activating sleap_test environment:"
python --version
echo "Conda info after activating sleap_test environment:"
conda info
echo "List of installed conda packages in the sleap_test environment:"
conda list
echo "List of installed pip packages in the sleap_test environment:"
pip list

echo "Testing sleap package installation..."
sleap_version=$(python -c "import sleap; print(sleap.__version__)")
echo "Test completed using sleap version: $sleap_version"

# Test built conda package (Mac)
- name: Test built conda package (Mac)
if: matrix.os == 'macos-14'
shell: bash -l {0}
run: |
echo "Current build path: $BUILD_PATH"
conda deactivate
echo "Python executable before activating environment:"
which python
echo "Python version before activating environment:"
python --version
echo "Conda info before activating environment:"
conda info

echo "Creating and testing conda environment with sleap package..."
conda create -y -n sleap_test -c file://$BUILD_PATH -c conda-forge -c anaconda sleap
conda activate sleap_test

echo "Python executable after activating sleap_test environment:"
which python
echo "Python version after activating sleap_test environment:"
python --version
echo "Conda info after activating sleap_test environment:"
conda info
echo "List of installed conda packages in the sleap_test environment:"
conda list
echo "List of installed pip packages in the sleap_test environment:"
pip list

echo "Testing sleap package installation..."
sleap_version=$(python -c "import sleap; print(sleap.__version__)")
echo "Test completed using sleap version: $sleap_version"

# # Login to conda (Ubuntu)
# - name: Login to Anaconda (Ubuntu)
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# This file contains the minimal requirements to be installed via pip when using conda.

# No conda packages for these
imgstore<0.3.0 # 0.3.3 results in https://github.com/O365/python-o365/issues/591
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
nixio>=1.5.3 # Constrain put on by @jgrewe from G-Node
qimage2ndarray # ==1.9.0
segmentation-models
Expand Down
2 changes: 1 addition & 1 deletion sleap/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"""


__version__ = "1.4.0"
__version__ = "1.4.0a0"


def versions():
Expand Down

0 comments on commit 6a0cf9c

Please sign in to comment.