generated from ACCESS-NRI/template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from ACCESS-NRI/davide/conda_package
Set up conda package
- Loading branch information
Showing
11 changed files
with
1,004 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
channels: | ||
- accessnri | ||
- conda-forge | ||
- nodefaults | ||
|
||
dependencies: | ||
- anaconda-client | ||
- conda-build | ||
- conda-verify | ||
- versioneer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
{% set version = load_setup_py_data(setup_file='../setup.py', from_recipe_dir=True).get('version') %} | ||
{% set project = load_file_data('../pyproject.toml', from_recipe_dir=True).get('project') %} | ||
|
||
package: | ||
name: {{ project.get('name') }} | ||
version: "{{ version }}" | ||
|
||
build: | ||
noarch: python | ||
number: 0 | ||
script: "python3 -m pip install . -vv" | ||
entry_points: | ||
{% for name, script in project.get('scripts').items() %} | ||
- {{ name }} = {{ script }} | ||
{% endfor %} | ||
|
||
source: | ||
path: ../ | ||
|
||
requirements: | ||
host: | ||
- python | ||
- pip | ||
- setuptools >=61.0.0 | ||
- versioneer | ||
run: | ||
{% for dep in project.get('dependencies') %} | ||
- {{ dep }} | ||
{% endfor %} | ||
|
||
test: | ||
commands: | ||
{% for name, script in project.get('scripts').items() %} | ||
- {{ name }} --help | ||
{% endfor %} | ||
|
||
about: | ||
home: {{ project.get('urls').get('Repository') }} | ||
license: Apache Software | ||
license_file: LICENSE | ||
summary: {{ project.get('description') }} | ||
license_family: Apache | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
name: CD | ||
|
||
on: | ||
push: | ||
tags: | ||
- '**' | ||
|
||
jobs: | ||
get-package-name: | ||
name: Get package name | ||
runs-on: ubuntu-latest | ||
outputs: | ||
package-name: ${{ steps.get-package-name.outputs.package-name }} | ||
steps: | ||
- name: Checkout source | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-tags: true | ||
fetch-depth: 0 | ||
|
||
- name: Get name | ||
id: get-package-name | ||
run: | | ||
echo "package-name=$(yq '.project.name' pyproject.toml)" >> $GITHUB_OUTPUT | ||
release-conda-package: | ||
name: Build with conda and release | ||
runs-on: ubuntu-latest | ||
needs: get-package-name | ||
env: | ||
BUILD_FOLDER: ${{github.workspace}}/build | ||
PACKAGE_PATH: ${{github.workspace}}/build/noarch/*.tar.bz2 | ||
permissions: | ||
contents: write | ||
steps: | ||
- name: Checkout source | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-tags: true | ||
fetch-depth: 0 | ||
|
||
- name: Setup conda build environment | ||
uses: conda-incubator/setup-miniconda@a4260408e20b96e80095f42ff7f1a15b27dd94ca # v3.0.4 | ||
with: | ||
miniconda-version: "latest" | ||
python-version: ${{ vars.PY_VERSION }} | ||
environment-file: .conda/env_build.yml | ||
auto-activate-base: false | ||
auto-update-conda: false | ||
show-channel-urls: true | ||
|
||
- name: Build conda package | ||
shell: bash -el {0} | ||
run: | | ||
conda build . --no-anaconda-upload --output-folder=${{env.BUILD_FOLDER}} -c accessnri -c conda-forge -c coecms | ||
- name: Upload conda package to Anaconda.org | ||
shell: bash -el {0} | ||
run: | | ||
anaconda -t ${{ secrets.ANACONDA_TOKEN }} upload --user ${{ secrets.ANACONDA_USER_NAME }} ${{env.PACKAGE_PATH}} | ||
- name: Create Release | ||
uses: softprops/action-gh-release@c062e08bd532815e2082a85e87e3ef29c3e6d191 #v2.0.8 | ||
with: | ||
tag_name: ${{ github.ref_name }} | ||
name: ${{needs.get-package-name.outputs.package-name}} ${{ github.ref_name }} | ||
generate_release_notes: true | ||
fail_on_unmatched_files: true | ||
files: | | ||
${{env.PACKAGE_PATH}} | ||
# Dispatch the access-ram-condaenv repo (within the same GitHub organization) to update the conda environment | ||
# and deploy the new conda environment | ||
dispatch-access-ram-condaenv: | ||
name: Dispatch the ${{ github.repository_owner }}/access-ram-condaenv repo | ||
runs-on: ubuntu-latest | ||
needs: [get-package-name, release-conda-package] | ||
steps: | ||
- name: Dispatch repo | ||
uses: peter-evans/repository-dispatch@ff45666b9427631e3450c54a1bcbee4d9ff4d7c0 # v3.0.0 | ||
with: | ||
token: ${{ secrets.ADMIN_TOKEN }} | ||
repository: ${{ github.repository_owner }}/access-ram-condaenv | ||
event-type: release | ||
client-payload: |- | ||
{ | ||
"dependency": "${{needs.get-package-name.outputs.package-name}}", | ||
"version": "${{github.ref_name}}", | ||
"token": "${{secrets.ADMIN_TOKEN}}" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
name: CI | ||
|
||
on: | ||
pull_request: | ||
branches: [main] | ||
push: | ||
branches: [main] | ||
workflow_dispatch: | ||
|
||
jobs: | ||
changes: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
pull-requests: read | ||
outputs: | ||
tracked-files: ${{ steps.filter.outputs.tracked-files }} | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Filter files | ||
uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 #v3.0.2 | ||
id: filter | ||
with: | ||
filters: | | ||
tracked-files: | ||
- 'setup.py' | ||
- 'pyproject.toml' | ||
- '.conda/**' | ||
- 'src/**' | ||
verify-conda-build: | ||
name: Verify Conda Build | ||
runs-on: ubuntu-latest | ||
needs: changes | ||
# Only run if there are changes in the tracked files | ||
if: ${{ needs.changes.outputs.tracked-files == 'true' }} | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Setup conda build environment | ||
uses: conda-incubator/setup-miniconda@a4260408e20b96e80095f42ff7f1a15b27dd94ca # v3.0.4 | ||
with: | ||
miniconda-version: "latest" | ||
python-version: ${{ vars.PY_VERSION }} | ||
environment-file: .conda/env_build.yml | ||
auto-activate-base: false | ||
auto-update-conda: false | ||
show-channel-urls: true | ||
|
||
- name: Verify conda recipe | ||
shell: bash -el {0} | ||
run: conda-verify .conda --ignore C2105,C2122 | ||
# C2105: invalid package version for 'replace_landsurface' | ||
# (there is no git tag in this test so versioneer outputs a | ||
# version that conda-verify recognizes as 'invalid') | ||
# C2122: invalid license family | ||
# Reference --> https://github.com/conda/conda-verify?tab=readme-ov-file#checks | ||
|
||
- name: Build conda package | ||
shell: bash -el {0} | ||
run: conda build . --no-anaconda-upload --output-folder=./build -c accessnri -c conda-forge -c coecms | ||
|
||
- name: Verify conda package | ||
shell: bash -el {0} | ||
run: conda-verify ./build/noarch/*.tar.bz2 --ignore C1105,C1115,C1141 | ||
# C1105: invalid version number for 'replace_landsurface' | ||
# (there is no git tag in this test so versioneer outputs a | ||
# version that conda-verify recognizes as 'invalid') | ||
# C1115: Found invalid license | ||
# C1141: Found python file without a corresponding pyc file | ||
# Reference --> https://github.com/conda/conda-verify?tab=readme-ov-file#checks | ||
|
||
- name: Upload Artifact | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
if-no-files-found: error | ||
path: ./build/noarch/*.tar.bz2 | ||
|
||
# Dispatch the access-ram-condaenv repo (within the same GitHub organization) to deploy the development conda environment | ||
dispatch-access-ram-condaenv: | ||
name: Dispatch the ${{ github.repository_owner }}/access-ram-condaenv repo | ||
runs-on: ubuntu-latest | ||
if : ${{ github.event_name == 'pull_request' }} | ||
needs: verify-conda-build | ||
steps: | ||
- name: Dispatch repo | ||
uses: peter-evans/repository-dispatch@ff45666b9427631e3450c54a1bcbee4d9ff4d7c0 # v3.0.0 | ||
with: | ||
token: ${{ secrets.ADMIN_TOKEN }} | ||
repository: ${{ github.repository_owner }}/access-ram-condaenv | ||
event-type: prerelease | ||
client-payload: |- | ||
{ | ||
"token": "${{secrets.ADMIN_TOKEN}}" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
test_data/ | ||
.coverage | ||
__pycache__/ | ||
*.py[cod] | ||
.ruff_cache/ | ||
.mypy_cache/ | ||
.pytest_cache/ | ||
.vscode/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
[project] | ||
name = "era5grib-parallel" | ||
authors = [ | ||
{name = "Chermelle Engel", email="[email protected]"}, | ||
{name = "Davide Marchegiani", email="[email protected]"}, | ||
] | ||
maintainers = [ | ||
{ name = "ACCESS-NRI", email = "[email protected]" } | ||
] | ||
description = "Package to set up era5 grib files for use within ACCESS-RAM suites." | ||
license = { file = "LICENSE" } | ||
readme = "README.md" | ||
keywords = ["ACCESS-RAM", "Regional Nesting Suite", "era5grib"] | ||
dynamic = ["version"] | ||
dependencies = [ | ||
"python >=3.10,<=3.12", | ||
"cdo", | ||
"numpy <2", | ||
"pandas", | ||
"versioneer", | ||
] | ||
|
||
[project.urls] | ||
Repository = "https://github.com/ACCESS-NRI/era5_grib_parallel" | ||
|
||
[project.scripts] | ||
era5grib_parallel = "era5grib_parallel.nci_era5grib_parallel:main" | ||
|
||
[build-system] | ||
build-backend = "setuptools.build_meta" | ||
requires = [ | ||
"setuptools>64", | ||
"versioneer[toml]" | ||
] | ||
|
||
[tool.setuptools.packages.find] | ||
where = ["src"] | ||
namespaces = false | ||
|
||
[tool.versioneer] | ||
VCS = "git" | ||
style = "pep440" | ||
versionfile_source = "src/era5grib_parallel/_version.py" | ||
versionfile_build = "era5grib_parallel/_version.py" | ||
tag_prefix = "" | ||
parentdir_prefix = "era5grib-parallel-" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import versioneer | ||
from setuptools import setup | ||
|
||
setup( | ||
version=versioneer.get_version(), | ||
cmdclass=versioneer.get_cmdclass(), | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# Copyright 2024 ACCESS-NRI (https://www.access-nri.org.au/) | ||
# See the top-level COPYRIGHT.txt file for details. | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
from era5grib_parallel import _version | ||
|
||
__version__ = _version.get_versions()["version"] |
Oops, something went wrong.