diff --git a/.flake8 b/.flake8 new file mode 100644 index 0000000..5aaf5ef --- /dev/null +++ b/.flake8 @@ -0,0 +1,5 @@ +[flake8] +include = *.py +exclude = .git,__pycache__,.tox,.eggs,*.egg,doc,dist,build,_build,.ipynb_checkpoints,run_test.py +ignore = E, + W diff --git a/.git_archival.txt b/.git_archival.txt new file mode 100644 index 0000000..8fb235d --- /dev/null +++ b/.git_archival.txt @@ -0,0 +1,4 @@ +node: $Format:%H$ +node-date: $Format:%cI$ +describe-name: $Format:%(describe:tags=true,match=*[0-9]*)$ +ref-names: $Format:%D$ diff --git a/.gitattributes b/.gitattributes index 7245958..4f9ccb6 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,2 +1,5 @@ -colorcet/__init__.py export-subst -setup.cfg export-subst +# For setuptools_scm with .git_archival.txt +.git_archival.txt export-subst +# Line Endings configuration file for Git +# Set the default behavior, in case people don't have or can't have core.autocrlf set. +* text=auto diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index ddf2583..f47fb6b 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -19,92 +19,57 @@ jobs: defaults: run: shell: bash -l {0} - env: - CHANS: "-c pyviz -c bokeh" - PKG_TEST_PYTHON: "--test-python=py37" - PYTHON_VERSION: "3.7" - MPLBACKEND: "Agg" - CONDA_UPLOAD_TOKEN: ${{ secrets.CONDA_UPLOAD_TOKEN }} steps: - - uses: actions/checkout@v3 - with: - fetch-depth: "100" - - uses: actions/setup-python@v4 - with: - python-version: ${{ matrix.python-version }} + - uses: actions/checkout@v4 + - name: Fetch unshallow + run: git fetch --prune --tags --unshallow -f - uses: conda-incubator/setup-miniconda@v2 with: miniconda-version: "latest" - python-version: ${{ env.PYTHON_VERSION }} - - name: Fetch - run: git fetch --prune --tags -f + python-version: "3.11" + auto-update-conda: true - name: Set output id: vars run: echo "tag=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT - name: conda setup run: | - conda config --set always_yes True - conda install -c pyviz "pyctdev>=0.5" - doit ecosystem_setup + conda install anaconda-client conda-build setuptools_scm - name: conda build - run: doit package_build $CHANS $PKG_TEST_PYTHON --test-group=unit + run: | + VERSION=`python -m setuptools_scm` conda build conda.recipe/ - name: conda dev upload if: (github.event_name == 'push' && (contains(steps.vars.outputs.tag, 'a') || contains(steps.vars.outputs.tag, 'b') || contains(steps.vars.outputs.tag, 'rc'))) - run: doit package_upload --token=$CONDA_UPLOAD_TOKEN --label=dev + run: | + anaconda --token ${{ secrets.CONDA_UPLOAD_TOKEN }} upload --user pyviz --label=dev $(VERSION=`python -m setuptools_scm` conda build --output conda.recipe) - name: conda main upload if: (github.event_name == 'push' && !(contains(steps.vars.outputs.tag, 'a') || contains(steps.vars.outputs.tag, 'b') || contains(steps.vars.outputs.tag, 'rc'))) - run: doit package_upload --token=$CONDA_UPLOAD_TOKEN --label=dev --label=main + run: | + anaconda --token ${{ secrets.CONDA_UPLOAD_TOKEN }} upload --user pyviz --label=dev --label=main $(VERSION=`python -m setuptools_scm` conda build --output conda.recipe) pip_build: name: Build PyPI Packages runs-on: 'ubuntu-latest' defaults: run: shell: bash -l {0} - env: - CHANS: "-c pyviz -c bokeh" - PKG_TEST_PYTHON: "--test-python=py37" - PYTHON_VERSION: "3.7" - MPLBACKEND: "Agg" - PPU: ${{ secrets.PPU }} - PPP: ${{ secrets.PPP }} - PYPI: "https://upload.pypi.org/legacy/" steps: - - uses: actions/checkout@v3 - with: - fetch-depth: "100" - - uses: actions/setup-python@v4 - with: - python-version: ${{ matrix.python-version }} - - uses: conda-incubator/setup-miniconda@v2 + - uses: actions/checkout@v4 + - name: Fetch unshallow + run: git fetch --prune --tags --unshallow -f + - name: Set up Python + uses: actions/setup-python@v5 with: - miniconda-version: "latest" - python-version: ${{ env.PYTHON_VERSION }} - - name: Fetch - run: git fetch --prune --tags -f - - name: conda setup - run: | - conda config --set always_yes True - conda install -c pyviz "pyctdev>=0.5" - doit ecosystem_setup - doit env_create $CHANS --python=$PYTHON_VERSION + python-version: "3.11" - name: env setup run: | - eval "$(conda shell.bash hook)" - conda activate test-environment - doit develop_install $CHANS_DEV -o unit_tests - doit pip_on_conda - - name: doit env_capture - run: | - conda activate test-environment - doit env_capture + python -m pip install --upgrade pip + python -m pip install build - name: pip build run: | - eval "$(conda shell.bash hook)" - conda activate test-environment - doit ecosystem=pip package_build - - name: pip upload + python -m build + - name: Publish package to PyPI if: github.event_name == 'push' - run: | - eval "$(conda shell.bash hook)" - conda activate test-environment - doit ecosystem=pip package_upload -u $PPU -p $PPP -r $PYPI + uses: pypa/gh-action-pypi-publish@release/v1 + with: + user: ${{ secrets.PPU }} + password: ${{ secrets.PPP }} + packages-dir: dist/ diff --git a/.github/workflows/docs.yaml b/.github/workflows/docs.yaml index aa00148..77d5ec8 100644 --- a/.github/workflows/docs.yaml +++ b/.github/workflows/docs.yaml @@ -31,42 +31,25 @@ jobs: run: shell: bash -l {0} env: - DESC: "Documentation build" MPLBACKEND: "Agg" DISPLAY: ":99.0" - PYTHON_DOCS_VERSION: "3.9" steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: fetch-depth: "100" - - uses: conda-incubator/setup-miniconda@v2 - with: - miniconda-version: "latest" - name: Fetch run: git fetch --prune --tags -f - name: Set output id: vars run: echo "tag=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT - - name: conda setup - # conda-forge is required to install pydata-sphinx-theme and sphinx-copybutton. - run: | - conda create -n test-environment - conda activate test-environment - conda config --env --append channels pyviz/label/dev --append channels conda-forge - conda config --env --remove channels defaults - conda install python=${{ env.PYTHON_DOCS_VERSION}} pyctdev - - name: doit develop_install - run: | - conda activate test-environment - doit develop_install -o doc -o examples - - name: doit env_capture - run: | - conda activate test-environment - doit env_capture + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: '3.11' + - name: install + run: pip install ."[doc, examples]" - name: build docs - run: | - conda activate test-environment - doit build_website + run: sphinx-build -b html doc builtdocs - name: git status run: | git status diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 1b42636..cacdfa3 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -16,71 +16,51 @@ concurrency: cancel-in-progress: true jobs: + pre_commit: + name: Run pre-commit + runs-on: 'ubuntu-latest' + steps: + - uses: holoviz-dev/holoviz_tasks/pre-commit@v0.1a19 test_suite: name: Pytest on ${{ matrix.python-version }}, ${{ matrix.os }} + needs: [pre_commit] runs-on: ${{ matrix.os }} strategy: fail-fast: false matrix: os: ['ubuntu-latest', 'macos-latest', 'windows-latest'] # Run on the full set on schedule, workflow_dispatch and push&tags events, otherwise on a subset. - python-version: ${{ ( github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' || ( github.event_name == 'push' && github.ref_type == 'tag' ) ) && fromJSON('["3.7", "3.8", "3.9", "3.10", "3.11"]') || fromJSON('["3.7", "3.11"]') }} + # python-version: ${{ ( github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' || ( github.event_name == 'push' && github.ref_type == 'tag' ) ) && fromJSON('["3.7", "3.8", "3.9", "3.10", "3.11", "3.12"]') || fromJSON('["3.7", "3.12"]') }} + python-version: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12"] timeout-minutes: 60 defaults: run: - shell: bash -l {0} + shell: bash -l {0} env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - ENV_NAME: "colorcet" MPLBACKEND: "Agg" DISPLAY: ":99.0" steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: fetch-depth: "100" - - uses: conda-incubator/setup-miniconda@v2 - with: - miniconda-version: "latest" - name: Fetch run: git fetch --prune --tags -f - - name: conda setup - run: | - conda update -n base conda - conda create -n ${{ env.ENV_NAME }} - conda activate ${{ env.ENV_NAME }} - conda config --env --prepend channels pyviz/label/dev - conda config --env --show-sources - conda install python=${{ matrix.python-version }} pyctdev - - name: doit develop_install - run: | - conda activate ${{ env.ENV_NAME }} - doit develop_install -o tests -o examples - - name: pin bokeh on Python 3.8 - if: matrix.python-version == '3.8' - # Pin to avoid pulling an old version of Bokeh and Panel. - run: | - conda activate ${{ env.ENV_NAME }} - conda install "bokeh >=3" - - name: doit env_capture - run: | - conda activate ${{ env.ENV_NAME }} - doit env_capture - - name: doit test_lint - run: | - conda activate ${{ env.ENV_NAME }} - doit test_lint - - name: doit test_unit - run: | - conda activate ${{ env.ENV_NAME }} - doit test_unit - - name: doit test_examples - run: | - conda activate ${{ env.ENV_NAME }} - doit test_examples + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + allow-prereleases: true + - name: pip update + run: pip install --upgrade pip + - name: install + run: pip install -e ."[tests,tests_examples,tests_extra]" + - name: pip list + run: pip list + - name: unit tests + run: pytest colorcet --cov=colorcet --cov-append --cov-report xml + - name: examples tests + run: pytest doc --nbval-lax -p no:python - name: doit test_unit_extra - run: | - conda activate ${{ env.ENV_NAME }} - pip install pytest-mpl - doit test_unit_extra - - uses: codecov/codecov-action@v3 + run: pytest colorcet --mpl + - uses: codecov/codecov-action@v4 if: github.event_name == 'push' diff --git a/.gitignore b/.gitignore index 303ec0a..17b386f 100644 --- a/.gitignore +++ b/.gitignore @@ -18,17 +18,16 @@ coverage.xml __pycache__ .doit* *.egg-info -*/.version pip-wheel-metadata **.ipynb_checkpoints /build +dist/ +.venv/ +venv/ # nbsite # these files normally shouldn't be checked in as they should be # dynamically built from notebooks -doc/**/*.rst -doc/**/*.ipynb -doc/**/*.json # this dir contains the whole website and should not be checked in on main builtdocs/ # myst-nb output dir @@ -36,3 +35,6 @@ jupyter_execute/ # CET_updates.py is an intermediate file and should not be versioned. assets/CET_updates.py + +# setuptools_scm +colorcet/_version.py diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..633b8d3 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,35 @@ +# This is the configuration for pre-commit, a local framework for managing pre-commit hooks +# Check out the docs at: https://pre-commit.com/ + +default_stages: [commit] + +# Exclude Matlab files +exclude: '.+\.m$' + +repos: +- repo: https://github.com/nbQA-dev/nbQA + rev: 1.7.1 + hooks: + - id: nbqa-flake8 +- repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.5.0 + hooks: + - id: check-builtin-literals + - id: check-case-conflict + - id: check-docstring-first + - id: check-executables-have-shebangs + - id: check-toml + - id: detect-private-key + - id: end-of-file-fixer + exclude: (\.min\.js$|\.svg$) + - id: trailing-whitespace +- repo: https://github.com/PyCQA/flake8 + rev: 7.0.0 + hooks: + - id: flake8 # See 'setup.cfg' for args + args: [colorcet] + files: colorcet/ +- repo: https://github.com/hoxbro/clean_notebook + rev: v0.1.15a2 + hooks: + - id: clean-notebook diff --git a/MANIFEST.in b/MANIFEST.in deleted file mode 100644 index 03c6c31..0000000 --- a/MANIFEST.in +++ /dev/null @@ -1,8 +0,0 @@ -include LICENSE.txt -include README.md -include colorcet/.version -graft examples -graft colorcet/examples -global-exclude *.py[co] -global-exclude *~ -global-exclude *.ipynb_checkpoints/* diff --git a/README.md b/README.md index 52d460b..9e1b8be 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,7 @@ by Peter Kovesi at the Center for Exploration Targeting. ## Installation -Colorcet supports Python 3.7, 3.8, 3.9, 3.10 and 3.11 on Linux, Windows, or Mac +Colorcet supports Python 3.7 and greater on Linux, Windows, or Mac and can be installed with conda: ```sh @@ -41,16 +41,6 @@ or with pip: python -m pip install colorcet ``` -Once installed you can copy the examples into the current directory using the colorcet command and run them using the Jupyter notebook: - -```sh -colorcet examples -cd colorcet-examples -jupyter notebook -``` - -(Here colorcet examples is a shorthand for colorcet copy-examples --path colorcet-examples && colorcet fetch-data --path colorcet-examples.) - To work with JupyterLab you will also need the PyViz JupyterLab extension: ```sh diff --git a/assets/CET_to_py.py b/assets/CET_to_py.py index 867c09b..56a4504 100644 --- a/assets/CET_to_py.py +++ b/assets/CET_to_py.py @@ -55,12 +55,15 @@ Some of the Glasbey sets are aliased to short names as explained in the User Guide. """ -from colorcet.version import Version -__version__ = str(Version(fpath=__file__, archive_commit="$Format:%h$",reponame="datashader")) +import os from collections import OrderedDict from itertools import chain +# Define '__version__' +from importlib.metadata import version +__version__ = version('colorcet') + class AttrODict(OrderedDict): """Ordered dictionary with attribute access (e.g. for tab completion)""" @@ -150,7 +153,7 @@ def all_original_names(group=None, not_group=None, only_aliased=False, only_CET= Returns a list (optionally filtered) of the names of the available colormaps Filters available: - group: only include maps whose name include the given string(s) - (e.g. "'linear'" or "['linear','diverging']"). + (e.g. "'linear'" or "['linear','diverging']"). - not_group: filter out any maps whose names include the given string(s) - only_aliased: only include maps with shorter/simpler aliases - only_CET: only include maps from CET diff --git a/assets/rename_CET_maps.py b/assets/rename_CET_maps.py index c71738c..634ae3c 100644 --- a/assets/rename_CET_maps.py +++ b/assets/rename_CET_maps.py @@ -31,4 +31,3 @@ subprocess.run(f'git mv -vk "{path}" "{new_path}"', shell=True) subprocess.run("git rm -rf CETperceptual_csv_0_1_v2", shell=True) - diff --git a/colorcet/__init__.py b/colorcet/__init__.py index fc808a0..1d03e44 100644 --- a/colorcet/__init__.py +++ b/colorcet/__init__.py @@ -40,12 +40,29 @@ Some of the Glasbey sets are aliased to short names as explained in the User Guide. """ -from .version import Version -__version__ = str(Version(fpath=__file__, archive_commit="$Format:%h$", reponame="colorcet")) - from collections import OrderedDict from itertools import chain +# Define '__version__' +try: + # __version__ was added in _version in setuptools-scm 7.0.0, we rely on + # the hopefully stable version variable. + from ._version import version as __version__ +except (ModuleNotFoundError, ImportError): + # Either _version doesn't exist (ModuleNotFoundError) or version isn't + # in _version (ImportError). ModuleNotFoundError is a subclass of + # ImportError, let's be explicit anyway. + + # Try something else: + from importlib.metadata import version as mversion, PackageNotFoundError + + try: + __version__ = mversion("colorcet") + except PackageNotFoundError: + # The user is probably trying to run this without having installed + # the package. + __version__ = "0.0.0+unknown" + class AttrODict(OrderedDict): """Ordered dictionary with attribute access (e.g. for tab completion)""" @@ -143,7 +160,7 @@ def all_original_names(group=None, not_group=None, only_aliased=False, only_CET= Returns a list (optionally filtered) of the names of the available colormaps Filters available: - group: only include maps whose name include the given string(s) - (e.g. "'linear'" or "['linear','diverging']"). + (e.g. "'linear'" or "['linear','diverging']"). - not_group: filter out any maps whose names include the given string(s) - only_aliased: only include maps with shorter/simpler aliases - only_CET: only include maps from CET diff --git a/colorcet/__main__.py b/colorcet/__main__.py deleted file mode 100644 index 15abc56..0000000 --- a/colorcet/__main__.py +++ /dev/null @@ -1,12 +0,0 @@ -def main(args=None): - try: - import pyct.cmd - except ImportError: - import sys - from . import _missing_cmd - print(_missing_cmd()) - sys.exit(1) - return pyct.cmd.substitute_main('colorcet',args=args) - -if __name__ == "__main__": - main() \ No newline at end of file diff --git a/colorcet/tests/baseline/test_matplotlib.png b/colorcet/tests/baseline/test_matplotlib.png index c478118..42fe921 100644 Binary files a/colorcet/tests/baseline/test_matplotlib.png and b/colorcet/tests/baseline/test_matplotlib.png differ diff --git a/colorcet/tests/baseline/test_matplotlib_glasbey.png b/colorcet/tests/baseline/test_matplotlib_glasbey.png index 284b597..478e0be 100644 Binary files a/colorcet/tests/baseline/test_matplotlib_glasbey.png and b/colorcet/tests/baseline/test_matplotlib_glasbey.png differ diff --git a/colorcet/tests/test_bokeh.py b/colorcet/tests/test_bokeh.py index 7af2e4e..1342f39 100644 --- a/colorcet/tests/test_bokeh.py +++ b/colorcet/tests/test_bokeh.py @@ -16,4 +16,4 @@ def test_bokeh_palette_glasbey_do_not_start_with_bw(): cmap = cc.palette[name] assert isinstance(cmap, list) assert len(cmap) == 256 - assert {cmap[0], cmap[1]} != {'#00000', '#ffffff'} \ No newline at end of file + assert {cmap[0], cmap[1]} != {'#00000', '#ffffff'} diff --git a/colorcet/version.py b/colorcet/version.py deleted file mode 100644 index ae00fc4..0000000 --- a/colorcet/version.py +++ /dev/null @@ -1,771 +0,0 @@ -""" -Provide consistent and up-to-date ``__version__`` strings for -Python packages. - -See https://github.com/holoviz/autover for more information. -""" - -# The Version class is a copy of autover.version.Version v0.2.5, -# except as noted below. -# -# The current version of autover supports a workflow based on tagging -# a git repository, and reports PEP440 compliant version information. -# Previously, the workflow required editing of version numbers in -# source code, and the version was not necessarily PEP440 compliant. -# Version.__new__ is added here to provide the previous Version class -# (OldDeprecatedVersion) if Version is called in the old way. - - -__author__ = 'Jean-Luc Stevens' - -import os, subprocess, json - -def run_cmd(args, cwd=None): - proc = subprocess.Popen(args, stdout=subprocess.PIPE, - stderr=subprocess.PIPE, - cwd=cwd) - output, error = (str(s.decode()).strip() for s in proc.communicate()) - - # Detects errors as _either_ a non-zero return code _or_ messages - # printed to stderr, because the return code is erroneously fixed at - # zero in some cases (see https://github.com/holoviz/param/pull/389). - if proc.returncode != 0 or len(error) > 0: - raise Exception(proc.returncode, error) - return output - - - -class Version(object): - """ - A simple approach to Python package versioning that supports PyPI - releases and additional information when working with version - control. When obtaining a package from PyPI, the version returned - is a string-formatted rendering of the supplied release tuple. - For instance, release (1,0) tagged as ``v1.0`` in the version - control system will return ``1.0`` for ``str(__version__)``. Any - number of items can be supplied in the release tuple, with either - two or three numeric versioning levels typical. - - During development, a command like ``git describe`` will be used to - compute the number of commits since the last version tag, the short - commit hash, and whether the commit is dirty (has changes not yet - committed). Version tags must start with a lowercase 'v' and have a - period in them, e.g. v2.0, v0.9.8 or v0.1 and may include the PEP440 - prerelease identifiers of 'a' (alpha) 'b' (beta) or 'rc' (release - candidate) allowing tags such as v2.0.a3, v0.9.8.b3 or v0.1.rc5. - - Also note that when version control system (VCS) information is - used, the number of commits since the last version tag is - determined. This approach is often useful in practice to decide - which version is newer for a single developer, but will not - necessarily be reliable when comparing against a different fork or - branch in a distributed VCS. - - For git, if you want version control information available even in - an exported archive (e.g. a .zip file from GitHub), you can set - the following line in the .gitattributes file of your project:: - - __init__.py export-subst - - Note that to support pip installation directly from GitHub via git - archive, a .version file must be tracked by the repo to supply the - release number (otherwise only the short SHA is available). - - The PEP440 format returned is [N!]N(.N)*[{a|b|rc}N][.postN+SHA] - where everything before .postN is obtained from the tag, the N in - .postN is the number of commits since the last tag and the SHA is - obtained via git describe. This later portion is only shown if the - commit count since the last tag is non zero. Instead of '.post', an - alternate valid prefix such as '.rev', '_rev', '_r' or '.r' may be - supplied.""" - - def __new__(cls,**kw): - # If called in the old way, provide the previous class. Means - # PEP440/tag based workflow warning below will never appear. - if ('release' in kw and kw['release'] is not None) or \ - ('dev' in kw and kw['dev'] is not None) or \ - ('commit_count' in kw): - return OldDeprecatedVersion(**kw) - else: - return super(Version, cls).__new__(cls) - - - def __init__(self, release=None, fpath=None, commit=None, reponame=None, - commit_count_prefix='.post', archive_commit=None, **kwargs): - """ - :release: Release tuple (corresponding to the current VCS tag) - :commit Short SHA. Set to '$Format:%h$' for git archive support. - :fpath: Set to ``__file__`` to access version control information - :reponame: Used to verify VCS repository name. - """ - self.fpath = fpath - self._expected_commit = commit - - if release is not None or 'commit_count' in kwargs: - print('WARNING: param.Version now supports PEP440 and a new tag based workflow. See param/version.py for more details') - - self.expected_release = release - - self._commit = None if (commit is None or commit.startswith("$Format")) else commit - self._commit_count = None - self._release = None - self._dirty = False - self._prerelease = None - - self.archive_commit= archive_commit - - self.reponame = reponame - self.commit_count_prefix = commit_count_prefix - - @property - def prerelease(self): - """ - Either None or one of 'aN' (alpha), 'bN' (beta) or 'rcN' - (release candidate) where N is an integer. - """ - return self.fetch()._prerelease - - @property - def release(self): - "Return the release tuple" - return self.fetch()._release - - @property - def commit(self): - "A specification for this particular VCS version, e.g. a short git SHA" - return self.fetch()._commit - - @property - def commit_count(self): - "Return the number of commits since the last release" - return self.fetch()._commit_count - - @property - def dirty(self): - "True if there are uncommitted changes, False otherwise" - return self.fetch()._dirty - - - def fetch(self): - """ - Returns a tuple of the major version together with the - appropriate SHA and dirty bit (for development version only). - """ - if self._release is not None: - return self - - self._release = self.expected_release - if not self.fpath: - self._commit = self._expected_commit - return self - - # Only git right now but easily extended to SVN, Mercurial, etc. - for cmd in ['git', 'git.cmd', 'git.exe']: - try: - self.git_fetch(cmd) - break - except EnvironmentError: - pass - return self - - - def git_fetch(self, cmd='git', as_string=False): - commit_argument = self._commit - output = None - try: - if self.reponame is not None: - # Verify this is the correct repository (since fpath could - # be an unrelated git repository, and autover could just have - # been copied/installed into it). - remotes = run_cmd([cmd, 'remote', '-v'], - cwd=os.path.dirname(self.fpath)) - repo_matches = ['/' + self.reponame + '.git' , - # A remote 'server:reponame.git' can also be referred - # to (i.e. cloned) as `server:reponame`. - '/' + self.reponame + ' '] - if not any(m in remotes for m in repo_matches): - try: - output = self._output_from_file() - if output is not None: - self._update_from_vcs(output) - except: pass - if output is None: - # glob pattern (not regexp) matching vX.Y.Z* tags - output = run_cmd([cmd, 'describe', '--long', '--match', - "v[0-9]*.[0-9]*.[0-9]*", '--dirty'], - cwd=os.path.dirname(self.fpath)) - if as_string: return output - except Exception as e1: - try: - output = self._output_from_file() - if output is not None: - self._update_from_vcs(output) - if self._known_stale(): - self._commit_count = None - if as_string: return output - - # If an explicit commit was supplied (e.g from git - # archive), it should take precedence over the file. - if commit_argument: - self._commit = commit_argument - return - - except IOError: - if e1.args[1] == 'fatal: No names found, cannot describe anything.': - raise Exception("Cannot find any git version tags of format v*.*") - # If there is any other error, return (release value still useful) - return self - - self._update_from_vcs(output) - - - def _known_stale(self): - """ - The commit is known to be from a file (and therefore stale) if a - SHA is supplied by git archive and doesn't match the parsed commit. - """ - if self._output_from_file() is None: - commit = None - else: - commit = self.commit - - known_stale = (self.archive_commit is not None - and not self.archive_commit.startswith('$Format') - and self.archive_commit != commit) - if known_stale: self._commit_count = None - return known_stale - - def _output_from_file(self, entry='git_describe'): - """ - Read the version from a .version file that may exist alongside __init__.py. - - This file can be generated by piping the following output to file: - - git describe --long --match v*.* - """ - try: - vfile = os.path.join(os.path.dirname(self.fpath), '.version') - with open(vfile, 'r') as f: - return json.loads(f.read()).get(entry, None) - except: # File may be missing if using pip + git archive - return None - - - def _update_from_vcs(self, output): - "Update state based on the VCS state e.g the output of git describe" - split = output[1:].split('-') - dot_split = split[0].split('.') - for prefix in ['a','b','rc']: - if prefix in dot_split[-1]: - prefix_split = dot_split[-1].split(prefix) - self._prerelease = prefix + prefix_split[-1] - dot_split[-1] = prefix_split[0] - - - self._release = tuple(int(el) for el in dot_split) - self._commit_count = int(split[1]) - - self._commit = str(split[2][1:]) # Strip out 'g' prefix ('g'=>'git') - - self._dirty = (split[-1]=='dirty') - return self - - def __str__(self): - """ - Version in x.y.z string format. Does not include the "v" - prefix of the VCS version tags, for pip compatibility. - - If the commit count is non-zero or the repository is dirty, - the string representation is equivalent to the output of:: - - git describe --long --match v*.* --dirty - - (with "v" prefix removed). - """ - known_stale = self._known_stale() - if self.release is None and not known_stale: - extracted_directory_tag = self._output_from_file(entry='extracted_directory_tag') - return 'None' if extracted_directory_tag is None else extracted_directory_tag - elif self.release is None and known_stale: - extracted_directory_tag = self._output_from_file(entry='extracted_directory_tag') - if extracted_directory_tag is not None: - return extracted_directory_tag - return '0.0.0+g{SHA}-gitarchive'.format(SHA=self.archive_commit) - - release = '.'.join(str(el) for el in self.release) - prerelease = '' if self.prerelease is None else self.prerelease - - if self.commit_count == 0 and not self.dirty: - return release + prerelease - - commit = self.commit - dirty = '-dirty' if self.dirty else '' - archive_commit = '' - if known_stale: - archive_commit = '-gitarchive' - commit = self.archive_commit - - if archive_commit != '': - postcount = self.commit_count_prefix + '0' - elif self.commit_count not in [0, None]: - postcount = self.commit_count_prefix + str(self.commit_count) - else: - postcount = '' - - components = [release, prerelease, postcount, - '' if commit is None else '+g' + commit, dirty, - archive_commit] - return ''.join(components) - - def __repr__(self): - return str(self) - - def abbrev(self): - """ - Abbreviated string representation of just the release number. - """ - return '.'.join(str(el) for el in self.release) - - def verify(self, string_version=None): - """ - Check that the version information is consistent with the VCS - before doing a release. If supplied with a string version, - this is also checked against the current version. Should be - called from setup.py with the declared package version before - releasing to PyPI. - """ - if string_version and string_version != str(self): - raise Exception("Supplied string version does not match current version.") - - if self.dirty: - raise Exception("Current working directory is dirty.") - - if self.expected_release is not None and self.release != self.expected_release: - raise Exception("Declared release does not match current release tag.") - - if self.commit_count !=0: - raise Exception("Please update the VCS version tag before release.") - - if (self._expected_commit is not None - and not self._expected_commit.startswith( "$Format")): - raise Exception("Declared release does not match the VCS version tag") - - - - @classmethod - def get_setup_version(cls, setup_path, reponame, describe=False, - dirty='report', pkgname=None, archive_commit=None): - """ - Helper for use in setup.py to get the version from the .version file (if available) - or more up-to-date information from git describe (if available). - - Assumes the __init__.py will be found in the directory - {reponame}/__init__.py relative to setup.py unless pkgname is - explicitly specified in which case that name is used instead. - - If describe is True, the raw string obtained from git described is - returned which is useful for updating the .version file. - - The dirty policy can be one of 'report', 'strip', 'raise'. If it is - 'report' the version string may end in '-dirty' if the repository is - in a dirty state. If the policy is 'strip', the '-dirty' suffix - will be stripped out if present. If the policy is 'raise', an - exception is raised if the repository is in a dirty state. This can - be useful if you want to make sure packages are not built from a - dirty repository state. - """ - pkgname = reponame if pkgname is None else pkgname - policies = ['raise','report', 'strip'] - if dirty not in policies: - raise AssertionError("get_setup_version dirty policy must be in %r" % policies) - - fpath = os.path.join(setup_path, pkgname, "__init__.py") - version = Version(fpath=fpath, reponame=reponame, archive_commit=archive_commit) - if describe: - vstring = version.git_fetch(as_string=True) - else: - vstring = str(version) - - if version.dirty and dirty == 'raise': - raise AssertionError('Repository is in a dirty state.') - elif version.dirty and dirty=='strip': - return vstring.replace('-dirty', '') - else: - return vstring - - - @classmethod - def extract_directory_tag(cls, setup_path, reponame): - setup_dir = os.path.split(setup_path)[-1] # Directory containing setup.py - prefix = reponame + '-' # Prefix to match - if setup_dir.startswith(prefix): - tag = setup_dir[len(prefix):] - # Assuming the tag is a version if it isn't empty, 'master' and has a dot in it - if tag not in ['', 'master'] and ('.' in tag): - return tag - return None - - - @classmethod - def setup_version(cls, setup_path, reponame, archive_commit=None, - pkgname=None, dirty='report'): - info = {} - git_describe = None - pkgname = reponame if pkgname is None else pkgname - try: - # Will only work if in a git repo and git is available - git_describe = Version.get_setup_version(setup_path, - reponame, - describe=True, - dirty=dirty, - pkgname=pkgname, - archive_commit=archive_commit) - - if git_describe is not None: - info['git_describe'] = git_describe - except: pass - - if git_describe is None: - extracted_directory_tag = Version.extract_directory_tag(setup_path, reponame) - if extracted_directory_tag is not None: - info['extracted_directory_tag'] = extracted_directory_tag - try: - with open(os.path.join(setup_path, pkgname, '.version'), 'w') as f: - f.write(json.dumps({'extracted_directory_tag':extracted_directory_tag})) - except: - print('Error in setup_version: could not write .version file.') - - - info['version_string'] = Version.get_setup_version(setup_path, - reponame, - describe=False, - dirty=dirty, - pkgname=pkgname, - archive_commit=archive_commit) - try: - with open(os.path.join(setup_path, pkgname, '.version'), 'w') as f: - f.write(json.dumps(info)) - except: - print('Error in setup_version: could not write .version file.') - - return info['version_string'] - - - -def get_setup_version(location, reponame, pkgname=None, archive_commit=None): - """Helper for use in setup.py to get the current version from either - git describe or the .version file (if available). - - Set pkgname to the package name if it is different from the - repository name. - - To ensure git information is included in a git archive, add - setup.py to .gitattributes (in addition to __init__): - ``` - __init__.py export-subst - setup.py export-subst - ``` - Then supply "$Format:%h$" for archive_commit. - - """ - import warnings - pkgname = reponame if pkgname is None else pkgname - if archive_commit is None: - warnings.warn("No archive commit available; git archives will not contain version information") - return Version.setup_version(os.path.dirname(os.path.abspath(location)),reponame,pkgname=pkgname,archive_commit=archive_commit) - - -def get_setupcfg_version(): - """As get_setup_version(), but configure via setup.cfg. - - If your project uses setup.cfg to configure setuptools, and hence has - at least a "name" key in the [metadata] section, you can - set the version as follows: - ``` - [metadata] - name = mypackage - version = attr: autover.version.get_setup_version2 - ``` - - If the repository name is different from the package name, specify - `reponame` as a [tool:autover] option: - ``` - [tool:autover] - reponame = mypackage - ``` - - To ensure git information is included in a git archive, add - setup.cfg to .gitattributes (in addition to __init__): - ``` - __init__.py export-subst - setup.cfg export-subst - ``` - - Then add the following to setup.cfg: - ``` - [tool:autover.configparser_workaround.archive_commit=$Format:%h$] - ``` - - The above being a section heading rather than just a key is - because setuptools requires % to be escaped with %, or it can't - parse setup.cfg...but then git export-subst would not work. - - """ - try: - import configparser - except ImportError: - import ConfigParser as configparser # python2 (also prevents dict-like access) - import re - cfg = "setup.cfg" - autover_section = 'tool:autover' - config = configparser.ConfigParser() - config.read(cfg) - pkgname = config.get('metadata','name') - reponame = config.get(autover_section,'reponame',vars={'reponame':pkgname}) if autover_section in config.sections() else pkgname - - ### - # hack archive_commit into section heading; see docstring - archive_commit = None - archive_commit_key = autover_section+'.configparser_workaround.archive_commit' - for section in config.sections(): - if section.startswith(archive_commit_key): - archive_commit = re.match(r".*=\s*(\S*)\s*",section).group(1) - ### - return get_setup_version(cfg,reponame=reponame,pkgname=pkgname,archive_commit=archive_commit) - - -# from param/version.py aa087db29976d9b7e0f59c29789dfd721c85afd0 -class OldDeprecatedVersion(object): - """ - A simple approach to Python package versioning that supports PyPI - releases and additional information when working with version - control. When obtaining a package from PyPI, the version returned - is a string-formatted rendering of the supplied release tuple. - For instance, release (1,0) tagged as ``v1.0`` in the version - control system will return ``1.0`` for ``str(__version__)``. Any - number of items can be supplied in the release tuple, with either - two or three numeric versioning levels typical. - - During development, a command like ``git describe`` will be used to - compute the number of commits since the last version tag, the - short commit hash, and whether the commit is dirty (has changes - not yet committed). Version tags must start with a lowercase 'v' - and have a period in them, e.g. v2.0, v0.9.8 or v0.1. - - Development versions are supported by setting the dev argument to an - appropriate dev version number. The corresponding tag can be PEP440 - compliant (using .devX) of the form v0.1.dev3, v1.9.0.dev2 etc but - it doesn't have to be as the dot may be omitted i.e v0.1dev3, - v1.9.0dev2 etc. - - Also note that when version control system (VCS) information is - used, the comparison operators take into account the number of - commits since the last version tag. This approach is often useful - in practice to decide which version is newer for a single - developer, but will not necessarily be reliable when comparing - against a different fork or branch in a distributed VCS. - - For git, if you want version control information available even in - an exported archive (e.g. a .zip file from GitHub), you can set - the following line in the .gitattributes file of your project:: - - __init__.py export-subst - """ - - def __init__(self, release=None, fpath=None, commit=None, - reponame=None, dev=None, commit_count=0): - """ - :release: Release tuple (corresponding to the current VCS tag) - :commit Short SHA. Set to '$Format:%h$' for git archive support. - :fpath: Set to ``__file__`` to access version control information - :reponame: Used to verify VCS repository name. - :dev: Development version number. None if not a development version. - :commit_count Commits since last release. Set for dev releases. - """ - self.fpath = fpath - self._expected_commit = commit - self.expected_release = release - - self._commit = None if commit in [None, "$Format:%h$"] else commit - self._commit_count = commit_count - self._release = None - self._dirty = False - self.reponame = reponame - self.dev = dev - - @property - def release(self): - "Return the release tuple" - return self.fetch()._release - - @property - def commit(self): - "A specification for this particular VCS version, e.g. a short git SHA" - return self.fetch()._commit - - @property - def commit_count(self): - "Return the number of commits since the last release" - return self.fetch()._commit_count - - @property - def dirty(self): - "True if there are uncommitted changes, False otherwise" - return self.fetch()._dirty - - - def fetch(self): - """ - Returns a tuple of the major version together with the - appropriate SHA and dirty bit (for development version only). - """ - if self._release is not None: - return self - - self._release = self.expected_release - if not self.fpath: - self._commit = self._expected_commit - return self - - # Only git right now but easily extended to SVN, Mercurial, etc. - for cmd in ['git', 'git.cmd', 'git.exe']: - try: - self.git_fetch(cmd) - break - except EnvironmentError: - pass - return self - - - def git_fetch(self, cmd='git'): - try: - if self.reponame is not None: - # Verify this is the correct repository (since fpath could - # be an unrelated git repository, and param could just have - # been copied/installed into it). - output = run_cmd([cmd, 'remote', '-v'], - cwd=os.path.dirname(self.fpath)) - repo_matches = ['/' + self.reponame + '.git' , - # A remote 'server:reponame.git' can also be referred - # to (i.e. cloned) as `server:reponame`. - '/' + self.reponame + ' '] - if not any(m in output for m in repo_matches): - return self - - output = run_cmd([cmd, 'describe', '--long', '--match', 'v*.*', '--dirty'], - cwd=os.path.dirname(self.fpath)) - except Exception as e: - if e.args[1] == 'fatal: No names found, cannot describe anything.': - raise Exception("Cannot find any git version tags of format v*.*") - # If there is any other error, return (release value still useful) - return self - - self._update_from_vcs(output) - - def _update_from_vcs(self, output): - "Update state based on the VCS state e.g the output of git describe" - split = output[1:].split('-') - if 'dev' in split[0]: - dev_split = split[0].split('dev') - self.dev = int(dev_split[1]) - split[0] = dev_split[0] - # Remove the pep440 dot if present - if split[0].endswith('.'): - split[0] = dev_split[0][:-1] - - self._release = tuple(int(el) for el in split[0].split('.')) - self._commit_count = int(split[1]) - self._commit = str(split[2][1:]) # Strip out 'g' prefix ('g'=>'git') - self._dirty = (split[-1]=='dirty') - return self - - - def __str__(self): - """ - Version in x.y.z string format. Does not include the "v" - prefix of the VCS version tags, for pip compatibility. - - If the commit count is non-zero or the repository is dirty, - the string representation is equivalent to the output of:: - - git describe --long --match v*.* --dirty - - (with "v" prefix removed). - """ - if self.release is None: return 'None' - release = '.'.join(str(el) for el in self.release) - release = '%s.dev%d' % (release, self.dev) if self.dev is not None else release - - if (self._expected_commit is not None) and ("$Format" not in self._expected_commit): - pass # Concrete commit supplied - print full version string - elif (self.commit_count == 0 and not self.dirty): - return release - - dirty_status = '-dirty' if self.dirty else '' - return '%s-%s-g%s%s' % (release, self.commit_count if self.commit_count else 'x', - self.commit, dirty_status) - - def __repr__(self): - return str(self) - - def abbrev(self,dev_suffix=""): - """ - Abbreviated string representation, optionally declaring whether it is - a development version. - """ - return '.'.join(str(el) for el in self.release) + \ - (dev_suffix if self.commit_count > 0 or self.dirty else "") - - - def __eq__(self, other): - """ - Two versions are considered equivalent if and only if they are - from the same release, with the same commit count, and are not - dirty. Any dirty version is considered different from any - other version, since it could potentially have any arbitrary - changes even for the same release and commit count. - """ - if self.dirty or other.dirty: return False - return ((self.release, self.commit_count, self.dev) - == (other.release, other.commit_count, other.dev)) - - def __gt__(self, other): - if self.release == other.release: - if self.dev == other.dev: - return self.commit_count > other.commit_count - elif None in [self.dev, other.dev]: - return self.dev is None - else: - return self.dev > other.dev - else: - return (self.release, self.commit_count) > (other.release, other.commit_count) - - def __lt__(self, other): - if self==other: - return False - else: - return not (self > other) - - - def verify(self, string_version=None): - """ - Check that the version information is consistent with the VCS - before doing a release. If supplied with a string version, - this is also checked against the current version. Should be - called from setup.py with the declared package version before - releasing to PyPI. - """ - if string_version and string_version != str(self): - raise Exception("Supplied string version does not match current version.") - - if self.dirty: - raise Exception("Current working directory is dirty.") - - if self.release != self.expected_release: - raise Exception("Declared release does not match current release tag.") - - if self.commit_count !=0: - raise Exception("Please update the VCS version tag before release.") - - if self._expected_commit not in [None, "$Format:%h$"]: - raise Exception("Declared release does not match the VCS version tag") diff --git a/conda.recipe/meta.yaml b/conda.recipe/meta.yaml index 24f2d68..394ade2 100644 --- a/conda.recipe/meta.yaml +++ b/conda.recipe/meta.yaml @@ -1,43 +1,47 @@ -{% set sdata = load_setup_py_data() %} +{% set pyproject = load_file_data('../pyproject.toml', from_recipe_dir=True) %} +{% set buildsystem = pyproject['build-system'] %} +{% set project = pyproject['project'] %} + +{% set name = project['name'] %} +{% set version = VERSION %} package: - name: colorcet - version: {{ sdata['version'] }} + name: {{ name|lower }} + version: {{ version }} source: path: .. build: noarch: python - script: python setup.py install --single-version-externally-managed --record=record.txt - entry_points: - {% for group,epoints in sdata.get("entry_points",{}).items() %} - {% for entry_point in epoints %} - - {{ entry_point }} - {% endfor %} - {% endfor %} + script: {{ PYTHON }} -m pip install . -vv requirements: build: - - python {{ sdata['python_requires'] }} - {% for dep in sdata['extras_require']['build'] %} + - python {{ project['requires-python'] }} + - pip + {% for dep in buildsystem['requires'] %} - {{ dep }} {% endfor %} run: - - python {{ sdata['python_requires'] }} - {% for dep in sdata.get('install_requires',{}) %} - - {{ dep }} - {% endfor %} + - python {{ project['requires-python'] }} test: - imports: - - colorcet requires: - {% for dep in sdata['extras_require']['tests'] %} - - "{{ dep }}" + {% for dep in project['optional-dependencies']['tests'] %} + - {{ dep }} {% endfor %} + source_files: + - pyproject.toml + - colorcet + imports: + - colorcet + commands: + - python -c "import colorcet; ver = colorcet.__version__; assert ver != '0.0.0' and ver != 'unknown'" + - pytest colorcet/ about: - home: {{ sdata['url'] }} - summary: {{ sdata['description'] }} - license: {{ sdata['license'] }} + home: {{ project['urls']['Homepage'] }} + summary: {{ project['description'] }} + license: {{ project['license']['text'] }} + license_file: LICENSE.txt diff --git a/examples/assets/images/census_fire.png b/doc/assets/images/census_fire.png similarity index 100% rename from examples/assets/images/census_fire.png rename to doc/assets/images/census_fire.png diff --git a/examples/assets/images/census_hot.png b/doc/assets/images/census_hot.png similarity index 100% rename from examples/assets/images/census_hot.png rename to doc/assets/images/census_hot.png diff --git a/examples/assets/images/fire.png b/doc/assets/images/fire.png similarity index 100% rename from examples/assets/images/fire.png rename to doc/assets/images/fire.png diff --git a/examples/assets/images/hot.png b/doc/assets/images/hot.png similarity index 100% rename from examples/assets/images/hot.png rename to doc/assets/images/hot.png diff --git a/examples/assets/images/jet.png b/doc/assets/images/jet.png similarity index 100% rename from examples/assets/images/jet.png rename to doc/assets/images/jet.png diff --git a/examples/assets/images/named.png b/doc/assets/images/named.png similarity index 100% rename from examples/assets/images/named.png rename to doc/assets/images/named.png diff --git a/examples/assets/images/rainbow.png b/doc/assets/images/rainbow.png similarity index 100% rename from examples/assets/images/rainbow.png rename to doc/assets/images/rainbow.png diff --git a/examples/assets/images/rainbow4.png b/doc/assets/images/rainbow4.png similarity index 100% rename from examples/assets/images/rainbow4.png rename to doc/assets/images/rainbow4.png diff --git a/examples/assets/write_named.py b/doc/assets/write_named.py similarity index 100% rename from examples/assets/write_named.py rename to doc/assets/write_named.py diff --git a/doc/conf.py b/doc/conf.py index 2b76a2e..6285e81 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -12,15 +12,12 @@ nbbuild_cell_timeout = 10000 +exclude_patterns = ['governance'] html_static_path += ['_static'] html_theme = 'pydata_sphinx_theme' - -templates_path = ['_templates'] - html_logo = "_static/logo_horizontal.png" html_favicon = "_static/favicon.ico" -html_css_files = [ - 'nbsite.css', +html_css_files += [ 'custom.css' ] diff --git a/doc/getting_started/index.rst b/doc/getting_started/index.rst index c316a4f..86c0c8e 100644 --- a/doc/getting_started/index.rst +++ b/doc/getting_started/index.rst @@ -5,7 +5,7 @@ Getting started Installation ------------ -Colorcet supports Python 2.7, 3.6, 3.7, 3.8 and 3.9 on Linux, Windows, or Mac +Colorcet supports Python 3.7 and greater on Linux, Windows, or Mac and can be installed with conda:: conda install colorcet @@ -57,18 +57,20 @@ or discuss on Gitter. Developer Instructions ---------------------- -1. Install Python 3 `miniconda `_ or `anaconda `_, if you don't already have it on your system. +1. Install Python and pip. 2. Clone the colorcet git repository if you do not already have it:: git clone git://github.com/pyviz/colorcet.git -3. Set up a new conda environment with optional plotting tools:: +3. Set up a new environment with all the required dependencies:: cd colorcet - conda env create -n colorcet matplotlib bokeh holoviews - conda activate colorcet + # + pip install -e .[all] -4. Put the colorcet directory into the Python path in this environment:: +4. Run the unit tests / run the examples tests / build the docs :: - pip install -e . + pytest colorcet + pytest doc --nbval-lax -p no:python + sphinx-build -b html doc builtdocs diff --git a/doc/governance/project-docs/CONTRIBUTING.md b/doc/governance/project-docs/CONTRIBUTING.md index fdfa21f..19a23ab 100644 --- a/doc/governance/project-docs/CONTRIBUTING.md +++ b/doc/governance/project-docs/CONTRIBUTING.md @@ -1,5 +1,5 @@ # Contributing - + For the contributing policy, see [HoloViz/HoloViz - CONTRIBUTING.md](https://github.com/holoviz/holoviz/blob/colorcet-gov/doc/governance/project-docs/CONTRIBUTING.md). - + The Colorcet Project’s equivalently named documents take precedence over any external materials referenced within this linked document above. diff --git a/doc/governance/project-docs/LICENSE.md b/doc/governance/project-docs/LICENSE.md index 2a6c34a..ec6d16e 100644 --- a/doc/governance/project-docs/LICENSE.md +++ b/doc/governance/project-docs/LICENSE.md @@ -1,3 +1,3 @@ # License - + For the license, see [HoloViz/Colorcet - LICENSE.txt](https://github.com/holoviz/colorcet/blob/main/LICENSE.txt). diff --git a/examples/index.ipynb b/doc/index.ipynb similarity index 95% rename from examples/index.ipynb rename to doc/index.ipynb index 44c8768..b203b65 100644 --- a/examples/index.ipynb +++ b/doc/index.ipynb @@ -117,10 +117,25 @@ "\n", "## Samples\n", "\n", - "\n", + "![named](assets/images/named.png)\n", "\n", "The complete set of 100+ maps is shown in the [User Guide](./user_guide/index.ipynb)." ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "```{toctree}\n", + ":hidden:\n", + ":maxdepth: 2\n", + "\n", + "Introduction \n", + "Getting Started \n", + "User Guide \n", + "About \n", + "```" + ] } ], "metadata": { diff --git a/doc/index.rst b/doc/index.rst deleted file mode 100644 index 81c8c06..0000000 --- a/doc/index.rst +++ /dev/null @@ -1,26 +0,0 @@ -.. - Originally generated by nbsite (0.6.0a1): - /Users/jsignell/conda/envs/colorcet/bin/nbsite generate-rst --org pyviz --project-name colorcet --offset 0 - Will not subsequently be overwritten by nbsite, so can be edited. - -.. raw:: html - -

