Skip to content
This repository was archived by the owner on Mar 13, 2024. It is now read-only.
Open
129 changes: 104 additions & 25 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
@@ -1,43 +1,122 @@
# This is a GitHub Actions workflow that builds the package and publishes it to the PyPI, the Python Package Index.
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python

# Workflow syntax for GitHub Actions
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions

# This workflow was designed based on this guide:
# Publishing package distribution releases using GitHub Actions CI/CD workflows
# https://packaging.python.org/en/latest/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/

name: Python package

on: [push, pull_request]
# See:"Building and Publishing" on the Python Packaging User Guide
# https://packaging.python.org/en/latest/guides/section-build-and-publish/

on: push
name: Python package
jobs:
build:
test:
# https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners/about-github-hosted-runners
runs-on: ["ubuntu-22.04"]
runs-on: ubuntu-22.04
strategy:
fail-fast: true
matrix:
# https://devguide.python.org/versions/
python-version: ["3.9", "3.10", "3.11", "3.12"]
python-version: [ "3.9", "3.10", "3.11", "3.12" ]

steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
# Install package in editable mode with extra testing dependencies
pip install -e .[test]
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Test with pytest
run: |
pytest

# It runs whenever we publish a new release.
# https://docs.github.com/en/repositories/releasing-projects-on-github

build:
name: Build distribution
runs-on: ubuntu-22.04
needs: test
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Install build
run: |
python -m pip install --upgrade pip
python -m pip install build --user
- name: Build a binary wheel and a source tarball
run: python -m build
- name: Store the distribution packages
uses: actions/upload-artifact@v4
with:
name: python-package-distributions
path: dist/

# OpenID Connect token that the pypi-publish actions needs to implement secretless trusted publishing to PyPI
# https://docs.pypi.org/trusted-publishers/
publish-to-test-pypi:
name: Publish test PyPI
needs:
- build
runs-on: ubuntu-22.04
# https://test.pypi.org/manage/project/beelabel/settings/publishing/
environment:
name: testpypi
url: https://test.pypi.org/p/beelabel/
permissions:
# IMPORTANT: mandatory for trusted publishing
id-token: write
steps:
- name: Download all the dists
uses: actions/download-artifact@v4
with:
name: python-package-distributions
path: dist/
# https://github.com/marketplace/actions/pypi-publish
- name: Publish distribution to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://test.pypi.org/legacy/
# Don't complain on repeat uploads for the same package version
# https://github.com/marketplace/actions/pypi-publish#tolerating-release-package-file-duplicates
skip-existing: true

publish-to-pypi:
name: Publish to PyPI
# # only publish to PyPI on tag pushes
if: startsWith(github.ref, 'refs/tags/')
needs:
- publish-to-test-pypi
runs-on: ubuntu-22.04
environment:
name: pypi
url: https://pypi.org/p/beelabel/
permissions:
id-token: write
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
# Install package in editable mode with extra testing dependencies
pip install -e .[test]
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Test with pytest
run: |
pytest
- name: Download all the dists
uses: actions/download-artifact@v4
with:
name: python-package-distributions
path: dist/
# https://github.com/marketplace/actions/pypi-publish
- name: Publish distribution to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
17 changes: 15 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,24 @@

# Bee labelling

This repository contains Python code to perform bee 3D flight path inference. This finds a trajectory for a series of retrodetected images.
This repository contains Python code to perform bee 3D flight path inference. This finds a trajectory for a series of retro-detected images.

# Installation

TODO
To install this package from the [Python Package Index (PyPI)](https://pypi.org/project/beelabel/), create a virtual environment and [install using `pip`](https://pip.pypa.io/en/stable/cli/pip_install/).

```bash
# Create a virtual environemnt
python -m venv .venv
# Activate the environment
source .venv/bin/activate
```

Then install this package:

```bash
pip install beelabel
```

# Usage

Expand Down
4 changes: 4 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ build-backend = "setuptools.build_meta"
name = "beelabel"
description = "3D flight path inference using bee tracking images with retroreflection detection methods."
readme = "README.md"
# https://packaging.python.org/en/latest/guides/single-sourcing-package-version/
dynamic = ["version"]
requires-python = ">= 3.8"
dependencies = [
Expand Down Expand Up @@ -45,6 +46,9 @@ classifiers = [
"Programming Language :: Python :: 3.13",
]

[tool.setuptools.dynamic]
version = {attr = "beelabel.__version__"}

# https://peps.python.org/pep-0631/
[project.optional-dependencies]
test = [
Expand Down
1 change: 1 addition & 0 deletions src/beelabel/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__version__ = '0.0.1rc1'