Skip to content

Commit

Permalink
Use *uv* and *hatch* and enable *Python* 3.13.
Browse files Browse the repository at this point in the history
  • Loading branch information
KelSolaar committed Oct 12, 2024
1 parent 8d762cd commit 0bcceef
Show file tree
Hide file tree
Showing 14 changed files with 380 additions and 320 deletions.
4 changes: 2 additions & 2 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ is available to guide the process: https://www.colour-science.org/contributing/.
- [ ] Pyright static checking has been run and passed.
- [ ] Pre-commit hooks have been run and passed.

<!-- The unit tests can be invoked with `poetry run invoke tests` -->
<!-- Pyright can be started with `pyright --skipunannotated` -->
<!-- The unit tests can be invoked with `uv run invoke tests` -->
<!-- Pyright can be started with `pyright --threads --skipunannotated` -->

**Documentation**

Expand Down
14 changes: 6 additions & 8 deletions .github/workflows/continuous-integration-documentation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest]
python-version: [3.12]
python-version: [3.13]
fail-fast: false
runs-on: ${{ matrix.os }}
steps:
Expand All @@ -29,18 +29,16 @@ jobs:
run: |
sudo apt-get update
sudo apt-get --yes install latexmk texlive-full
- name: Install Poetry
- name: Install uv
run: |
curl -sSL https://install.python-poetry.org | POETRY_HOME=$HOME/.poetry python3 -
echo "$HOME/.poetry/bin" >> $GITHUB_PATH
pip install uv
shell: bash
- name: Install Package Dependencies
run: |
poetry run python -m pip install --upgrade pip
poetry install
poetry run python -c "import imageio;imageio.plugins.freeimage.download()"
uv sync --all-extras --no-dev
uv run python -c "import imageio;imageio.plugins.freeimage.download()"
shell: bash
- name: Build Documentation
run: |
poetry run invoke docs
uv run invoke docs
shell: bash
23 changes: 11 additions & 12 deletions .github/workflows/continuous-integration-quality-unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest]
python-version: [3.12]
python-version: [3.13]
fail-fast: false
runs-on: ${{ matrix.os }}
steps:
Expand All @@ -20,37 +20,36 @@ jobs:
echo "CI_SHA=${{ github.sha }}" >> $GITHUB_ENV
echo "COVERALLS_REPO_TOKEN=${{ secrets.COVERALLS_REPO_TOKEN }}" >> $GITHUB_ENV
shell: bash
- name: Set up Python 3.9 for Pre-Commit
- name: Set up Python 3.10 for Pre-Commit
uses: actions/setup-python@v5
with:
python-version: 3.9
python-version: "3.10"
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install Poetry
- name: Install uv
run: |
curl -sSL https://install.python-poetry.org | POETRY_HOME=$HOME/.poetry python3 -
echo "$HOME/.poetry/bin" >> $GITHUB_PATH
pip install uv
shell: bash
- name: Install Package Dependencies
run: |
poetry run python -m pip install --upgrade pip
poetry install
uv sync --all-extras --no-dev
uv run python -c "import imageio;imageio.plugins.freeimage.download()"
shell: bash
- name: Pre-Commit (All Files)
run: |
poetry run pre-commit run --all-files
uv run pre-commit run --all-files
shell: bash
- name: Test Optimised Python Execution
run: |
poetry run python -OO -c "import $CI_PACKAGE"
uv run python -OO -c "import $CI_PACKAGE"
shell: bash
- name: Test with Pytest
run: |
poetry run python -W ignore -m pytest --doctest-modules --ignore=$CI_PACKAGE/examples --cov=$CI_PACKAGE $CI_PACKAGE
uv run python -W ignore -m pytest --doctest-modules --ignore=$CI_PACKAGE/examples --cov=$CI_PACKAGE $CI_PACKAGE
shell: bash
- name: Upload Coverage to coveralls.io
run: |
if [ -z "$COVERALLS_REPO_TOKEN" ]; then echo \"COVERALLS_REPO_TOKEN\" secret is undefined!; else poetry run coveralls; fi
if [ -z "$COVERALLS_REPO_TOKEN" ]; then echo \"COVERALLS_REPO_TOKEN\" secret is undefined!; else uv run coveralls; fi
shell: bash
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
python-version: ${{ matrix.python-version }}
- name: Install Package Dependencies
run: |
pip install -r requirements.txt
cat requirements.txt | grep -Eo '(^[^#]+)' | xargs -n 1 pip install || true
- name: Static Type Checking
run: |
pyright --skipunannotated
pyright --threads --skipunannotated
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
.fleet
.idea
.ipynb_checkpoints
.python-version
.sandbox
.vs
.vscode
Expand All @@ -18,4 +19,4 @@ docs/_build
docs/generated
references
zenodo
poetry.lock
uv.lock
10 changes: 5 additions & 5 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -160,14 +160,14 @@ Primary Dependencies

