diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index def820f..9ea2562 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -1,8 +1,13 @@ - ---- name: Release -on: [push] +on: + pull_request: + push: + branches: + - main + release: + types: + - published jobs: release: @@ -18,11 +23,23 @@ jobs: - uses: actions/setup-python@v5 - name: Install dependencies run: | - python -m pip install -U pip wheel setuptools setuptools-scm twine - # python -m pip install -U pip wheel "setuptools<66.0.0" setuptools-scm twine + python -m pip install -U build check-manifest pip pytest setuptools setuptools-scm twine - name: Build distributions - run: python setup.py sdist bdist_wheel + run: python -m build --sdist --wheel . --outdir dist + + - name: CheckFiles + run: | + ls dist + check-manifest --verbose + + - name: Test wheels + run: | + cd dist + python -m twine check * + python -m pip install *.whl + cp --recursive ../tests . + python -m pytest -rxs tests - name: Publish to PyPI - if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags') + if: success() && github.event_name == 'release' uses: pypa/gh-action-pypi-publish@release/v1 diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index d7d6d29..70abc24 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -17,36 +17,33 @@ jobs: fail-fast: false matrix: os: ["macos-latest", "ubuntu-latest", "windows-latest"] - python-version: ["3.8", "3.9", "3.10"] + python-version: [ "3.9", "3.10" ,"3.11", "3.12", "3.13" ] + defaults: + run: + shell: bash -l {0} + steps: - uses: actions/checkout@v4 - - name: Cache conda - uses: actions/cache@v4 - env: - # Increase this value to reset cache if ci/environment.yml has not changed - CACHE_NUMBER: 0 - with: - path: ~/conda_pkgs_dir - key: ${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-${{ hashFiles('ci/environment-py${{ matrix.python-version }}.yml') }} - - uses: conda-incubator/setup-miniconda@v3 + + - name: Setup Micromamba ${{ matrix.python-version }} + uses: mamba-org/setup-micromamba@v1 with: - # mamba-version: "*" # activate this to build with mamba. - python-version: ${{ matrix.python-version }} - miniforge-variant: Mambaforge - channels: conda-forge, defaults # These need to be specified to use mamba - channel-priority: true - environment-file: ci/environment-py${{ matrix.python-version }}.yml + environment-name: TEST + init-shell: bash + create-args: >- + python=${{ matrix.python-version }} pip + --file requirements.txt + pytest codecov pytest-cov + --channel conda-forge - activate-environment: test_env_cmocean - use-only-tar-bz2: true # IMPORTANT: This needs to be set for caching to work properly! - name: Set up conda environment - shell: bash -l {0} run: | python -m pip install -e . --no-deps --force-reinstall + - name: Run Tests - shell: bash -l {0} run: | - pytest --cov=./ --cov-report=xml + pytest -rxs --cov=./ --cov-report=xml + - name: Upload code coverage to Codecov uses: codecov/codecov-action@v4 with: diff --git a/.gitignore b/.gitignore index 6cee59b..9b735f0 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +cmocean/_version.py cmocean/rgb/drafts/ dist *.pyc diff --git a/MANIFEST.in b/MANIFEST.in index 4fabd54..415288f 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -2,3 +2,8 @@ include README.md include *.txt recursive-include cmocean *.txt recursive-include cmocean *.py + +recursive-exclude cmocean/rgb *.jscm +prune docs +prune figures +exclude cmocean/_version.py diff --git a/ci/environment-py3.10.yml b/ci/environment-py3.10.yml deleted file mode 100644 index 3c9e6ab..0000000 --- a/ci/environment-py3.10.yml +++ /dev/null @@ -1,14 +0,0 @@ -name: test_env_cmocean -channels: - - conda-forge -dependencies: - - python=3.10 - ############## These will have to be adjusted to your specific project - - matplotlib-base - - numpy - ############## - - pytest - - pip: - - codecov - - pytest-cov - - coverage[toml] diff --git a/ci/environment-py3.8.yml b/ci/environment-py3.8.yml deleted file mode 100644 index 431995c..0000000 --- a/ci/environment-py3.8.yml +++ /dev/null @@ -1,14 +0,0 @@ -name: test_env_cmocean -channels: - - conda-forge -dependencies: - - python=3.8 - ############## These will have to be adjusted to your specific project - - matplotlib-base - - numpy - ############## - - pytest - - pip: - - codecov - - pytest-cov - - coverage[toml] diff --git a/ci/environment-py3.9.yml b/ci/environment-py3.9.yml deleted file mode 100644 index b2f681d..0000000 --- a/ci/environment-py3.9.yml +++ /dev/null @@ -1,14 +0,0 @@ -name: test_env_cmocean -channels: - - conda-forge -dependencies: - - python=3.9 - ############## These will have to be adjusted to your specific project - - matplotlib-base - - numpy - ############## - - pytest - - pip: - - codecov - - pytest-cov - - coverage[toml] diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..570011e --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,60 @@ +[build-system] +build-backend = "setuptools.build_meta" +requires = [ + "setuptools>=42", + "setuptools_scm", +] + +[project] +name = "cmocean" +description = "Colormaps for Oceanography" +readme = "README.md" +license = {file = "LICENSE.txt"} +maintainers = [ + {name = "Kristen Thyng", email = "kthyng@gmail.com"}, +] +requires-python = ">=3.8" +classifiers = [ + "Programming Language :: Python :: 3 :: Only", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", +] +dynamic = [ + "dependencies", + "version", +] +[project.optional-dependencies] +tests = [ + "pytest", +] +plots = [ + "colorspacious", + "viscm", +] + +[project.urls] +documentation = "https://matplotlib.org/cmocean/" +homepage = "https://github.com/matplotlib/cmocean" +repository = "https://github.com/matplotlib/cmocean" + +[tool.setuptools] +packages = ["cmocean"] +include-package-data = true + +[tool.setuptools.dynamic] +dependencies = {file = ["requirements.txt"]} + +[tool.setuptools_scm] +write_to = "cmocean/_version.py" +write_to_template = "__version__ = '{version}'" +tag_regex = "^(?Pv)?(?P[^\\+]+)(?P.*)?$" + +[tool.pytest.ini_options] +filterwarnings = [ + "error:::cmocean.*", + "ignore::UserWarning", + "ignore::RuntimeWarning", +] diff --git a/requirements.txt b/requirements.txt index db5d81e..80565db 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1,3 @@ matplotlib numpy +packaging diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index 498ec14..0000000 --- a/setup.cfg +++ /dev/null @@ -1,2 +0,0 @@ -[metadata] -license_file = LICENSE.txt diff --git a/setup.py b/setup.py deleted file mode 100644 index 95d68bc..0000000 --- a/setup.py +++ /dev/null @@ -1,52 +0,0 @@ -#!/usr/bin/env python - -""" -setup.py for cmocean - -""" -import sys -from setuptools import setup # to support "develop" mode -from setuptools.command.test import test as TestCommand - -class PyTest(TestCommand): - def finalize_options(self): - TestCommand.finalize_options(self) - self.verbose = True - - def run_tests(self): - import pytest - errno = pytest.main(self.test_args) - sys.exit(errno) - -extras_require={ - 'plots': ["colorspacious", "viscm"], -} -# # in case I add more later -# extras_require['complete'] = sorted(set(sum(extras_require.values(), []))) - -setup( - name = "cmocean", - version = "v4.0.3", - author = "Kristen Thyng", - author_email = "kthyng@gmail.com", - url = 'https://github.com/matplotlib/cmocean', - # download_url = 'https://github.com/matplotlib/cmocean/tarball/2.0', - description = ("Colormaps for Oceanography"), - long_description=open('README.md').read(), - long_description_content_type='text/markdown', - classifiers=[ - "Development Status :: 3 - Alpha", - ], - package_data={ - 'cmocean': ['rgb/*.txt', 'rgb/inverted/*.txt'], - }, - packages = ["cmocean"], - ext_package='cmocean', - scripts = [], - keywords = ['colormaps', 'oceanography', 'plotting', 'visualization'], - setup_requires=['setuptools'], - install_requires=['matplotlib', 'numpy', 'packaging'], - tests_require=['pytest'], - python_requires=">=3.8", - extras_require=extras_require - )