Skip to content

Commit 10d88cc

Browse files
authored
Merge pull request #45 from ACCESS-NRI/davide/conda_package
Davide/conda package
2 parents 36012b3 + 764ac1f commit 10d88cc

18 files changed

+1016
-125
lines changed

.conda/env_build.yml

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
channels:
2+
- accessnri
3+
- conda-forge
4+
- nodefaults
5+
6+
dependencies:
7+
- anaconda-client
8+
- conda-build
9+
- conda-verify
10+
- versioneer

.conda/meta.yaml

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
{% set version = load_setup_py_data(setup_file='../setup.py', from_recipe_dir=True).get('version') %}
2+
{% set project = load_file_data('../pyproject.toml', from_recipe_dir=True).get('project') %}
3+
4+
package:
5+
name: {{ project.get('name') }}
6+
version: "{{ version }}"
7+
8+
build:
9+
noarch: python
10+
number: 0
11+
script: "python3 -m pip install . -vv"
12+
entry_points:
13+
{% for name, script in project.get('scripts').items() %}
14+
- {{ name }} = {{ script }}
15+
{% endfor %}
16+
17+
source:
18+
path: ../
19+
20+
requirements:
21+
host:
22+
- python
23+
- pip
24+
- setuptools >=61.0.0
25+
- versioneer
26+
run:
27+
{% for dep in project.get('dependencies') %}
28+
- {{ dep }}
29+
{% endfor %}
30+
31+
test:
32+
commands:
33+
{% for name, script in project.get('scripts').items() %}
34+
- {{ name }} --help
35+
{% endfor %}
36+
37+
about:
38+
home: {{ project.get('urls').get('Repository') }}
39+
license: Apache Software
40+
license_file: LICENSE
41+
summary: {{ project.get('description') }}
42+
license_family: Apache
43+

.github/archived_workflows/pylint.yml

-23
This file was deleted.

.github/workflows/CD.yml

