diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index aa324dc..5221551 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -27,7 +27,7 @@ jobs: fail-fast: false matrix: os: ['ubuntu-latest', 'macos-latest', 'windows-latest'] - python-version: ['3.8', '3.9', '3.10', '3.11'] + python-version: ['3.8', '3.9', '3.10', '3.11', '3.12'] steps: - uses: actions/checkout@v4 @@ -44,10 +44,6 @@ jobs: tox-conda cache-environment: true - - name: Install core dependencies. - shell: bash -l {0} - run: mamba install -c conda-forge tox-conda coverage mamba - # Unit, integration, and end-to-end tests. - name: Run unit tests and doctests. diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index fef43a0..9de1e23 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -17,10 +17,6 @@ repos: - id: python-no-log-warn - id: python-use-type-annotations - id: text-unicode-replacement-char -- repo: https://github.com/asottile/setup-cfg-fmt - rev: v2.5.0 - hooks: - - id: setup-cfg-fmt - repo: https://github.com/astral-sh/ruff-pre-commit rev: v0.3.7 hooks: @@ -55,12 +51,6 @@ repos: types-setuptools ] pass_filenames: false -- repo: https://github.com/mgedmin/check-manifest - rev: "0.49" - hooks: - - id: check-manifest - args: [--no-build-isolation] - additional_dependencies: [setuptools-scm, wheel, toml] - repo: meta hooks: - id: check-hooks-apply diff --git a/CHANGES.md b/CHANGES.md index 19cba35..592d045 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -5,6 +5,10 @@ chronological order. Releases follow [semantic versioning](https://semver.org/) releases are available on [PyPI](https://pypi.org/project/pytask-r) and [Anaconda.org](https://anaconda.org/conda-forge/pytask-r). +## 0.4.1 - 2024-xx-xx + +- {pull}`46` modernizes the package. + ## 0.4.0 - 2023-10-08 - {pull}`42` makes the package compatible with pytask v0.4.0. diff --git a/pyproject.toml b/pyproject.toml index 060dd09..4e6fd96 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,9 +1,65 @@ +[project] +name = "pytask_r" +description = "Run R scripts with pytask." +classifiers = [ + "Development Status :: 4 - Beta", + "License :: OSI Approved :: MIT License", + "Operating System :: OS Independent", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3 :: Only", + "Programming Language :: R", +] +requires-python = ">=3.8" +dependencies = ["click", "pluggy>=1.0.0", "pytask>=0.4.0"] +dynamic = ["version"] + +[[project.authors]] +name = "Tobias Raabe" +email = "raabe@posteo.de" + +[project.readme] +file = "README.md" +content-type = "text/markdown" + +[project.license] +text = "MIT" + +[project.urls] +Homepage = "https://github.com/pytask-dev/pytask-r" +Changelog = "https://github.com/pytask-dev/pytask-r/blob/main/CHANGES.md" +Documentation = "https://github.com/pytask-dev/pytask-r" +Github = "https://github.com/pytask-dev/pytask-r" +Tracker = "https://github.com/pytask-dev/pytask-r/issues" + +[project.entry-points.pytask] +pytask_r = "pytask_r.plugin" + +[project.optional-dependencies] +test = ["pytask-parallel", "pytest", "pytest-cov", "pytest-xdist", "pyyaml"] + +[tool.rye] +managed = true + [build-system] -requires = ["setuptools>=45", "wheel", "setuptools_scm[toml]>=6.0"] -build-backend = "setuptools.build_meta" +requires = ["hatchling", "hatch-vcs"] +build-backend = "hatchling.build" + +[tool.hatch.build.hooks.vcs] +version-file = "src/pytask_r/_version.py" + +[tool.hatch.build.targets.sdist] +exclude = ["tests"] +only-packages = true + +[tool.hatch.build.targets.wheel] +exclude = ["tests"] +only-packages = true + +[tool.hatch.version] +source = "vcs" -[tool.setuptools_scm] -write_to = "src/pytask_r/_version.py" +[tool.hatch.metadata] +allow-direct-references = true [tool.mypy] files = ["src", "tests"] @@ -27,21 +83,16 @@ unsafe-fixes = true [tool.ruff.lint] extend-ignore = [ - "S101", # raise errors for asserts. - "B905", # strict parameter for zip that was implemented in py310. - "ANN101", # type annotating self - "ANN102", # type annotating cls - "FBT", # flake8-boolean-trap - "EM", # flake8-errmsg - "ANN401", # flake8-annotate typing.Any - "PD", # pandas-vet - "COM812", # Comply with ruff-format - "ISC001", # Comply with ruff-format + "ANN101", # type annotating self + "ANN102", # type annotating cls + "ANN401", + "COM812", # Comply with ruff-format + "ISC001", # Comply with ruff-format ] select = ["ALL"] [tool.ruff.lint.per-file-ignores] -"tests/*" = ["D", "ANN"] +"tests/*" = ["D", "ANN", "S101"] [tool.ruff.lint.pydocstyle] convention = "numpy" diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index d2ba86c..0000000 --- a/setup.cfg +++ /dev/null @@ -1,45 +0,0 @@ -[metadata] -name = pytask_r -description = Run R scripts with pytask. -long_description = file: README.md -long_description_content_type = text/markdown -url = https://github.com/pytask-dev/pytask-r -author = Tobias Raabe -author_email = raabe@posteo.de -license = MIT -license_files = LICENSE -platforms = any -classifiers = - Development Status :: 4 - Beta - License :: OSI Approved :: MIT License - Operating System :: OS Independent - Programming Language :: Python :: 3 - Programming Language :: Python :: 3 :: Only - Programming Language :: R -project_urls = - Changelog = https://github.com/pytask-dev/pytask-r/blob/main/CHANGES.md - Documentation = https://github.com/pytask-dev/pytask-r - Github = https://github.com/pytask-dev/pytask-r - Tracker = https://github.com/pytask-dev/pytask-r/issues - -[options] -packages = find: -install_requires = - click - pluggy>=1.0.0 - pytask>=0.4.0 -python_requires = >=3.8 -include_package_data = True -package_dir = =src -zip_safe = False - -[options.packages.find] -where = src - -[options.entry_points] -pytask = - pytask_r = pytask_r.plugin - -[check-manifest] -ignore = - src/pytask_r/_version.py diff --git a/src/pytask_r/execute.py b/src/pytask_r/execute.py index fabb9f9..dd80881 100644 --- a/src/pytask_r/execute.py +++ b/src/pytask_r/execute.py @@ -27,11 +27,11 @@ def pytask_execute_task_setup(task: PTask) -> None: ) raise RuntimeError(msg) - assert len(marks) == 1 + if len(marks) > 1: + msg = "Only one R marker is allowed per task." + raise ValueError(msg) - _, _, serializer, suffix = r(**marks[0].kwargs) - assert serializer - assert suffix + _, _, serializer, _ = r(**marks[0].kwargs) serialized_node: PythonNode = task.depends_on["_serialized"] # type: ignore[assignment] serialized_node.value.parent.mkdir(parents=True, exist_ok=True) # type: ignore[union-attr] diff --git a/tox.ini b/tox.ini index 1504f2f..1721656 100644 --- a/tox.ini +++ b/tox.ini @@ -2,26 +2,17 @@ envlist = pytest [testenv] +# Cannot use package = editable, because tox-conda does not support tox v4. usedevelop = true -[testenv:pytest] +[testenv:test] +extras = test conda_channels = conda-forge - conda-forge/label/pytask_rc - conda-forge/label/pytask_parallel_rc nodefaults conda_deps = - pytask >=0.4.0 - pytask-parallel >=0.4.0 - - # Optional dependencies. - pyyaml r-base >=4 r-jsonlite r-yaml - - pytest - pytest-cov - pytest-xdist commands = pytest {posargs}