CORDEX-be2 / ValEnsPy

A Python package to Validate Ensembles of gridded model data
GNU General Public License v3.0
0 stars 0 forks source link

PyPi package #177

Open kobebryant432 opened 3 hours ago

kobebryant432 commented 3 hours ago

Creation of our first publication of the package to PyPi.

@vergauwenthomas I could use some help with this.

Should we make a complete new workflow? I have already created a (personal) PyPi account - should we also have an organizational account?

vergauwenthomas commented 2 hours ago

Your personal PyPi account is sufficient, you can always add more maintainers and change owner.

If you want full control of deployment (indepenant of the repo) you can use poetry to deploy to PyPi, else you can setup a github workflow that does the trick.

Either way, you must be careful not to track your deploy password in this repo. So if you use poetry to deploy, save your password and add it to the .gitignore. I you plan to use workflows, you can save the deploy password as a secret in github (see github secrets).

Here is the workflow i uses for the metobs_toolkit:

name: Upload Python Package to PyPI

on:
  release:
    types: [created]

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - name: Build and publish to pypi
        uses: JRubics/poetry-publish@v2.0
        with:
          pypi_token: ${{ secrets.PYPI_TOKEN }}
          poetry_install_options: "--without titan"
          allow_poetry_pre_release: "yes"
          package_directory: "metobs_toolkit"

This triggers when a new release tag is created.

Before releasing, make sure that the package version in pyproject and __init__ file are the same! Because once you publish to PyPi, you cannot revert /delete versions (you can yank them if you like).

vergauwenthomas commented 2 hours ago

Also add classifiers too the pyproject before publishing:

classifiers = [
  "Development Status :: 4 - Beta",
  "Intended Audience :: Science/Research",
  "License :: OSI Approved :: MIT License",
  "Natural Language :: English",
  "Operating System :: OS Independent",
  "Programming Language :: Python :: 3",
  "Programming Language :: Python :: 3.9",
  "Programming Language :: Python :: 3.10",
  "Programming Language :: Python :: 3.11",
  "Programming Language :: Python :: 3.12",
  "Topic :: Scientific/Engineering :: Atmospheric Science"
]

(update accordingly)

vergauwenthomas commented 2 hours ago

let me know if you need more help!