Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setup python packaging for pypi and conda #9

Merged
merged 2 commits into from
Aug 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .conda/environment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
channels:
- conda-forge
- accessnri
- default

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

package:
name: med_diagnostics
version: "{{ version }}"

source:
url: "https://pypi.io/packages/source/a/med-diagnostics/med_diagnostics-{{ version }}.tar.gz"

build:
noarch: python
number: 0
script: "{{ PYTHON }} -m pip install . -vv"

requirements:
host:
- python
- pip
- versioneer
run:
- python >=3.10
- access-nri-intake
- apscheduler
- panel
- matplotlib

about:
home: https://github.com/ACCESS-NRI/med-live-diagnostics
license: Apache Software
license_family: APACHE
summary: "Interactive monitoring and diagnostic analyses of ACCESS climate models"
doc_url: https://med-live-diagnostics.readthedocs.io/en/latest

extra:
recipe-maintainers:
- mtetley
- rbeucher
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
src/med_diagnostics/_version.py export-subst
20 changes: 20 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
name: Bug report
about: Create an issue to report a bug
title: "[BUG] <description of the bug>"
labels: bug
assignees: ''

---

# Describe the bug

<Replace this text with a clear and concise description of the bug. You can add screen shots by dragging them into this panel. If your code errored, please include the traceback here.>

# To Reproduce

<Replace this text with a description of how to reproduce the bug. See [these guidelines](http://matthewrocklin.com/blog/work/2018/02/28/minimal-bug-reports) on how to provide a good bug report. Bug reports that follow these guidelines are easier to diagnose, and so are often handled much more quickly.>

# Additional context

<Replace this text with any other relevant information about the problem>
24 changes: 24 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
---
name: Feature request
about: Create an issue to suggest an idea for this project
title: ''
labels: enhancement
assignees: ''

---

# Is your feature request related to a problem? Please describe.

<Replace this text with a clear and concise description of what the problem is.>

# Describe the feature you'd like

<Replace this text with a clear and concise description of what you want to happen.>

# Describe alternatives you've considered

<Replace this text with a clear and concise description of any alternative solutions or features you've considered.>

# Additional context

<Replace this text with any other relevant information about your suggestion>
11 changes: 11 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates

version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
62 changes: 62 additions & 0 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: CD

on: [push, pull_request]

jobs:
pypi:
name: build and deploy to PyPI
if: github.repository == 'ACCESS-NRI/MED-live-diagnostics' && github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
runs-on: "ubuntu-latest"
permissions:
id-token: write

steps:
- name: Checkout source
uses: actions/checkout@v3

- name: Set up Python 3.11
uses: actions/setup-python@v4
with:
python-version: 3.11

- name: Install build dependencies
run: python -m pip install build twine

- name: Build distributions
shell: bash -l {0}
run: |
git clean -xdf
pyproject-build

- name: Publish package to PyPI
uses: pypa/gh-action-pypi-publish@release/v1

conda:
name: build and deploy to conda
needs: pypi
if: always() && needs.pypi.result == 'success'
runs-on: "ubuntu-latest"

steps:
- name: Checkout source
uses: actions/checkout@v3

- name: Setup conda environment
uses: conda-incubator/setup-miniconda@v2
with:
miniconda-version: "latest"
python-version: 3.11
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/[email protected]
with:
meta_yaml_dir: .conda
python-version: 3.11
user: accessnri
label: main
token: ${{ secrets.anaconda_token }}

36 changes: 36 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
[project]
name = "med-diagnostics"
authors = [
{ name = "ACCESS-NRI" },
]
description = "ACCESS MED-Diagnostics"
readme = "README.md"
requires-python = ">=3.10"
license = {text = "APACHE-2.0"}
classifiers = [
"Development Status :: 4 - Beta",
"Programming Language :: Python :: 3",
"License :: OSI Approved :: Apache Software License",
"Operating System :: OS Independent",
]
dependencies = ["apscheduler", "access-nri-intake", "panel", "matplotlib"]
dynamic = ["version"]

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


[tool.setuptools.packages.find]
where = ["src"]

[tool.versioneer]
VCS = "git"
style = "pep440"
versionfile_source = "src/med_diagnostics/_version.py"
versionfile_build = "med_diagnostics/_version.py"
tag_prefix = "v"
parentdir_prefix = "med_diagnostics-"
8 changes: 8 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env python
from setuptools import setup
import versioneer

setup(
version=versioneer.get_version(),
cmdclass=versioneer.get_cmdclass(),
)
4 changes: 3 additions & 1 deletion src/med_diagnostics/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
from . import data, diagnostics, ui, session
from . import data, diagnostics, ui, session
from . import _version
__version__ = _version.get_versions()['version']
Loading