Skip to content

Commit

Permalink
Fix tasks to be up to date with uv. Fix doc configuration.
Browse files Browse the repository at this point in the history
Update reference to clf io repository.
  • Loading branch information
MichaelMauderer committed Nov 11, 2024
1 parent 2bcb82f commit f177fd2
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 76 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ repos:
rev: 1.16.0
hooks:
- id: blacken-docs
language_version: python3.9
language_version: python3.10
- repo: https://github.com/pre-commit/mirrors-prettier
rev: "v3.1.0"
hooks:
Expand Down
3 changes: 1 addition & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@
import sys
from pathlib import Path

import colour_clf_io as package

sys.path.append(str(Path(__file__).parent.parent))

import colour_clf_io as package # noqa: E402

basename = re.sub("_(\\w)", lambda x: x.group(1).upper(), package.__name__.title())

Expand Down
92 changes: 42 additions & 50 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,50 +1,42 @@
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"
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 sys_platform == "win32"
colour-science==0.4.4 ; python_version >= "3.9" and python_version < "3.13"
contourpy==1.2.0 ; python_version >= "3.9" and python_version < "3.13"
cycler==0.12.1 ; python_version >= "3.9" and python_version < "3.13"
docutils==0.20.1 ; python_version >= "3.9" and python_version < "3.13"
fonttools==4.46.0 ; 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"
importlib-resources==6.1.1 ; python_version >= "3.9" and python_version < "3.10"
jinja2==3.1.2 ; python_version >= "3.9" and python_version < "3.13"
kiwisolver==1.4.5 ; 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"
matplotlib==3.8.2 ; python_version >= "3.9" and python_version < "3.13"
numpy==1.26.2 ; 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"
pyparsing==3.1.1 ; python_version >= "3.9" and python_version < "3.13"
python-dateutil==2.8.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"
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"
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
certifi==2024.8.30
charset-normalizer==3.4.0
colorama==0.4.6 ; sys_platform == 'win32'
docutils==0.21.2
idna==3.10
imagesize==1.4.1
jinja2==3.1.4
latexcodec==3.0.0
lxml==5.3.0
lxml-stubs==0.5.1
markupsafe==3.0.2
numpy==2.1.2
packaging==24.2
pybtex==0.24.0
pybtex-docutils==1.0.3
pydata-sphinx-theme==0.16.0
pygments==2.18.0
pyyaml==6.0.2
requests==2.32.3
restructuredtext-lint==1.4.0
setuptools==75.3.0 ; python_full_version >= '3.12'
six==1.16.0
snowballstemmer==2.2.0
soupsieve==2.6
sphinx==8.1.3
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'
typing-extensions==4.12.2
urllib3==2.2.3
58 changes: 35 additions & 23 deletions tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
"PYPI_PACKAGE_NAME",
"PYPI_ARCHIVE_NAME",
"BIBLIOGRAPHY_NAME",
"literalise",
"clean",
"formatting",
"quality",
Expand Down Expand Up @@ -146,6 +147,24 @@ def inner(text):
print_callable("=" * width)


@task
def literalise(ctx: Context):
"""
Write various literals in the `colour.hints` module.
Parameters
----------
ctx
Context.
"""

message_box("Literalising...")
with ctx.cd("utilities"):
ctx.run("./literalise.py")

ctx.run("pre-commit run --files colour/hints/__init__.py", warn=True)


@task
def clean(
ctx: Context,
Expand All @@ -163,7 +182,7 @@ def clean(
docs
Whether to clean the *docs* directory.
bytecode
Whether to clean the bytecode files, e.g. *.pyc* files.
Whether to clean the bytecode files, e.g., *.pyc* files.
pytest
Whether to clean the *Pytest* cache directory.
"""
Expand Down Expand Up @@ -252,7 +271,7 @@ def quality(

if pyright:
message_box('Checking codebase with "Pyright"...')
ctx.run("pyright --skipunannotated --level warning")
ctx.run("pyright --threads --skipunannotated --level warning")

if rstlint:
message_box('Linting "README.rst" file...')
Expand Down Expand Up @@ -329,7 +348,7 @@ def examples(ctx: Context, plots: bool = False):
@task(formatting, quality, precommit, tests, examples)
def preflight(ctx: Context): # noqa: ARG001
"""
Perform the preflight tasks, i.e. *formatting*, *tests*, *quality*, and
Perform the preflight tasks, i.e., *formatting*, *tests*, *quality*, and
*examples*.
Parameters
Expand Down Expand Up @@ -400,26 +419,19 @@ def requirements(ctx: Context):
"""

message_box('Exporting "requirements.txt" file...')
ctx.run(
"poetry export -f requirements.txt "
"--without-hashes "
"--with dev,docs,graphviz,meshing,optional "
"--output requirements.txt"
)
ctx.run('uv export --no-hashes --all-extras | grep -v "-e \\." > requirements.txt')

message_box('Exporting "docs/requirements.txt" file...')
ctx.run(
"poetry export -f requirements.txt "
"--without-hashes "
"--with docs,graphviz,meshing,optional "
"--output docs/requirements.txt"
'uv export --no-hashes --all-extras --no-dev | grep -v "-e \\." > '
"docs/requirements.txt"
)


@task(clean, preflight, docs, todo, requirements)
@task(literalise, clean, preflight, docs, todo, requirements)
def build(ctx: Context):
"""
Build the project and runs dependency tasks, i.e. *docs*, *todo*, and
Build the project and runs dependency tasks, i.e., *docs*, *todo*, and
*preflight*.
Parameters
Expand All @@ -429,9 +441,7 @@ def build(ctx: Context):
"""

message_box("Building...")
if (
"modified: README.rst" in ctx.run("git status").stdout # pyright: ignore
):
if "modified: README.rst" in ctx.run("git status").stdout: # pyright: ignore
raise RuntimeError('Please commit your changes to the "README.rst" file!')

with open("README.rst") as readme_file:
Expand All @@ -456,7 +466,7 @@ def build(ctx: Context):
)
)

ctx.run("poetry build")
ctx.run("uv build")
ctx.run("git checkout -- README.rst")
ctx.run("twine check dist/*")

Expand All @@ -479,12 +489,14 @@ def virtualise(ctx: Context, tests: bool = True):
ctx.run(f"tar -xvf {PYPI_ARCHIVE_NAME}-{APPLICATION_VERSION}.tar.gz")
ctx.run(f"mv {PYPI_ARCHIVE_NAME}-{APPLICATION_VERSION} {unique_name}")
with ctx.cd(unique_name):
ctx.run("poetry install")
ctx.run("source $(poetry env info -p)/bin/activate")
ctx.run('python -c "import imageio;imageio.plugins.freeimage.download()"')
ctx.run("uv sync --all-extras --no-dev")
ctx.run(
'uv run python -c "import imageio;imageio.plugins.freeimage.download()"'
)
if tests:
ctx.run(
"poetry run pytest "
"source .venv/bin/activate && "
"uv run pytest "
"--doctest-modules "
f"--ignore={PYTHON_PACKAGE_NAME}/examples "
f"{PYTHON_PACKAGE_NAME}",
Expand Down

0 comments on commit f177fd2

Please sign in to comment.