Skip to content

Commit

Permalink
Merge pull request #973 from mrapp-ke/python-version-file
Browse files Browse the repository at this point in the history
Add file specifying the minimum Python version
  • Loading branch information
michael-rapp authored Jul 7, 2024
2 parents c8d7685 + 70a64d5 commit a7df99a
Show file tree
Hide file tree
Showing 23 changed files with 103 additions and 38 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/merge_bugfix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ jobs:
ref: feature
- name: Reset bugfix branch
run: |
export FEATURE_VERSION="$(cat VERSION)"
export FEATURE_VERSION="$(cat .version)"
git fetch origin bugfix:bugfix
git reset --hard bugfix
echo -n "${FEATURE_VERSION}" > VERSION
echo -n "${FEATURE_VERSION}" > .version
- name: Generate token
uses: actions/create-github-app-token@v1
id: app-token
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/merge_feature.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ jobs:
ref: main
- name: Reset feature branch
run: |
export MAIN_VERSION="$(cat VERSION)"
export MAIN_VERSION="$(cat .version)"
git fetch origin feature:feature
git reset --hard feature
echo -n "${MAIN_VERSION}" > VERSION
echo -n "${MAIN_VERSION}" > .version
- name: Generate token
uses: actions/create-github-app-token@v1
id: app-token
Expand Down
26 changes: 13 additions & 13 deletions .github/workflows/merge_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
if: ${{ github.event.release.target_commitish == 'main' }}
run: |
./build reset_development_version
git add VERSION.dev && git commit -m "[Bot] Update development version to $(cat VERSION.dev)." && git push origin main
git add .version-dev && git commit -m "[Bot] Update development version to $(cat .version-dev)." && git push origin main
- name: Merge into feature branch
if: ${{ github.event.release.target_commitish == 'main' }}
run: |
Expand All @@ -47,37 +47,37 @@ jobs:
run: |
git checkout main
./build increment_major_version
git add VERSION
git commit -m "[Bot] Update version to $(cat VERSION)."
git add .version
git commit -m "[Bot] Update version to $(cat .version)."
git push origin main
git checkout feature
./build increment_minor_version
git add VERSION
git commit -m "[Bot] Update version to $(cat VERSION)."
git add .version
git commit -m "[Bot] Update version to $(cat .version)."
git push origin feature
git checkout bugfix
./build increment_patch_version
git add VERSION
git commit -m "[Bot] Update version to $(cat VERSION)."
git add .version
git commit -m "[Bot] Update version to $(cat .version)."
git push origin bugfix
- name: Update minor version
if: ${{ github.event.release.target_commitish == 'feature' }}
run: |
git checkout feature
./build increment_minor_version
git add VERSION
git commit -m "[Bot] Update version to $(cat VERSION)."
git add .version
git commit -m "[Bot] Update version to $(cat .version)."
git push origin feature
git checkout bugfix
./build increment_patch_version
git add VERSION
git commit -m "[Bot] Update version to $(cat VERSION)."
git add .version
git commit -m "[Bot] Update version to $(cat .version)."
git push origin bugfix
- name: Update patch version
if: ${{ github.event.release.target_commitish == 'bugfix' }}
run: |-
git checkout bugfix
./build increment_patch_version
git add VERSION
git commit -m "[Bot] Update version to $(cat VERSION)."
git add .version
git commit -m "[Bot] Update version to $(cat .version)."
git push origin bugfix
15 changes: 15 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,25 @@ on:
types:
- published
jobs:
read_python_version:
name: Read Python version
runs-on: ubuntu-latest
outputs:
python_version: ${{ steps.python_version.outputs.content }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Read Python version
uses: juliangruber/read-file-action@v1
id: python_version
with:
path: .version-python
publish_packages:
needs: read_python_version
name: Publish wheel packages
uses: ./.github/workflows/template_publish.yml
with:
python_version: ${{ needs.read_python_version.outputs.python_version }}
pypi_repository: pypi
secrets:
pypi_username: ${{ secrets.PYPI_USERNAME }}
Expand Down
22 changes: 19 additions & 3 deletions .github/workflows/release_development.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,30 @@ jobs:
- name: Update development version
run: |
./build increment_development_version
git add VERSION.dev
git commit -m "[Bot] Update development version to $(cat VERSION.dev)."
git add .version-dev
git commit -m "[Bot] Update development version to $(cat .version-dev)."
git push
read_python_version:
name: Read Python version
runs-on: ubuntu-latest
outputs:
python_version: ${{ steps.python_version.outputs.content }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Read Python version
uses: juliangruber/read-file-action@v1
id: python_version
with:
path: .version-python
publish_packages:
name: Publish wheel packages
needs: update_development_version
needs:
- update_development_version
- read_python_version
uses: ./.github/workflows/template_publish.yml
with:
python_version: ${{ needs.read_python_version.outputs.python_version }}
pypi_repository: testpypi
dev_release: true
secrets:
Expand Down
9 changes: 9 additions & 0 deletions .github/workflows/template_publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ name: Publish wheel packages
on:
workflow_call:
inputs:
python_version:
required: true
type: string
dev_release:
required: false
type: boolean
Expand Down Expand Up @@ -30,6 +33,7 @@ jobs:
uses: ./.github/workflows/template_publish_platform.yml
with:
subproject: common
python_version: ${{ inputs.python_version }}
dev_release: ${{ inputs.dev_release }}
pypi_repository: ${{ inputs.pypi_repository }}
secrets:
Expand All @@ -40,6 +44,7 @@ jobs:
uses: ./.github/workflows/template_publish_platform.yml
with:
subproject: boosting
python_version: ${{ inputs.python_version }}
dev_release: ${{ inputs.dev_release }}
pypi_repository: ${{ inputs.pypi_repository }}
secrets:
Expand All @@ -50,6 +55,7 @@ jobs:
uses: ./.github/workflows/template_publish_platform.yml
with:
subproject: seco
python_version: ${{ inputs.python_version }}
dev_release: ${{ inputs.dev_release }}
pypi_repository: ${{ inputs.pypi_repository }}
secrets:
Expand All @@ -60,6 +66,7 @@ jobs:
uses: ./.github/workflows/template_publish_non_native.yml
with:
subproject: common
python_version: ${{ inputs.python_version }}
dev_release: ${{ inputs.dev_release }}
pypi_repository: ${{ inputs.pypi_repository }}
secrets:
Expand All @@ -70,6 +77,7 @@ jobs:
uses: ./.github/workflows/template_publish_non_native.yml
with:
subproject: boosting
python_version: ${{ inputs.python_version }}
dev_release: ${{ inputs.dev_release }}
pypi_repository: ${{ inputs.pypi_repository }}
secrets:
Expand All @@ -80,6 +88,7 @@ jobs:
uses: ./.github/workflows/template_publish_non_native.yml
with:
subproject: seco
python_version: ${{ inputs.python_version }}
dev_release: ${{ inputs.dev_release }}
pypi_repository: ${{ inputs.pypi_repository }}
secrets:
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/template_publish_non_native.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ on:
subproject:
required: true
type: string
python_version:
required: true
type: string
dev_release:
required: false
type: boolean
Expand Down Expand Up @@ -44,6 +47,7 @@ jobs:
CIBW_BUILD_FRONTEND: build
CIBW_ARCHS_LINUX: aarch64
CIBW_SKIP: pp* *musllinux*
CIBW_PROJECT_REQUIRES_PYTHON: ${{ inputs.python_version }}
with:
package-dir: python/subprojects/${{ inputs.subproject }}/
- name: Setup Python
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/template_publish_platform.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ on:
subproject:
required: true
type: string
python_version:
required: true
type: string
dev_release:
required: false
type: boolean
Expand Down Expand Up @@ -55,6 +58,7 @@ jobs:
CIBW_BUILD_FRONTEND: build
CIBW_ARCHS: auto64
CIBW_SKIP: pp* *musllinux*
CIBW_PROJECT_REQUIRES_PYTHON: ${{ inputs.python_version }}
with:
package-dir: python/subprojects/${{ inputs.subproject }}/
- name: Setup Python
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/test_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ jobs:
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '>=3.9'
python-version-file: .version-python
- name: Install OpenCL
run: |
sudo apt update
Expand Down Expand Up @@ -133,7 +133,7 @@ jobs:
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '>=3.9'
python-version-file: .version-python
- name: Install OpenMP
run: brew install libomp
- name: Install OpenCL
Expand Down Expand Up @@ -166,7 +166,7 @@ jobs:
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '>=3.9'
python-version-file: .version-python
- name: Prepare MSVC
uses: ilammy/msvc-dev-cmd@v1
- name: Install OpenCL
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test_doc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ jobs:
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '>=3.9'
python-version-file: .version-python
- name: Prepare ccache
uses: hendrikmuhs/ccache-action@v1
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test_format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '>=3.9'
python-version-file: .version-python
- name: Detect changes
uses: dorny/paths-filter@v3
id: filter
Expand Down
8 changes: 8 additions & 0 deletions .github/workflows/test_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ jobs:
runs-on: ubuntu-latest
outputs:
build_files: ${{ steps.filter.outputs.build_files }}
python_version: ${{ steps.python_version.outputs.content }}
steps:
- name: Look up Git repository in cache
uses: actions/cache/restore@v4
Expand All @@ -36,6 +37,11 @@ jobs:
- 'build'
- 'build.bat'
- 'scons/**'
- name: Read Python version
uses: juliangruber/read-file-action@v1
id: python_version
with:
path: .version-python
- name: Save Git repository to cache
uses: actions/cache/save@v4
if: success() || failure()
Expand All @@ -47,3 +53,5 @@ jobs:
if: ${{ needs.changes.outputs.build_files == 'true' }}
name: Test publishing wheel packages
uses: ./.github/workflows/template_publish.yml
with:
python_version: ${{ needs.changes.outputs.python_version }}
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions .version-python
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
>=3.9
2 changes: 1 addition & 1 deletion cpp/subprojects/common/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ install_dir = install_root / meson.project_name() / 'mlrl' / meson.project_name(
# Obtain information about the library
lib_name = 'mlrl' + meson.project_name()
fs = import('fs')
version = fs.read('../../../VERSION')
version = fs.read('../../../.version')
target_architecture = host_machine.cpu_family() + '-' + host_machine.system()

# Check build options
Expand Down
2 changes: 1 addition & 1 deletion doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
author = 'Michael Rapp et al.'

# The full version, including alpha/beta/rc tags
release = (Path(__file__).resolve().parent.parent / 'VERSION').read_text()
release = (Path(__file__).resolve().parent.parent / '.version').read_text()

# -- General configuration ---------------------------------------------------

Expand Down
2 changes: 1 addition & 1 deletion doc/developer_guide/coding_standards.md
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ We do not allow directly pushing to the above branches. Instead, all changes mus

Once modifications to one of the branches have been merged, {ref}`ci` jobs are used to automatically update downstream branches via pull requests. If all checks for such pull requests are successful, they are merged automatically. If there are any merge conflicts, they must be resolved manually. Following this procedure, changes to the feature brach are merged into the main branch (see `merge_feature.yml`), whereas changes to the bugfix branch are first merged into the feature branch and then into the main branch (see `merge_bugfix.yml`).

Whenever a new release has been published, the release branch is merged into the upstream branches (see `merge_release.yml`), i.e., major releases result in the feature and bugfix branches being updated, whereas minor releases result in the bugfix branch being updated. The version of the release branch and the affected branches are updated accordingly. The version of a branch is specified in the file `VERSION` in the project's root directory. Similarly, the file `VERSION.dev` is used to keep track of the version number used for development releases (see `release_development.yml`).
Whenever a new release has been published, the release branch is merged into the upstream branches (see `merge_release.yml`), i.e., major releases result in the feature and bugfix branches being updated, whereas minor releases result in the bugfix branch being updated. The version of the release branch and the affected branches are updated accordingly. The version of a branch is specified in the file `.version` in the project's root directory. Similarly, the file `.version-dev` is used to keep track of the version number used for development releases (see `release_development.yml`).

(dependencies)=

Expand Down
6 changes: 4 additions & 2 deletions python/subprojects/boosting/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
from setuptools import Extension, find_packages, setup
from setuptools.command.build_ext import build_ext

VERSION = (Path(__file__).resolve().parent.parent.parent.parent / 'VERSION').read_text()
VERSION = (Path(__file__).resolve().parent.parent.parent.parent / '.version').read_text()

PYTHON_VERSION = (Path(__file__).resolve().parent.parent.parent.parent / '.version-python').read_text()


class PrecompiledExtension(Extension):
Expand Down Expand Up @@ -104,7 +106,7 @@ def find_extensions(directory):
'MacOS',
'Windows',
],
python_requires='>=3.9',
python_requires=PYTHON_VERSION,
install_requires=[
'mlrl-common==' + VERSION,
],
Expand Down
6 changes: 4 additions & 2 deletions python/subprojects/common/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
from setuptools import Extension, find_packages, setup
from setuptools.command.build_ext import build_ext

VERSION = (Path(__file__).resolve().parent.parent.parent.parent / 'VERSION').read_text()
VERSION = (Path(__file__).resolve().parent.parent.parent.parent / '.version').read_text()

PYTHON_VERSION = (Path(__file__).resolve().parent.parent.parent.parent / '.version-python').read_text()


class PrecompiledExtension(Extension):
Expand Down Expand Up @@ -124,7 +126,7 @@ def find_dependencies(requirements_file, dependency_names):
'MacOS',
'Windows',
],
python_requires='>=3.9',
python_requires=PYTHON_VERSION,
install_requires=[
find_dependencies(requirements_file=Path(__file__).resolve().parent.parent.parent / 'requirements.txt',
dependency_names=['numpy', 'scipy', 'scikit-learn']),
Expand Down
6 changes: 4 additions & 2 deletions python/subprojects/seco/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
from setuptools import Extension, find_packages, setup
from setuptools.command.build_ext import build_ext

VERSION = (Path(__file__).resolve().parent.parent.parent.parent / 'VERSION').read_text()
VERSION = (Path(__file__).resolve().parent.parent.parent.parent / '.version').read_text()

PYTHON_VERSION = (Path(__file__).resolve().parent.parent.parent.parent / '.version-python').read_text()


class PrecompiledExtension(Extension):
Expand Down Expand Up @@ -103,7 +105,7 @@ def find_extensions(directory):
'MacOS',
'Windows',
],
python_requires='>=3.9',
python_requires=PYTHON_VERSION,
install_requires=[
'mlrl-common==' + VERSION,
],
Expand Down
Loading

0 comments on commit a7df99a

Please sign in to comment.