Skip to content

Commit

Permalink
Use pyproject.toml and src root dir (#14)
Browse files Browse the repository at this point in the history
* Use pyproject.toml and src root dir
  • Loading branch information
sandorkertesz authored May 8, 2024
1 parent 48eb21e commit f753676
Show file tree
Hide file tree
Showing 39 changed files with 62 additions and 174 deletions.
11 changes: 11 additions & 0 deletions .github/workflows/cd-pypi.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name: cd

on:
push:
tags:
- '**'

jobs:
pypi:
uses: ecmwf-actions/reusable-workflows/.github/workflows/cd-pypi.yml@v2
secrets: inherit
129 changes: 1 addition & 128 deletions .github/workflows/legacy-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,62 +36,7 @@ jobs:
python-version: 3.x
- uses: pre-commit/[email protected]

unit-tests:
name: unit-tests (3.10)
if: ${{ !github.event.pull_request.head.repo.fork && github.event.action != 'labeled' || github.event.label.name == 'approved-for-ci' }}
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.sha || github.ref }}
- name: Install Conda environment with Micromamba
uses: mamba-org/provision-with-micromamba@v14
with:
environment-file: tests/environment-unit-tests.yml
environment-name: DEVELOP
channels: conda-forge
cache-env: true
extra-specs: |
python=3.10
- name: Install package
run: |
python -m pip install --no-deps -e .
- name: Run tests
run: |
make unit-tests
type-check:
needs: [unit-tests]
if: ${{ !github.event.pull_request.head.repo.fork && github.event.action != 'labeled' || github.event.label.name == 'approved-for-ci' }}
runs-on: ubuntu-latest
defaults:
run:
shell: bash -l {0}

steps:
- uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.sha || github.ref }}
- name: Install Conda environment with Micromamba
uses: mamba-org/provision-with-micromamba@v12
with:
environment-file: environment.yml
environment-name: DEVELOP
channels: conda-forge
cache-env: true
cache-env-key: ubuntu-latest-3.10
extra-specs: |
python=3.10
- name: Install package
run: |
python -m pip install --no-deps -e .
- name: Run code quality checks
run: |
echo type-check not used
documentation:
needs: [unit-tests]
if: ${{ !github.event.pull_request.head.repo.fork && github.event.action != 'labeled' || github.event.label.name == 'approved-for-ci' }}
runs-on: ubuntu-latest
defaults:
Expand All @@ -105,7 +50,7 @@ jobs:
- name: Install Conda environment with Micromamba
uses: mamba-org/provision-with-micromamba@v12
with:
environment-file: environment.yml
environment-file: tests/environment-unit-tests.yml
environment-name: DEVELOP
channels: conda-forge
cache-env: true
Expand All @@ -118,75 +63,3 @@ jobs:
- name: Build documentation
run: |
make docs-build
integration-tests:
needs: [unit-tests]
if: ${{ !github.event.pull_request.head.repo.fork && github.event.action != 'labeled' || github.event.label.name == 'approved-for-ci' }}
runs-on: ubuntu-latest
defaults:
run:
shell: bash -l {0}

strategy:
matrix:
include:
- python-version: "3.10"
# extra: -minver # This will need to be uncommented and environment-minver.yml updated if we want to publish on conda

steps:
- uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.sha || github.ref }}
- name: Install Conda environment with Micromamba
uses: mamba-org/provision-with-micromamba@v12
with:
environment-file: tests/environment-unit-tests${{ matrix.extra }}.yml
environment-name: DEVELOP${{ matrix.extra }}
channels: conda-forge
cache-env: true
cache-env-key: ubuntu-latest-${{ matrix.python-version }}${{ matrix.extra }}.
extra-specs: |
python=${{matrix.python-version }}
- name: Install package
run: |
python -m pip install --no-deps -e .
- name: Run tests
run: |
make unit-tests
distribution:
needs: [integration-tests, type-check, documentation]
if: ${{ !github.event.pull_request.head.repo.fork && github.event.action != 'labeled' || github.event.label.name == 'approved-for-ci' }}
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.sha || github.ref }}
- name: Build distributions
run: |
$CONDA/bin/python -m pip install build
$CONDA/bin/python -m build
- name: Publish a Python distribution to PyPI
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}

