Skip to content

Commit

Permalink
Add conda packaging and deployment to accessnri channel
Browse files Browse the repository at this point in the history
  • Loading branch information
aidanheerdegen committed Aug 15, 2024
1 parent b1539af commit f404bad
Show file tree
Hide file tree
Showing 8 changed files with 844 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
umpost/_version.py export-subst
40 changes: 40 additions & 0 deletions .github/workflows/CD.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: CD

on:
push:
branches:
- master

env:
PY_VERSION: 3.10

jobs:

conda:
name: Build with conda and upload
runs-on: ubuntu-latest
steps:
- name: Checkout source
uses: actions/checkout@v4
with:
fetch-tags: true
fetch-depth: 0

- name: Setup conda environment
uses: conda-incubator/setup-miniconda@11b562958363ec5770fef326fe8ef0366f8cbf8a
with:
miniconda-version: "latest"
python-version: ${{ env.PY_VERSION }}
environment-file: conda/environment.yml
auto-update-conda: false
auto-activate-base: false
show-channel-urls: true

- name: Build and upload the conda package
uses: uibcdf/action-build-and-upload-conda-packages@c6e7a90ad5e599d6cde76e130db4ee52ad733ecf
with:
meta_yaml_dir: conda
python-version: ${{ env.PY_VERSION }}
user: accessnri
label: main
token: ${{ secrets.anaconda_token }}
5 changes: 5 additions & 0 deletions .pylintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[MAIN]

# Files or directories to be skipped. They should be base names, not
# paths.
ignore=_version.py
13 changes: 13 additions & 0 deletions conda/environment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: um2nc

channels:
- conda-forge
- accessnri
- coecms
- defaults

dependencies:
- anaconda-client
- conda-build
- conda-verify
- versioneer
49 changes: 49 additions & 0 deletions conda/meta.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
{% set data = load_setup_py_data(setup_file='../setup.py', from_recipe_dir=True) %}
{% set version = data.get('version') %}
{% set pyproj = load_file_data('../pyproject.toml', from_recipe_dir=True) %}
{% set project = pyproj.get('project') %}

package:
name: um2nc
version: "{{ version }}"

build:
noarch: python
number: 0
script: "{{ python }} -m pip install . -vv"
entry_points:
{% for name, script in project.get('scripts', {}).items() %}
- {{ name }} = {{ script }}
{% endfor %}

source:
path: ../

requirements:
host:
- python
- pip
- setupools >=61.0.0
- versioneer
run:
- python >=3.10
{% for dep in project.get('dependencies', []) %}
- {{ dep }}
{% endfor %}

test:
imports:
- umpost
requires:
- pytest
source_files:
- test/**
commands:
- py.test

about:
home: https://github.com/access-nri/um2nc-standalone
license: Apache Software
license_family: Apache
summary: "Tool to convert fieldsfiles into netCDF format. Used for post-processing UM climate model output"

46 changes: 46 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
[project]
name = "um2nc"
authors = [
{name = "Ben Davies", email="[email protected]"},
{name = "Martin Dix", email="[email protected]"},
{name = "Spencer Wong", email="[email protected]"},
]
maintainers = [
{ name = "ACCESS-NRI", email = "[email protected]" }
]
description = "Program to convert Unified Model output files in fields file format to netCDF"
license = { text = "Apache-2.0" }
readme = "README.md"
keywords = ["netCDF", "UM", "postprocessing"]
dynamic = ["version"]
dependencies = [
"numpy",
"mule",
"cftime",
"netCDF4",
"scitools-iris",
"cf-units",
"PyYAML",
"f90nml",
]
[project.scripts]
um2nc = "umpost.um2netcdf:main"

[tool.versioneer]
VCS = "git"
style = "pep440"
versionfile_source = "umpost/_version.py"
versionfile_build = "umpost/_version.py"
tag_prefix = ""
parentdir_prefix = "umpost-"

[build-system]
build-backend = "setuptools.build_meta"
requires = [
"setuptools>64",
"versioneer[toml]"
]

[tool.setuptools.packages.find]
include = ["umpost*"]
namespaces = false
7 changes: 7 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from setuptools import setup
import versioneer

setup(
version=versioneer.get_version(),
cmdclass=versioneer.get_cmdclass(),
)
Loading

0 comments on commit f404bad

Please sign in to comment.