+90
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
name: CD
2+
3+
on:
4+
push:
5+
tags:
6+
- '**'
7+
8+
jobs:
9+
get-package-name:
10+
name: Get package name
11+
runs-on: ubuntu-latest
12+
outputs:
13+
package-name: ${{ steps.get-package-name.outputs.package-name }}
14+
steps:
15+
- name: Checkout source
16+
uses: actions/checkout@v4
17+
with:
18+
fetch-tags: true
19+
fetch-depth: 0
20+
21+
- name: Get name
22+
id: get-package-name
23+
run: |
24+
echo "package-name=$(yq '.project.name' pyproject.toml)" >> $GITHUB_OUTPUT
25+
26+
release-conda-package:
27+
name: Build with conda and release
28+
runs-on: ubuntu-latest
29+
needs: get-package-name
30+
env:
31+
BUILD_FOLDER: ${{github.workspace}}/build
32+
PACKAGE_PATH: ${{github.workspace}}/build/noarch/*.tar.bz2
33+
permissions:
34+
contents: write
35+
steps:
36+
- name: Checkout source
37+
uses: actions/checkout@v4
38+
with:
39+
fetch-tags: true
40+
fetch-depth: 0
41+
42+
- name: Setup conda build environment
43+
uses: conda-incubator/setup-miniconda@a4260408e20b96e80095f42ff7f1a15b27dd94ca # v3.0.4
44+
with:
45+
miniconda-version: "latest"
46+
python-version: ${{ vars.PY_VERSION }}
47+
environment-file: .conda/env_build.yml
48+
auto-activate-base: false
49+
auto-update-conda: false
50+
show-channel-urls: true
51+
52+
- name: Build conda package
53+
shell: bash -el {0}
54+
run: |
55+
conda build . --no-anaconda-upload --output-folder=${{env.BUILD_FOLDER}} -c accessnri -c conda-forge -c coecms
56+
57+
- name: Upload conda package to Anaconda.org
58+
shell: bash -el {0}
59+
run: |
60+
anaconda -t ${{ secrets.ANACONDA_TOKEN }} upload --user ${{ secrets.ANACONDA_USER_NAME }} ${{env.PACKAGE_PATH}}
61+
62+
- name: Create Release
63+
uses: softprops/action-gh-release@c062e08bd532815e2082a85e87e3ef29c3e6d191 #v2.0.8
64+
with:
65+
tag_name: ${{ github.ref_name }}
66+
name: ${{needs.get-package-name.outputs.package-name}} ${{ github.ref_name }}
67+
generate_release_notes: true
68+
fail_on_unmatched_files: true
69+
files: |
70+
${{env.PACKAGE_PATH}}
71+
72+
# Dispatch the access-ram-condaenv repo (within the same GitHub organization) to update the conda environment
73+
# and deploy the new conda environment
74+
dispatch-access-ram-condaenv:
75+
name: Dispatch the ${{ github.repository_owner }}/access-ram-condaenv repo
76+
runs-on: ubuntu-latest
77+
needs: [get-package-name, release-conda-package]
78+
steps:
79+
- name: Dispatch repo
80+
uses: peter-evans/repository-dispatch@ff45666b9427631e3450c54a1bcbee4d9ff4d7c0 # v3.0.0
81+
with:
82+
token: ${{ secrets.ADMIN_TOKEN }}
83+
repository: ${{ github.repository_owner }}/access-ram-condaenv
84+
event-type: release
85+
client-payload: |-
86+
{
87+
"dependency": "${{needs.get-package-name.outputs.package-name}}",
88+
"version": "${{github.ref_name}}",
89+
"token": "${{secrets.ADMIN_TOKEN}}"
90+
}

.github/workflows/CI.yml

+96
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
name: CI
2+
3+
on:
4+
pull_request:
5+
branches: [main]
6+
push:
7+
branches: [main]
8+
workflow_dispatch:
9+
10+
jobs:
11+
changes:
12+
runs-on: ubuntu-latest
13+
permissions:
14+
pull-requests: read
15+
outputs:
16+
tracked-files: ${{ steps.filter.outputs.tracked-files }}
17+
steps:
18+
- name: Checkout code
19+
uses: actions/checkout@v4
20+
21+
- name: Filter files
22+
uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 #v3.0.2
23+
id: filter
24+
with:
25+
filters: |
26+
tracked-files:
27+
- 'setup.py'
28+
- 'pyproject.toml'
29+
- '.conda/**'
30+
- 'src/**'
31+
32+
verify-conda-build:
33+
name: Verify Conda Build
34+
runs-on: ubuntu-latest
35+
needs: changes
36+
# Only run if there are changes in the tracked files
37+
if: ${{ needs.changes.outputs.tracked-files == 'true' }}
38+
steps:
39+
- uses: actions/checkout@v4
40+
41+
- name: Setup conda build environment
42+
uses: conda-incubator/setup-miniconda@a4260408e20b96e80095f42ff7f1a15b27dd94ca # v3.0.4
43+
with:
44+
miniconda-version: "latest"
45+
python-version: ${{ vars.PY_VERSION }}
46+
environment-file: .conda/env_build.yml
47+
auto-activate-base: false
48+
auto-update-conda: false
49+
show-channel-urls: true
50+
51+
- name: Verify conda recipe
52+
shell: bash -el {0}
53+
run: conda-verify .conda --ignore C2105,C2122
54+
# C2105: invalid package version for 'replace_landsurface'
55+
# (there is no git tag in this test so versioneer outputs a
56+
# version that conda-verify recognizes as 'invalid')
57+
# C2122: invalid license family
58+
# Reference --> https://github.com/conda/conda-verify?tab=readme-ov-file#checks
59+
60+
- name: Build conda package
61+
shell: bash -el {0}
62+
run: conda build . --no-anaconda-upload --output-folder=./build -c accessnri -c conda-forge -c coecms
63+
64+
- name: Verify conda package
65+
shell: bash -el {0}
66+
run: conda-verify ./build/noarch/*.tar.bz2 --ignore C1105,C1115,C1141
67+
# C1105: invalid version number for 'replace_landsurface'
68+
# (there is no git tag in this test so versioneer outputs a
69+
# version that conda-verify recognizes as 'invalid')
70+
# C1115: Found invalid license
71+
# C1141: Found python file without a corresponding pyc file
72+
# Reference --> https://github.com/conda/conda-verify?tab=readme-ov-file#checks
73+
74+
- name: Upload Artifact
75+
uses: actions/upload-artifact@v4
76+
with:
77+
if-no-files-found: error
78+
path: ./build/noarch/*.tar.bz2
79+
80+
# Dispatch the access-ram-condaenv repo (within the same GitHub organization) to deploy the development conda environment
81+
dispatch-access-ram-condaenv:
82+
name: Dispatch the ${{ github.repository_owner }}/access-ram-condaenv repo
83+
runs-on: ubuntu-latest
84+
if : ${{ github.event_name == 'pull_request' }}
85+
needs: verify-conda-build
86+
steps:
87+
- name: Dispatch repo
88+
uses: peter-evans/repository-dispatch@ff45666b9427631e3450c54a1bcbee4d9ff4d7c0 # v3.0.0
89+
with:
90+
token: ${{ secrets.ADMIN_TOKEN }}
91+
repository: ${{ github.repository_owner }}/access-ram-condaenv
92+
event-type: prerelease
93+
client-payload: |-
94+
{
95+
"token": "${{secrets.ADMIN_TOKEN}}"
96+
}

.github/workflows/ci.yml

-15
This file was deleted.

.gitignore

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
test_data/
2+
.coverage
3+
*.sh
4+
__pycache__/
5+
*.py[cod]
6+
.ruff_cache/
7+
.mypy_cache/
8+
.pytest_cache/
9+
.vscode/

.pre-commit-config.yaml

-21
This file was deleted.

pyproject.toml

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
[project]
2+
name = "replace-landsurface"
3+
authors = [
4+
{name = "Chermelle Engel", email="[email protected]"},
5+
{name = "Davide Marchegiani", email="[email protected]"},
6+
{name = "Paul Leopardi", email="[email protected]"},
7+
]
8+
maintainers = [
9+
{ name = "ACCESS-NRI", email = "[email protected]" }
10+
]
11+
description = "Package to replace specific land surface fields to be used within ACCESS-RAM suites."
12+
license = { file = "LICENSE" }
13+
readme = "README.md"
14+
keywords = ["ACCESS-RAM", "Regional Nesting Suite", "Replace Land Surface"]
15+
dynamic = ["version"]
16+
dependencies = [
17+
"python >=3.10,<=3.12",
18+
"mule",
19+
"numpy ==1.23.4", # https://stackoverflow.com/a/75148219/21024780
20+
"scitools-iris",
21+
"xarray",
22+
"versioneer",
23+
]
24+
25+
[project.urls]
26+
Repository = "https://github.com/ACCESS-NRI/replace_landsurface"
27+
28+
[project.scripts]
29+
hres_eccb = "replace_landsurface.hres_eccb:main"
30+
hres_ic = "replace_landsurface.hres_ic:main"
31+
32+
[build-system]
33+
build-backend = "setuptools.build_meta"
34+
requires = [
35+
"setuptools>64",
36+
"versioneer[toml]"
37+
]
38+
39+
[tool.setuptools.packages.find]
40+
where = ["src"]
41+
namespaces = false
42+
43+
[tool.versioneer]
44+
VCS = "git"
45+
style = "pep440"
46+
versionfile_source = "src/replace_landsurface/_version.py"
47+
versionfile_build = "replace_landsurface/_version.py"
48+
tag_prefix = ""
49+
parentdir_prefix = "replace-landsurface-"

0 commit comments

Comments
 (0)