notify:
if: always() && ${{ !github.event.pull_request.head.repo.fork && github.event.action != 'labeled' || github.event.label.name == 'approved-for-ci' }}
needs:
- pre-commit
- unit-tests
- type-check
- documentation
- integration-tests
- distribution
runs-on: ubuntu-latest
steps:
- name: Trigger Teams notification
uses: ecmwf-actions/notify-teams@v1
with:
incoming_webhook: ${{ secrets.MS_TEAMS_INCOMING_WEBHOOK }}
needs_context: ${{ toJSON(needs) }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# setuptools-scm
version.py
_version.py

# Sphinx automatic generation of API
docs/_api/
Expand Down
4 changes: 2 additions & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@
autodoc_typehints = "none"

# autoapi configuration
autoapi_dirs = ["../earthkit/meteo"]
autoapi_ignore = ["*/version.py", "sphinxext/*"]
autoapi_dirs = ["../src/earthkit/meteo"]
autoapi_ignore = ["*/_version.py", "sphinxext/*"]
autoapi_options = [
"members",
"undoc-members",
Expand Down
53 changes: 46 additions & 7 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,47 @@
[build-system]
requires = ["setuptools>=45", "setuptools_scm[toml]>=6.2"]
requires = ["setuptools>=61", "setuptools-scm>=8.0"]

[project]
authors = [
{name = "European Centre for Medium-Range Weather Forecasts (ECMWF)", email = "[email protected]"}
]
classifiers = [
"Development Status :: 2 - Pre-Alpha",
"Intended Audience :: Developers",
"License :: OSI Approved :: Apache Software License",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy",
"Operating System :: OS Independent"
]
dependencies = [
"numpy"
]
description = "Meteorological computations"
dynamic = ["version"]
license = {text = "Apache License Version 2.0"}
name = "earthkit-meteo"
readme = "README.md"
requires-python = ">= 3.8"

[project.optional-dependencies]
test = [
"pytest",
"pytest-cov"
]

[project.urls]
Documentation = "https://earthkit-meteo.readthedocs.io/"
Homepage = "https://github.com/ecmwf/earthkit-meteo/"
Issues = "https://github.com/ecmwf/earthkit-meteo.issues"
Repository = "https://github.com/ecmwf/earthkit-meteo/"

[tool.coverage.run]
branch = true
branch = "true"

[tool.isort]
profile = "black"
Expand All @@ -11,9 +50,9 @@ profile = "black"
add_ignore = ["D1", "D200", "D205", "D400", "D401"]
convention = "numpy"

[tool.setuptools.packages.find]
include = ["earthkit.meteo"]
where = ["src/"]

[tool.setuptools_scm]
write_to = "earthkit/meteo/version.py"
write_to_template = '''
# Do not change! Do not track in version control!
__version__ = "{version}"
'''
version_file = "src/earthkit/meteo/_version.py"
36 changes: 0 additions & 36 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,39 +1,3 @@
[metadata]
name = earthkit-meteo
license = Apache License 2.0
description = Meteorological computations
Development Status :: 2 - Pre-Alpha
Intended Audience :: Science/Research
License :: OSI Approved :: Apache Software License
Operating System :: OS Independent
Programming Language :: Python
Programming Language :: Python :: 3
Programming Language :: Python :: 3.8
Programming Language :: Python :: 3.9
Programming Language :: Python :: 3.10
Programming Language :: Python :: 3.11
Topic :: Scientific/Engineering
long_description_content_type=text/markdown
long_description = file: README.md
test_suite = tests

[options]
packages = find_namespace:
install_requires =
numpy

[options.packages.find]
include = earthkit.*

[options.extras_require]
test =
pytest
pytest-cov

[flake8]
max-line-length = 110
extend-ignore = E203, W503

[mypy]
strict = False
ignore_missing_imports = True
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
try:
# NOTE: the `version.py` file must not be present in the git repository
# as it is generated by setuptools at install time
from .version import __version__
from ._version import __version__
except ImportError: # pragma: no cover
# Local copy or not installed with setuptools
__version__ = "999"
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit f753676

Please sign in to comment.