**Colour - Datasets** requires various dependencies in order to run:

- `python >= 3.9, < 4 <https://www.python.org/download/releases>`__
- `python >= 3.10, < 3.14 <https://www.python.org/download/releases>`__
- `cachetools <https://pypi.org/project/cachetools>`__
- `colour-science >= 4.3 <https://pypi.org/project/colour-science>`__
- `colour-science >= 4.4 <https://pypi.org/project/colour-science>`__
- `imageio >= 2, < 3 <https://imageio.github.io>`__
- `numpy >= 1.22, < 2 <https://pypi.org/project/numpy>`__
- `scipy >= 1.8, < 2 <https://pypi.org/project/scipy>`__
- `numpy >= 1.24, < 3 <https://pypi.org/project/numpy>`__
- `scipy >= 1.10, < 2 <https://pypi.org/project/scipy>`__
- `tqdm <https://pypi.org/project/tqdm>`__
- `xlrd <https://pypi.org/project/xlrd>`__
- `xlrd >=1.2, <2 <https://pypi.org/project/xlrd>`__

Pypi
~~~~
Expand Down
14 changes: 7 additions & 7 deletions TODO.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,34 +6,34 @@ TODO

- colour_datasets/__init__.py

- Line 78 : # TODO: Remove legacy printing support when deemed appropriate.
- Line 74 : # TODO: Remove legacy printing support when deemed appropriate.


- colour_datasets/records/zenodo.py

- Line 450 : # TODO: Remove the following space escaping: The new Zenodo API is not quoting filenames properly thus we are temporarily escaping spaces for now. https://github.com/colour-science/colour-datasets/issues/ 36issuecomment-1773464695
- Line 433 : # TODO: Remove the following space escaping: The new Zenodo API is not quoting filenames properly thus we are temporarily escaping spaces for now. https://github.com/colour-science/colour-datasets/issues/ 36issuecomment-1773464695


- colour_datasets/utilities/common.py

- Line 42 : # TODO: Use *colour* definition.
- Line 43 : # TODO: Use *colour* definition.


- colour_datasets/loaders/kuopio.py

- Line 310 : # TODO: Implement support for *Natural Colors*: https://sandbox.zenodo.org/record/315640 http://www.uef.fi/web/spectral/natural-colors
- Line 304 : # TODO: Implement support for *Natural Colors*: https://sandbox.zenodo.org/record/315640 http://www.uef.fi/web/spectral/natural-colors


- colour_datasets/loaders/xrite2016.py

- Line 109 : # TODO: Implement support for "CGATS" file format in "Colour": https://github.com/colour-science/colour/issues/354
- Line 108 : # TODO: Implement support for "CGATS" file format in "Colour": https://github.com/colour-science/colour/issues/354


- colour_datasets/loaders/dyer2017.py

- Line 141 : # TODO: Re-instate "manufacturer", "model", "illuminant" and "type" attributes according to outcome of https://github.com/ampas/rawtoaces/issues/114. Those attributes are currently stored in "self._kwargs".
- Line 928 : # TODO: Re-instate "manufacturer", "model", "illuminant" and "type" attributes according to outcome of https://github.com/ampas/rawtoaces/issues/114.
- Line 1430 : # TODO: Re-instate "manufacturer", "model", "illuminant" and "type" attributes according to outcome of https://github.com/ampas/rawtoaces/issues/114.
- Line 923 : # TODO: Re-instate "manufacturer", "model", "illuminant" and "type" attributes according to outcome of https://github.com/ampas/rawtoaces/issues/114.
- Line 1420 : # TODO: Re-instate "manufacturer", "model", "illuminant" and "type" attributes according to outcome of https://github.com/ampas/rawtoaces/issues/114.

