From b42b3c6b72f08c683dc1f99eef062214c79f0c4a Mon Sep 17 00:00:00 2001 From: Tobias Raabe Date: Wed, 25 Oct 2023 23:24:50 +0200 Subject: [PATCH 1/3] Fix. --- environment.yml | 2 +- pyproject.toml | 166 ++++++++++++++++++++++++------------------------ tox.ini | 11 ---- 3 files changed, 84 insertions(+), 95 deletions(-) diff --git a/environment.yml b/environment.yml index 94355b23..c65e57e8 100644 --- a/environment.yml +++ b/environment.yml @@ -5,7 +5,7 @@ channels: - nodefaults dependencies: - - python >=3.8,<3.12 + - python >=3.8 - pip - setuptools_scm - toml diff --git a/pyproject.toml b/pyproject.toml index b8a827dc..ae7c0887 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -9,6 +9,89 @@ requires = [ [tool.setuptools_scm] write_to = "src/_pytask/_version.py" +[project] +name = "pytask" +description = "In its highest aspirations, pytask tries to be pytest as a build system." +requires-python = ">=3.8" +classifiers = [ + "Development Status :: 4 - Beta", + "Environment :: Console", + "Intended Audience :: Science/Research", + "License :: OSI Approved :: MIT License", + "Operating System :: MacOS :: MacOS X", + "Operating System :: Microsoft :: Windows", + "Operating System :: POSIX", + "Programming Language :: Python :: 3 :: Only", + "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", + "Topic :: Scientific/Engineering", + "Topic :: Software Development :: Build Tools", +] +dynamic = ["version"] +dependencies = [ + "attrs>=21.3", + "click", + "click-default-group", + "networkx>=2.4", + "optree>=0.9", + "packaging", + "pluggy>=1", + "rich", + "sqlalchemy>=1.4.36", + 'tomli>=1; python_version < "3.11"', + 'typing-extensions; python_version < "3.9"', +] + +[project.readme] +file = "README.md" +content-type = "text/markdown" + +[project.license] +text = "MIT" + +[[project.authors]] +name = "Tobias Raabe" +email = "raabe@posteo.de" + +[project.optional-dependencies] +docs = [ + "furo", + "ipython", + "myst-parser", + "nbsphinx", + "sphinx", + "sphinx-click", + "sphinx-copybutton", + "sphinx-design>=0.3", + "sphinx-toolbox", + "sphinxext-opengraph", +] +[project.urls] +Changelog = "https://pytask-dev.readthedocs.io/en/stable/changes.html" +Documentation = "https://pytask-dev.readthedocs.io/en/stable" +Github = "https://github.com/pytask-dev/pytask" +Homepage = "https://pytask-dev.readthedocs.io/en/stable" +Tracker = "https://github.com/pytask-dev/pytask/issues" + +[project.scripts] +pytask = "_pytask.cli:cli" + +[tool.setuptools] +include-package-data = true +zip-safe = false +platforms = ["unix", "linux", "osx", "win32"] +license-files = ["LICENSE"] + +[tool.setuptools.package-dir] +"" = "src" + +[tool.setuptools.packages.find] +where = ["src"] +namespaces = false + [tool.ruff] target-version = "py38" select = ["ALL"] @@ -103,88 +186,5 @@ ignore-words-list = "falsy, hist, ines, unparseable" [tool.refurb] python_version = "3.8" -[project] -name = "pytask" -description = "In its highest aspirations, pytask tries to be pytest as a build system." -requires-python = ">=3.8" -classifiers = [ - "Development Status :: 4 - Beta", - "Environment :: Console", - "Intended Audience :: Science/Research", - "License :: OSI Approved :: MIT License", - "Operating System :: MacOS :: MacOS X", - "Operating System :: Microsoft :: Windows", - "Operating System :: POSIX", - "Programming Language :: Python :: 3 :: Only", - "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", - "Topic :: Scientific/Engineering", - "Topic :: Software Development :: Build Tools", -] -dynamic = ["version"] -dependencies = [ - "attrs>=21.3", - "click", - "click-default-group", - "networkx>=2.4", - "optree>=0.9", - "packaging", - "pluggy>=1", - "rich", - "sqlalchemy>=1.4.36", - "tomli>=1", - "typing-extensions", -] - -[project.readme] -file = "README.md" -content-type = "text/markdown" - -[project.license] -text = "MIT" - -[[project.authors]] -name = "Tobias Raabe" -email = "raabe@posteo.de" - -[project.optional-dependencies] -docs = [ - "furo", - "ipython", - "myst-parser", - "nbsphinx", - "sphinx", - "sphinx-click", - "sphinx-copybutton", - "sphinx-design>=0.3", - "sphinx-toolbox", - "sphinxext-opengraph", -] -[project.urls] -Changelog = "https://pytask-dev.readthedocs.io/en/stable/changes.html" -Documentation = "https://pytask-dev.readthedocs.io/en/stable" -Github = "https://github.com/pytask-dev/pytask" -Homepage = "https://pytask-dev.readthedocs.io/en/stable" -Tracker = "https://github.com/pytask-dev/pytask/issues" - -[project.scripts] -pytask = "_pytask.cli:cli" - -[tool.setuptools] -include-package-data = true -zip-safe = false -platforms = ["unix", "linux", "osx", "win32"] -license-files = ["LICENSE"] - [tool.check-manifest] ignore = ["src/_pytask/_version.py"] - -[tool.setuptools.package-dir] -"" = "src" - -[tool.setuptools.packages.find] -where = ["src"] -namespaces = false diff --git a/tox.ini b/tox.ini index 302b570a..d024bd02 100644 --- a/tox.ini +++ b/tox.ini @@ -16,17 +16,6 @@ deps = pytest-xdist coverage - # Package dependencies - attrs >=21.3.0 - click - click-default-group - networkx >=2.4 - pluggy - sqlalchemy >=1.4.36 - optree >=0.9 - rich - tomli >=1.0.0 - # Optional and test dependencies pexpect linux, macos: pygraphviz From a4846aa8b5f9d7a39e49856978f2bfb7190aa744 Mon Sep 17 00:00:00 2001 From: Tobias Raabe Date: Wed, 25 Oct 2023 23:31:28 +0200 Subject: [PATCH 2/3] Fix tomllib. --- src/_pytask/config_utils.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/_pytask/config_utils.py b/src/_pytask/config_utils.py index 8f3b040c..dbba3f18 100644 --- a/src/_pytask/config_utils.py +++ b/src/_pytask/config_utils.py @@ -2,13 +2,18 @@ from __future__ import annotations import os +import sys from pathlib import Path from typing import Any import click -import tomli from _pytask.shared import parse_paths +if sys.version_info >= (3, 11): + import tomllib +else: + import tomli as tomllib + def set_defaults_from_config( context: click.Context, param: click.Parameter, value: Any # noqa: ARG001 @@ -85,7 +90,7 @@ def _find_project_root_and_config(paths: list[Path] | None) -> tuple[Path, Path if path.exists(): try: read_config(path) - except (tomli.TOMLDecodeError, OSError) as e: + except (tomllib.TOMLDecodeError, OSError) as e: raise click.FileError( filename=str(path), hint=f"Error reading {path}:\n{e}" ) from None @@ -114,7 +119,7 @@ def read_config( Raises ------ - tomli.TOMLDecodeError + tomllib.TOMLDecodeError Raised if ``*.toml`` could not be read. KeyError Raised if the specified sections do not exist. @@ -122,7 +127,7 @@ def read_config( """ sections_ = sections.split(".") - config = tomli.loads(path.read_text(encoding="utf-8")) + config = tomllib.loads(path.read_text(encoding="utf-8")) for section in sections_: config = config[section] From 05a1ffb339f76c981acca36efe6f98ff422eaa95 Mon Sep 17 00:00:00 2001 From: Tobias Raabe Date: Wed, 25 Oct 2023 23:40:22 +0200 Subject: [PATCH 3/3] improve annotated. --- src/_pytask/collect_utils.py | 6 +++++- src/_pytask/task_utils.py | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/_pytask/collect_utils.py b/src/_pytask/collect_utils.py index b6c91d1b..4f7ca196 100644 --- a/src/_pytask/collect_utils.py +++ b/src/_pytask/collect_utils.py @@ -2,6 +2,7 @@ from __future__ import annotations import itertools +import sys import uuid import warnings from pathlib import Path @@ -29,9 +30,12 @@ from _pytask.typing import ProductType from attrs import define from attrs import field -from typing_extensions import Annotated from typing_extensions import get_origin +if sys.version_info >= (3, 9): + from typing import Annotated +else: + from typing_extensions import Annotated if TYPE_CHECKING: from _pytask.session import Session diff --git a/src/_pytask/task_utils.py b/src/_pytask/task_utils.py index 5e80a187..4ae9d333 100644 --- a/src/_pytask/task_utils.py +++ b/src/_pytask/task_utils.py @@ -74,7 +74,7 @@ def task( .. code-block:: python - from typing_extensions import Annotated + from typing import Annotated from pytask import task @task