- -.. notebook:: colorcet ../examples/index.ipynb - :offset: 0 - :disable_interactivity_warning: - -.. toctree:: - :hidden: - :maxdepth: 2 - - Introduction - Getting Started - User Guide - About - - -------- - -`Right click to download this notebook from GitHub. `_ diff --git a/examples/user_guide/Categorical.ipynb b/doc/user_guide/Categorical.ipynb similarity index 99% rename from examples/user_guide/Categorical.ipynb rename to doc/user_guide/Categorical.ipynb index fcbf251..8e2ff43 100644 --- a/examples/user_guide/Categorical.ipynb +++ b/doc/user_guide/Categorical.ipynb @@ -4,6 +4,8 @@ "cell_type": "markdown", "metadata": {}, "source": [ + "# Categorical\n", + "\n", "## Glasbey colormaps for categorical data\n", "\n", "Colorcet primarily includes continuous colormaps, where each color is meant to be equally spaced in perceptual color space from the preceding and following colors. The resulting colors then convey numerical magnitude to the viewer. Categorical data can also be represented as numbers, but each number is then distinct, with the numerical value important only to distinguish from other values. When categorical data is plotted as colors, each category should have a color visibly distinct from all the other colors, _not_ nearby in color space, to make each category separately visible. \n", diff --git a/doc/user_guide/Categorical.rst b/doc/user_guide/Categorical.rst deleted file mode 100644 index 26c2178..0000000 --- a/doc/user_guide/Categorical.rst +++ /dev/null @@ -1,16 +0,0 @@ -.. - Originally generated by nbsite (0.4.6): - /Users/jbednar/miniconda3/envs/holoviz/bin/nbsite generate-rst --org holoviz --project-name colorcet --offset 0 - Will not subsequently be overwritten by nbsite, so can be edited. - -*********** -Categorical -*********** - -.. notebook:: colorcet ../../examples/user_guide/Categorical.ipynb - :offset: 0 - :disable_interactivity_warning: - -------- - -`Right click to download this notebook from GitHub. `_ diff --git a/examples/user_guide/Continuous.ipynb b/doc/user_guide/Continuous.ipynb similarity index 99% rename from examples/user_guide/Continuous.ipynb rename to doc/user_guide/Continuous.ipynb index 5dc5015..4386c71 100644 --- a/examples/user_guide/Continuous.ipynb +++ b/doc/user_guide/Continuous.ipynb @@ -4,6 +4,8 @@ "cell_type": "markdown", "metadata": {}, "source": [ + "# Continuous\n", + "\n", "## Perceptually uniform continuous colormaps from CET\n", "\n", "Peter Kovesi at the Center for Exploration Targeting created a very useful set of [perceptually uniform continuous colormaps](https://arxiv.org/abs/1509.03700), many of which can replace the highly non-uniform colormaps provided with Python plotting programs. Here we will show how to use them via a Python package named [colorcet](https://github.com/holoviz/colorcet), listing all the ones available and allowing you to evaluate how perceptually uniform they are for you, your particular monitor, etc. Download and installation instructions are at the [github site](https://github.com/holoviz/colorcet).\n", diff --git a/doc/user_guide/Continuous.rst b/doc/user_guide/Continuous.rst deleted file mode 100644 index efc2570..0000000 --- a/doc/user_guide/Continuous.rst +++ /dev/null @@ -1,17 +0,0 @@ -.. - Originally generated by nbsite (0.4.6): - /Users/jbednar/miniconda3/envs/holoviz/bin/nbsite generate-rst --org holoviz --project-name colorcet --offset 0 - Will not subsequently be overwritten by nbsite, so can be edited. - -********** -Continuous -********** - -.. notebook:: colorcet ../../examples/user_guide/Continuous.ipynb - :offset: 0 - :disable_interactivity_warning: - - -------- - -`Right click to download this notebook from GitHub. `_ diff --git a/examples/user_guide/index.ipynb b/doc/user_guide/index.ipynb similarity index 95% rename from examples/user_guide/index.ipynb rename to doc/user_guide/index.ipynb index 6beebe0..cfd0944 100644 --- a/examples/user_guide/index.ipynb +++ b/doc/user_guide/index.ipynb @@ -4,6 +4,8 @@ "cell_type": "markdown", "metadata": {}, "source": [ + "# User Guide\n", + "\n", "## Accessing the colormaps\n", "\n", "After importing `colorcet` as `cc`, all the colormaps shown in this notebook will be available for use in different forms. It's a bit difficult to describe, but the idea is that colorcet should have at least one such form convenient for any particular application. There are three distinct versions for each colormap, each of which consists of 256 distinct colors: \n", @@ -141,6 +143,21 @@ "source": [ "For more explanation of the various options see [categorical](Categorical.ipynb) and [continuous](Continuous.ipynb)." ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "```{toctree}\n", + ":titlesonly:\n", + ":hidden:\n", + ":maxdepth: 2\n", + "\n", + "Accessing the colormaps \n", + "Continuous \n", + "Categorical \n", + "```" + ] } ], "metadata": { diff --git a/doc/user_guide/index.rst b/doc/user_guide/index.rst deleted file mode 100644 index faba56d..0000000 --- a/doc/user_guide/index.rst +++ /dev/null @@ -1,25 +0,0 @@ -.. - Originally generated by nbsite (0.6.1a4): - /Users/jsignell/conda/envs/colorcet/bin/nbsite generate-rst --org pyviz --project-name colorcet --offset 0 - Will not subsequently be overwritten by nbsite, so can be edited. - 2019-04-03 jsignell: reordered categorical and continuous to not be alphabetical - -********** -User Guide -********** - -.. notebook:: colorcet ../../examples/user_guide/index.ipynb - :offset: 0 - :disable_interactivity_warning: - -.. toctree:: - :titlesonly: - :maxdepth: 2 - - Continuous - Categorical - - -------- - -`Right click to download this notebook from GitHub. `_ diff --git a/dodo.py b/dodo.py deleted file mode 100644 index e254b4d..0000000 --- a/dodo.py +++ /dev/null @@ -1,38 +0,0 @@ -""" -This file provides a mechanism to map between the semantic commands that any -project has (build docs, run tests, copy examples ... ) and the specific -command that should be run. - -Most of these commands are stored in pyctdev which is essentially a collection -of the holoviz way of doing these actions. Commands that are newer, or specific -to a particular project, will live in this file instead. To see a list of -all the available commands - after installing pyctdev - run: - -$ doit list - -To run one command, for instance building the website, run: - -$ doit build_website -""" - -import os -if "PYCTDEV_ECOSYSTEM" not in os.environ: - os.environ["PYCTDEV_ECOSYSTEM"] = "conda" -from pyctdev import * # noqa: api - - -def task_build_website(): - return {'actions': [ - "nbsite generate-rst --org holoviz --project-name colorcet", - "nbsite build --what=html --output=builtdocs --org holoviz --project-name colorcet", - ]} - - -def task_pip_on_conda(): - """Experimental: provide pip build env via conda""" - return {'actions':[ - # some ecosystem=pip build tools must be installed with conda when using conda... - 'conda install -y pip twine wheel rfc3986 keyring', - # ..and some are only available via conda-forge - 'conda install -y -c conda-forge tox virtualenv', - ]} diff --git a/pyproject.toml b/pyproject.toml index 1696485..475b7e2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,86 @@ [build-system] requires = [ - "pyct >=0.4.4", "setuptools >=30.3.0", - "wheel", + "setuptools_scm >=6", ] +build-backend = "setuptools.build_meta" + +[project] +name = "colorcet" +dynamic = ["version"] +description = "Collection of perceptually uniform colormaps" +readme = "README.md" +license = { text = "CC-BY License" } +requires-python = ">=3.7" +authors = [ + { name = "James A. Bednar", email = "jbednar@anaconda.com" }, +] +maintainers = [ + { name = "James A. Bednar", email = "jbednar@anaconda.com" }, +] +classifiers = [ + "License :: OSI Approved", + "Operating System :: OS Independent", + "Programming Language :: Python", + "Programming Language :: Python :: 3.7", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Development Status :: 5 - Production/Stable", +] +dependencies = [] + +[project.urls] +Homepage = "https://colorcet.holoviz.org" +Source = "http://github.com/holoviz/colorcet" +HoloViz = "https://holoviz.org/" + +[project.optional-dependencies] +tests = [ + "pre-commit", + "pytest >=2.8.5", + "pytest-cov", + "packaging", +] +tests_extra = [ + "colorcet[tests]", + "pytest-mpl", # only available on pip and conda-forge +] +examples = [ + "numpy", + "holoviews", + "matplotlib", + "bokeh", +] +tests_examples = [ + "colorcet[examples]", + "nbval", +] +doc = [ + "colorcet[examples]", + "nbsite >=0.8.4", + "sphinx-copybutton", +] +all = [ + "colorcet[tests]", + "colorcet[tests_extra]", + "colorcet[examples]", + "colorcet[doc]", +] + +[tool.setuptools] +# To exclude PNG files in colorcet/tests/baseline +include-package-data = false + +[tool.setuptools.packages.find] +include = ["colorcet"] + +[tool.setuptools_scm] +# Replace with version_file when Python 3.7 is dropped. +write_to = "colorcet/_version.py" + +[tool.pytest.ini_options] +addopts = "-v --pyargs" +norecursedirs = "doc .git dist build _build .ipynb_checkpoints" diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index 74b403e..0000000 --- a/setup.cfg +++ /dev/null @@ -1,5 +0,0 @@ -[metadata] -license_file = LICENSE.txt - -[wheel] -universal = 1 diff --git a/setup.py b/setup.py deleted file mode 100644 index 2684d1f..0000000 --- a/setup.py +++ /dev/null @@ -1,119 +0,0 @@ -import os -import sys -import shutil -from setuptools import setup, find_packages - -import pyct.build - -def get_setup_version(reponame): - """ - Helper to get the current version from either git describe or the - .version file (if available). - """ - import json - basepath = os.path.split(__file__)[0] - version_file_path = os.path.join(basepath, reponame, '.version') - try: - from colorcet import version - except: - version = None - if version is not None: - return version.Version.setup_version(basepath, reponame, archive_commit="$Format:%h$") - else: - return json.load(open(version_file_path, 'r'))['version_string'] - - -########## dependencies ########## - -install_requires = [ - 'pyct >=0.4.4', -] - -examples = [ - 'numpy', - 'holoviews', - 'matplotlib', - 'bokeh', -] - -tests = [ - 'flake8', - 'nbsmoke >=0.2.6', - 'pytest >=2.8.5', - 'pytest-cov', - 'packaging', -] - -extras_require = { - 'tests': tests, - 'examples': examples, - 'doc': examples + [ - 'nbsite >=0.8.4', - 'sphinx-copybutton', - ], - 'tests_extra': tests + [ - 'pytest-mpl' # only available on pip and conda-forge - ], - # until pyproject.toml/equivalent is widely supported (setup_requires - # doesn't work well with pip) - 'build': [ - 'pyct >=0.4.4', - 'setuptools >=30.3.0', - 'wheel', - ] -} - -extras_require['all'] = sorted(set(sum(extras_require.values(), []))) - -setup_args = dict( - name='colorcet', - description='Collection of perceptually uniform colormaps', - version=get_setup_version('colorcet'), - long_description=open("README.md", mode="r", encoding="utf-8").read(), - long_description_type='text/markdown', - license_files=['LICENSE.txt'], - license='CC-BY License', - classifiers=[ - "License :: OSI Approved", - "Operating System :: OS Independent", - "Programming Language :: Python", - "Programming Language :: Python :: 3.7", - "Programming Language :: Python :: 3.8", - "Programming Language :: Python :: 3.9", - "Programming Language :: Python :: 3.10", - "Programming Language :: Python :: 3.11", - "Development Status :: 5 - Production/Stable", - ], - author="James A. Bednar", - author_email="jbednar@anaconda.com", - maintainer="James A. Bednar", - maintainer_email="jbednar@anaconda.com", - url="https://colorcet.holoviz.org", - project_urls = { - "Bug Tracker": "http://github.com/holoviz/colorcet/issues", - "Documentation": "https://colorcet.holoviz.org", - "Source Code": "http://github.com/holoviz/colorcet", - }, - include_package_data=True, - packages=find_packages(), - python_requires=">=3.7", - install_requires=install_requires, - extras_require=extras_require, - entry_points={ - 'console_scripts': [ - 'colorcet = colorcet.__main__:main' - ] - }, -) - - -if __name__=="__main__": - example_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), - 'colorcet','examples') - if 'develop' not in sys.argv: - pyct.build.examples(example_path, __file__, force=True) - - setup(**setup_args) - - if os.path.isdir(example_path): - shutil.rmtree(example_path) diff --git a/tox.ini b/tox.ini deleted file mode 100644 index 981fd67..0000000 --- a/tox.ini +++ /dev/null @@ -1,58 +0,0 @@ -# For use with pyctdev (but should work with tox alone) - -[tox] -envlist = {py37,py38,py39,py310,py311}-{lint,unit,unit_extra,examples,all}-{default}-{dev,pkg} -build = wheel - -[_lint] -description = Lint check python code and notebooks -deps = .[tests] -commands = flake8 - pytest --nbsmoke-lint -k ".ipynb" - -[_unit] -description = There are just some basic unit tests so far -deps = .[tests] -commands = pytest colorcet --cov=colorcet --cov-append --cov-report xml - -[_unit_extra] -description = Run the unit tests with pytest-mpl and matplotlib -deps = .[examples,tests_extra] -commands = pytest colorcet --mpl - -[_examples] -description = Test that the examples run without exceptions -deps = .[examples,tests] -commands = pytest --nbsmoke-run -k ".ipynb" - -[_all] -description = Run all the tests -deps = .[examples, tests] -commands = {[_lint]commands} - {[_unit]commands} - {[_examples]commands} - -[testenv] -changedir = {envtmpdir} - -commands = unit: {[_unit]commands} - unit_extra: {[_unit_extra]commands} - lint: {[_lint]commands} - examples: {[_examples]commands} - all: {[_all]commands} - -deps = unit: {[_unit]deps} - unit_extra: {[_unit_extra]deps} - lint: {[_lint]deps} - examples: {[_examples]deps} - all: {[_all]deps} - -[pytest] -addopts = -v --pyargs -norecursedirs = doc .git dist build _build .ipynb_checkpoints - -[flake8] -include = *.py -exclude = .git,__pycache__,.tox,.eggs,*.egg,doc,dist,build,_build,.ipynb_checkpoints,run_test.py -ignore = E, - W