About
-----
Expand Down
2 changes: 1 addition & 1 deletion colour_datasets/records/zenodo.py
Original file line number Diff line number Diff line change
Expand Up @@ -668,7 +668,7 @@ def __repr__(self) -> str:
Community(
{'community': {'access': {'member_policy': 'open',
'members_visibility': 'public',
'record_policy': 'open',
'record_submission_policy': 'open',
"""

data = "\n".join([f" {line}" for line in pformat(self._data).splitlines()])
Expand Down
18 changes: 12 additions & 6 deletions colour_datasets/utilities/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import json
import os
import shutil
import socket
import sys
import urllib.error
import urllib.request
Expand Down Expand Up @@ -158,12 +159,17 @@ def url_download(url: str, filename: str, md5: str | None = None, retries: int =
miniters=1,
desc=f'Downloading "{url}" url',
) as progress:
urllib.request.urlretrieve( # noqa: S310
url,
filename=filename,
reporthook=progress.update_to,
data=None,
)
timeout = socket.getdefaulttimeout()
try:
socket.setdefaulttimeout(10)
urllib.request.urlretrieve( # noqa: S310
url,
filename=filename,
reporthook=progress.update_to,
data=None,
)
finally:
socket.setdefaulttimeout(timeout)

if md5 is not None and md5.lower() != hash_md5(filename):
raise ValueError( # noqa: TRY301
Expand Down
10 changes: 5 additions & 5 deletions docs/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ Primary Dependencies

**Colour - Datasets** requires various dependencies in order to run:

- `python >= 3.9, < 4 <https://www.python.org/download/releases>`__
- `python >= 3.10, < 3.14 <https://www.python.org/download/releases>`__
- `cachetools <https://pypi.org/project/cachetools>`__
- `colour-science >= 4.3 <https://pypi.org/project/colour-science>`__
- `colour-science >= 4.4 <https://pypi.org/project/colour-science>`__
- `imageio >= 2, < 3 <https://imageio.github.io>`__
- `numpy >= 1.22, < 2 <https://pypi.org/project/numpy>`__
- `scipy >= 1.8, < 2 <https://pypi.org/project/scipy>`__
- `numpy >= 1.24, < 3 <https://pypi.org/project/numpy>`__
- `scipy >= 1.10, < 2 <https://pypi.org/project/scipy>`__
- `tqdm <https://pypi.org/project/tqdm>`__
- `xlrd <https://pypi.org/project/xlrd>`__
- `xlrd >=1.2, <2 <https://pypi.org/project/xlrd>`__

Pypi
----
Expand Down
101 changes: 55 additions & 46 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,46 +1,55 @@
accessible-pygments==0.0.4 ; python_version >= "3.9" and python_version < "3.13"
alabaster==0.7.13 ; python_version >= "3.9" and python_version < "3.13"
babel==2.14.0 ; python_version >= "3.9" and python_version < "3.13"
beautifulsoup4==4.12.2 ; python_version >= "3.9" and python_version < "3.13"
biblib-simple==0.1.2 ; python_version >= "3.9" and python_version < "3.13"
cachetools==5.3.2 ; python_version >= "3.9" and python_version < "3.13"
certifi==2023.11.17 ; python_version >= "3.9" and python_version < "3.13"
charset-normalizer==3.3.2 ; python_version >= "3.9" and python_version < "3.13"
colorama==0.4.6 ; python_version >= "3.9" and python_version < "3.13" and (platform_system == "Windows" or sys_platform == "win32")
colour-science==0.4.4 ; python_version >= "3.9" and python_version < "3.13"
docutils==0.20.1 ; python_version >= "3.9" and python_version < "3.13"
idna==3.6 ; python_version >= "3.9" and python_version < "3.13"
imageio==2.33.1 ; python_version >= "3.9" and python_version < "3.13"
imagesize==1.4.1 ; python_version >= "3.9" and python_version < "3.13"
importlib-metadata==7.0.0 ; python_version >= "3.9" and python_version < "3.10"
jinja2==3.1.2 ; python_version >= "3.9" and python_version < "3.13"
latexcodec==2.0.1 ; python_version >= "3.9" and python_version < "3.13"
markupsafe==2.1.3 ; python_version >= "3.9" and python_version < "3.13"
numpy==1.26.2 ; python_version >= "3.9" and python_version < "3.13"
opencv-python==4.8.1.78 ; python_version >= "3.9" and python_version < "3.13"
packaging==23.2 ; python_version >= "3.9" and python_version < "3.13"
pillow==10.1.0 ; python_version >= "3.9" and python_version < "3.13"
pybtex==0.24.0 ; python_version >= "3.9" and python_version < "3.13"
pybtex-docutils==1.0.3 ; python_version >= "3.9" and python_version < "3.13"
pydata-sphinx-theme==0.14.4 ; python_version >= "3.9" and python_version < "3.13"
pygments==2.17.2 ; python_version >= "3.9" and python_version < "3.13"
pyyaml==6.0.1 ; python_version >= "3.9" and python_version < "3.13"
requests==2.31.0 ; python_version >= "3.9" and python_version < "3.13"
restructuredtext-lint==1.4.0 ; python_version >= "3.9" and python_version < "3.13"
scipy==1.11.4 ; python_version >= "3.9" and python_version < "3.13"
six==1.16.0 ; python_version >= "3.9" and python_version < "3.13"
snowballstemmer==2.2.0 ; python_version >= "3.9" and python_version < "3.13"
soupsieve==2.5 ; python_version >= "3.9" and python_version < "3.13"
sphinx==7.2.6 ; python_version >= "3.9" and python_version < "3.13"
sphinxcontrib-applehelp==1.0.7 ; python_version >= "3.9" and python_version < "3.13"
sphinxcontrib-bibtex==2.6.1 ; python_version >= "3.9" and python_version < "3.13"
sphinxcontrib-devhelp==1.0.5 ; python_version >= "3.9" and python_version < "3.13"
sphinxcontrib-htmlhelp==2.0.4 ; python_version >= "3.9" and python_version < "3.13"
sphinxcontrib-jsmath==1.0.1 ; python_version >= "3.9" and python_version < "3.13"
sphinxcontrib-qthelp==1.0.6 ; python_version >= "3.9" and python_version < "3.13"
sphinxcontrib-serializinghtml==1.1.9 ; python_version >= "3.9" and python_version < "3.13"
tqdm==4.66.1 ; python_version >= "3.9" and python_version < "3.13"
typing-extensions==4.9.0 ; python_version >= "3.9" and python_version < "3.13"
urllib3==2.1.0 ; python_version >= "3.9" and python_version < "3.13"
xlrd==1.2.0 ; python_version >= "3.9" and python_version < "3.13"
zipp==3.17.0 ; python_version >= "3.9" and python_version < "3.10"
# This file was autogenerated by uv via the following command:
# uv export --no-hashes --all-extras --no-dev
accessible-pygments==0.0.5
alabaster==1.0.0
babel==2.16.0
beautifulsoup4==4.12.3
biblib-simple==0.1.2
cachetools==5.5.0
certifi==2024.8.30
charset-normalizer==3.4.0
colorama==0.4.6 ; sys_platform == 'win32' or platform_system == 'Windows'
colour-science==0.4.6
contourpy==1.3.0
cycler==0.12.1
docutils==0.21.2
fonttools==4.54.1
idna==3.10
imageio==2.35.1
imagesize==1.4.1
jinja2==3.1.4
kiwisolver==1.4.7
latexcodec==3.0.0
markupsafe==3.0.1
matplotlib==3.9.2
numpy==2.1.2
opencv-python==4.10.0.84
packaging==24.1
pillow==10.4.0
pybtex==0.24.0
pybtex-docutils==1.0.3
pydata-sphinx-theme==0.15.4
pygments==2.18.0
pyparsing==3.1.4
python-dateutil==2.9.0.post0
pyyaml==6.0.2
requests==2.32.3
restructuredtext-lint==1.4.0
scipy==1.14.1
setuptools==75.1.0 ; python_full_version >= '3.12'
six==1.16.0
snowballstemmer==2.2.0
soupsieve==2.6
sphinx==8.1.2
sphinxcontrib-applehelp==2.0.0
sphinxcontrib-bibtex==2.6.3
sphinxcontrib-devhelp==2.0.0
sphinxcontrib-htmlhelp==2.1.0
sphinxcontrib-jsmath==1.0.1
sphinxcontrib-qthelp==2.0.0
sphinxcontrib-serializinghtml==2.0.0
tomli==2.0.2 ; python_full_version < '3.11'
tqdm==4.66.5
typing-extensions==4.12.2
urllib3==2.2.3
xlrd==1.2.0
Loading

0 comments on commit 0bcceef

Please sign in to comment.