From 889b6784272e35fb5e383bebeeaa87cd33323d87 Mon Sep 17 00:00:00 2001 From: Tobias Raabe Date: Fri, 3 May 2024 19:43:01 +0200 Subject: [PATCH 01/19] Add rye. --- README.md | 67 +++++++--------------------------------- hooks/pre_gen_project.py | 2 +- pyproject.toml | 58 ++++++++++++++++++---------------- tox.ini | 27 ++++++++-------- 4 files changed, 58 insertions(+), 96 deletions(-) diff --git a/README.md b/README.md index 2143705..8327f00 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ [![image](https://img.shields.io/github/actions/workflow/status/pytask-dev/cookiecutter-pytask-project/main.yml?branch=main)](https://github.com/pytask-dev/cookiecutter-pytask-project/actions?query=branch%3Amain) [![image](https://codecov.io/gh/pytask-dev/cookiecutter-pytask-project/branch/main/graph/badge.svg)](https://codecov.io/gh/pytask-dev/cookiecutter-pytask-project) [![pre-commit.ci status](https://results.pre-commit.ci/badge/github/pytask-dev/cookiecutter-pytask-project/main.svg)](https://results.pre-commit.ci/latest/github/pytask-dev/cookiecutter-pytask-project/main) -[![image](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black) +[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff) This repository contains a minimal cookiecutter template for a project with [pytask](https://github.com/pytask-dev/pytask). @@ -15,69 +15,24 @@ This repository contains a minimal cookiecutter template for a project with First, install cookiecutter. ```console -$ pip install cookiecutter - -$ conda install -c conda-forge cookiecutter +pip install cookiecutter +conda install -c conda-forge cookiecutter ``` Then, set up the template with ```console -$ cookiecutter https://github.com/pytask-dev/cookiecutter-pytask-project +cookiecutter https://github.com/pytask-dev/cookiecutter-pytask-project ``` ## Documentation -If you are new to pytask, just follow the -[tutorials](https://pytask-dev.readthedocs.io/en/stable/tutorials/index.html) which will -help you with your first steps like how to write the first task. - -If you are already familiar with pytask, the -[how-to guides](https://pytask-dev.readthedocs.io/en/stable/how_to_guides/index.html) -offer more in-depth guidance on complex projects. - -In general, you will find most guidance in the -[documentation](https://pytask-dev.readthedocs.io/en/stable/index.html) and some advice -in the FAQ below. - -## FAQ - -Q: Why are the source files nested in `src/`? - -A: This is called the src layout and the advantages are discussed in this -[article by Hynek Schlawack](https://hynek.me/articles/testing-packaging/). - -Although the article discusses the src layout in terms of Python packages, it is also -beneficial to structure a project the same way. Next to the reasons discussed there, it -is possible to use a single Python environment for multiple projects without messing -with your PYTHONPATH (via `pip install -e .` or `conda develop .`) each time and still -import modules. +You find the documentation at with +a +[quickstart guide](https://cookiecutter-pytask-project.readthedocs.io/en/latest/quickstart.html). -Q: My project is a Python package, but it does not seem to have a version. Where is it? +## Changes -A: The cookiecutter uses [setuptools_scm](https://github.com/pypa/setuptools_scm/) to -manage the version number. When you install your created project as a Python package -with `pip install -e .`, setuptools_scm tries to infer the version number from the tags -created on the repo. - -For example, if you have switched to a commit associated with the tag `v0.2.0`, -setuptools_scm will create a `src//_version.py` with a variable containing -`version = '0.2.0'` which you can use in your `src//__init__.py`. If you -are one commit ahead of the tag, you version will be something like `0.2.0.dev1+...` -indicating you are one commit ahead of the tag `v0.2.0`. - -If you want to switch to the tradition setup, replace the following code in your -`pyproject.toml` - -```toml -[build-system] -requires = ["setuptools>=45", "wheel", "setuptools_scm[toml]>=6.0"] -``` - -with - -```toml -[build-system] -requires = ["setuptools"] -build-backend = "setuptools.build_meta" -``` +Consult the +[release notes](https://cookiecutter-pytask-project.readthedocs.io/en/latest/changes.html) +to find out about what is new. diff --git a/hooks/pre_gen_project.py b/hooks/pre_gen_project.py index 139ff03..5809730 100644 --- a/hooks/pre_gen_project.py +++ b/hooks/pre_gen_project.py @@ -4,7 +4,7 @@ MODULE_REGEX = r"^[_a-zA-Z][_a-zA-Z0-9]*$" ENVIRON_REGEX = r"^[-_a-zA-Z0-9]*$" -PYTHONVERSION_REGEX = r"^(3\.(1[0-9]|[7-9])(\.[0-9]{1,2})?)$" +PYTHONVERSION_REGEX = r"^(3\.(1[0-9]|[8-9])(\.[0-9]{1,2})?)$" PYTHONVERSION_MIN = "3.8" EXCEPTION_MSG_MODULE_NAME = """ diff --git a/pyproject.toml b/pyproject.toml index a450727..94ed373 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,16 +1,21 @@ -[build-system] -requires = ["setuptools", "wheel", "setuptools_scm[toml]"] -build-backend = "setuptools.build_meta" - -[tool.setuptools_scm] -write_to = "version.py" - [project] name = "cookiecutter_pytask_project" +version = "1.7.0" description = "A minimal cookiecutter template for a project with pytask." -classifiers = [ "Development Status :: 3 - Alpha", "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", "Programming Language :: Python :: 3 :: Only", "Topic :: Scientific/Engineering", "Topic :: Software Development :: Build Tools",] +classifiers = [ + "Development Status :: 3 - Alpha", + "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", + "Programming Language :: Python :: 3 :: Only", + "Topic :: Scientific/Engineering", + "Topic :: Software Development :: Build Tools", +] requires-python = ">=3.8" -dynamic = ["version"] dependencies = ["cookiecutter"] [[project.authors]] @@ -19,16 +24,16 @@ 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", + "furo", + "ipython", + "myst-parser", + "nbsphinx", + "sphinx", + "sphinx-click", + "sphinx-copybutton", + "sphinx-design>=0.3", + "sphinx-toolbox", + "sphinxext-opengraph", ] test = ["pytest", "pytest-cookies", "pytest-cov"] @@ -46,10 +51,12 @@ Documentation = "https://cookiecutter-pytask-project.readthedocs.io/en/latest" Github = "https://github.com/pytask-dev/cookiecutter-pytask-project" Tracker = "https://github.com/pytask-dev/cookiecutter-pytask-project/issues" -[tool.setuptools] -platforms = [ "unix", "linux", "osx", "cygwin", "win32",] -license-files = [ "LICENSE"] -include-package-data = false +[tool.rye] +managed = true +virtual = true +dev-dependencies = [ + "tox-uv>=1.8.2", +] [tool.mypy] files = ["hooks", "tests"] @@ -74,9 +81,8 @@ unsafe-fixes = true [tool.ruff.lint] extend-ignore = [ - # Others. - "COM812", # Comply with ruff-format. - "ISC001", # Comply with ruff-format. + "COM812", # Comply with ruff-format. + "ISC001", # Comply with ruff-format. ] select = ["ALL"] diff --git a/tox.ini b/tox.ini index dd200b0..49f3e59 100644 --- a/tox.ini +++ b/tox.ini @@ -1,20 +1,21 @@ [tox] -envlist = test, docs +requires = tox>=4 +envlist = docs, test [testenv] -usedevelop = true passenv = CI - -[testenv:test] -allowlist_externals = pytest -extras = test - -commands = - pytest {posargs} +package = editable [testenv:docs] -extras = docs -changedir = docs/source +extras = docs, test commands = - sphinx-build -T -b html -d {envtmpdir}/doctrees . {envtmpdir}/html - - sphinx-build -T -b linkcheck -d {envtmpdir}/doctrees . {envtmpdir}/linkcheck + sphinx-build -n -T -b html -d {envtmpdir}/doctrees docs/source docs/build/html + - sphinx-build -n -T -b doctest -d {envtmpdir}/doctrees docs/source docs/build/html + +[testenv:typing] +extras = typing +commands = mypy + +[testenv:test] +extras = test +commands = pytest {posargs} From 914dbc5148a973e9ae9e0891016e8395e12266ac Mon Sep 17 00:00:00 2001 From: Tobias Raabe Date: Fri, 3 May 2024 19:45:03 +0200 Subject: [PATCH 02/19] Use tox-uv. --- .github/workflows/main.yml | 2 +- .gitignore | 5 ++- .python-version | 1 + requirements-dev.lock | 80 ++++++++++++++++++++++++++++++++++++++ requirements.lock | 52 +++++++++++++++++++++++++ 5 files changed, 137 insertions(+), 3 deletions(-) create mode 100644 .python-version create mode 100644 requirements-dev.lock create mode 100644 requirements.lock diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 4eaae9f..a890c0d 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -33,7 +33,7 @@ jobs: python-version: ${{ matrix.python-version }} cache: pip allow-prereleases: true - - run: pip install tox + - run: pip install tox-uv - name: Run tests. shell: bash -l {0} diff --git a/.gitignore b/.gitignore index 8e3b795..04dcee8 100644 --- a/.gitignore +++ b/.gitignore @@ -144,9 +144,10 @@ _generated *.egg-info .eggs -.pytask.sqlite3 +.pytask build dist -version.py +.ruff_cache +.mypy_cache diff --git a/.python-version b/.python-version new file mode 100644 index 0000000..8531a3b --- /dev/null +++ b/.python-version @@ -0,0 +1 @@ +3.12.2 diff --git a/requirements-dev.lock b/requirements-dev.lock new file mode 100644 index 0000000..e848340 --- /dev/null +++ b/requirements-dev.lock @@ -0,0 +1,80 @@ +# generated by rye +# use `rye lock` or `rye sync` to update this lockfile +# +# last locked with the following flags: +# pre: false +# features: [] +# all-features: true +# with-sources: false + +arrow==1.3.0 + # via cookiecutter +binaryornot==0.4.4 + # via cookiecutter +cachetools==5.3.3 + # via tox +certifi==2024.2.2 + # via requests +chardet==5.2.0 + # via binaryornot + # via tox +charset-normalizer==3.3.2 + # via requests +click==8.1.7 + # via cookiecutter +colorama==0.4.6 + # via tox +cookiecutter==2.6.0 +distlib==0.3.8 + # via virtualenv +filelock==3.14.0 + # via tox + # via virtualenv +idna==3.7 + # via requests +jinja2==3.1.3 + # via cookiecutter +markdown-it-py==3.0.0 + # via rich +markupsafe==2.1.5 + # via jinja2 +mdurl==0.1.2 + # via markdown-it-py +packaging==24.0 + # via pyproject-api + # via tox + # via tox-uv +platformdirs==4.2.1 + # via tox + # via virtualenv +pluggy==1.5.0 + # via tox +pygments==2.17.2 + # via rich +pyproject-api==1.6.1 + # via tox +python-dateutil==2.9.0.post0 + # via arrow +python-slugify==8.0.4 + # via cookiecutter +pyyaml==6.0.1 + # via cookiecutter +requests==2.31.0 + # via cookiecutter +rich==13.7.1 + # via cookiecutter +six==1.16.0 + # via python-dateutil +text-unidecode==1.3 + # via python-slugify +tox==4.15.0 + # via tox-uv +tox-uv==1.8.2 +types-python-dateutil==2.9.0.20240316 + # via arrow +urllib3==2.2.1 + # via requests +uv==0.1.39 + # via tox-uv +virtualenv==20.26.1 + # via tox diff --git a/requirements.lock b/requirements.lock new file mode 100644 index 0000000..c7f16f0 --- /dev/null +++ b/requirements.lock @@ -0,0 +1,52 @@ +# generated by rye +# use `rye lock` or `rye sync` to update this lockfile +# +# last locked with the following flags: +# pre: false +# features: [] +# all-features: true +# with-sources: false + +arrow==1.3.0 + # via cookiecutter +binaryornot==0.4.4 + # via cookiecutter +certifi==2024.2.2 + # via requests +chardet==5.2.0 + # via binaryornot +charset-normalizer==3.3.2 + # via requests +click==8.1.7 + # via cookiecutter +cookiecutter==2.6.0 +idna==3.7 + # via requests +jinja2==3.1.3 + # via cookiecutter +markdown-it-py==3.0.0 + # via rich +markupsafe==2.1.5 + # via jinja2 +mdurl==0.1.2 + # via markdown-it-py +pygments==2.17.2 + # via rich +python-dateutil==2.9.0.post0 + # via arrow +python-slugify==8.0.4 + # via cookiecutter +pyyaml==6.0.1 + # via cookiecutter +requests==2.31.0 + # via cookiecutter +rich==13.7.1 + # via cookiecutter +six==1.16.0 + # via python-dateutil +text-unidecode==1.3 + # via python-slugify +types-python-dateutil==2.9.0.20240316 + # via arrow +urllib3==2.2.1 + # via requests From 6b78cb351fc3cf6633fddbd0c6ddc57781d58a23 Mon Sep 17 00:00:00 2001 From: Tobias Raabe Date: Fri, 3 May 2024 20:13:03 +0200 Subject: [PATCH 03/19] Fix. --- .github/workflows/main.yml | 5 +++ {{cookiecutter.project_slug}}/README.md | 10 ++--- {{cookiecutter.project_slug}}/dependabot.yml | 12 ------ {{cookiecutter.project_slug}}/pyproject.toml | 45 +++++++------------- 4 files changed, 24 insertions(+), 48 deletions(-) delete mode 100644 {{cookiecutter.project_slug}}/dependabot.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index a890c0d..64e6270 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -33,6 +33,11 @@ jobs: python-version: ${{ matrix.python-version }} cache: pip allow-prereleases: true + - uses: prefix-dev/setup-pixi@v0.6.0 + with: + pixi-version: v0.20.1 + cache: true + - run: pip install tox-uv - name: Run tests. diff --git a/{{cookiecutter.project_slug}}/README.md b/{{cookiecutter.project_slug}}/README.md index bf38756..5e0e5a1 100644 --- a/{{cookiecutter.project_slug}}/README.md +++ b/{{cookiecutter.project_slug}}/README.md @@ -17,18 +17,16 @@ cookiecutter.github_username }}/{{ cookiecutter.project_slug cookiecutter.github_username }}/{{ cookiecutter.project_slug }}/main) [![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff) -## Usage +## Installation -To get started, create the environment with +To work with the project, you should have [pixi](https://pixi.sh/latest/) installed. -```console -$ mamba env create -``` +## Usage To build the project, type ```console -$ pytask +pixi run pytask ``` ## Credits diff --git a/{{cookiecutter.project_slug}}/dependabot.yml b/{{cookiecutter.project_slug}}/dependabot.yml deleted file mode 100644 index fbb58d4..0000000 --- a/{{cookiecutter.project_slug}}/dependabot.yml +++ /dev/null @@ -1,12 +0,0 @@ -version: 2 - -updates: - - package-ecosystem: "github-actions" - directory: "/" - schedule: - interval: "weekly" - - groups: - github-actions: - patterns: - - "*" diff --git a/{{cookiecutter.project_slug}}/pyproject.toml b/{{cookiecutter.project_slug}}/pyproject.toml index f06690c..da9726f 100644 --- a/{{cookiecutter.project_slug}}/pyproject.toml +++ b/{{cookiecutter.project_slug}}/pyproject.toml @@ -1,23 +1,21 @@ [build-system] -requires = ["setuptools>=45", "wheel", "setuptools_scm[toml]>=6.0"] - -[tool.setuptools_scm] -write_to = "src/{{ cookiecutter.project_slug }}/_version.py" +requires = ["hatchling"] +build-backend = "hatchling.build" [project] name = "{{ cookiecutter.project_slug }}" +version = "0.1.0" description = "{{ cookiecutter.project_description }}" requires-python = ">=3.8" classifiers = [ - "Intended Audience :: Science/Research", - "License :: OSI Approved :: {{ cookiecutter.open_source_license }} License", - "Operating System :: MacOS :: MacOS X", - "Operating System :: Microsoft :: Windows", - "Operating System :: POSIX", - "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3 :: Only", + "Intended Audience :: Science/Research", + "License :: OSI Approved :: {{ cookiecutter.open_source_license }} License", + "Operating System :: MacOS :: MacOS X", + "Operating System :: Microsoft :: Windows", + "Operating System :: POSIX", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3 :: Only", ] -dynamic = ["version"] dependencies = ["pytask"] [project.readme] @@ -43,7 +41,7 @@ docs = [ "sphinx-toolbox", "sphinxext-opengraph", ] -test = [] +test = ["pytest", "pytest-cov", "pytest-xdist"] [project.urls] Changelog = "https://github.com/{{ cookiecutter.github_username }}/{{ cookiecutter.project_slug }}" @@ -51,19 +49,6 @@ Documentation = "https://github.com/{{ cookiecutter.github_username }}/{{ cookie Github = "https://github.com/{{ cookiecutter.github_username }}/{{ cookiecutter.project_slug }}" Tracker = "https://github.com/{{ cookiecutter.github_username }}/{{ cookiecutter.project_slug }}/issues" -[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 - {% if cookiecutter.add_mypy == "yes" %}[tool.mypy] files = ["src", "tests"] check_untyped_defs = true @@ -75,10 +60,10 @@ warn_redundant_casts = true warn_unused_ignores = true [[tool.mypy.overrides]] +ignore_errors = true module = "tests.*" disallow_untyped_defs = false -ignore_errors = true{% endif %} - +{% endif %} [tool.pytask.ini_options] paths = ["src/{{ cookiecutter.project_slug }}"] @@ -89,8 +74,8 @@ unsafe-fixes = true [tool.ruff.lint] extend-ignore = [ - "COM812", # Comply with ruff-format. - "ISC001", # Comply with ruff-format. + "COM812", # Comply with ruff-format. + "ISC001", # Comply with ruff-format. ] select = ["ALL"] From f68297a77d4ca3aae3398d2136f06d316a040929 Mon Sep 17 00:00:00 2001 From: Tobias Raabe Date: Fri, 3 May 2024 20:30:39 +0200 Subject: [PATCH 04/19] fix. --- environment.yml | 38 ------------------- .../.github/workflows/main.yml | 17 ++------- {{cookiecutter.project_slug}}/environment.yml | 38 ------------------- {{cookiecutter.project_slug}}/pyproject.toml | 23 +++++++++++ {{cookiecutter.project_slug}}/tox.ini | 25 ------------ 5 files changed, 27 insertions(+), 114 deletions(-) delete mode 100644 environment.yml delete mode 100644 {{cookiecutter.project_slug}}/environment.yml delete mode 100644 {{cookiecutter.project_slug}}/tox.ini diff --git a/environment.yml b/environment.yml deleted file mode 100644 index 6090cbf..0000000 --- a/environment.yml +++ /dev/null @@ -1,38 +0,0 @@ -name: cp - -channels: - - conda-forge - - nodefaults - -dependencies: - - python >=3.8 - - pip >=21.1 - - setuptools_scm - - toml - - # Package dependencies - - cookiecutter >=2.1.0 - - pytask >=0.2 - - # Misc - - black - - ipython - - mypy - - pre-commit - - pytest - # - pytest-cookies>=0.6.2 - - pytest-cov - - pytest-xdist - - tox-conda - - # Documentation - - furo - - myst-parser - - nbsphinx - - sphinx - - sphinx-copybutton - - sphinx-panels - - - pip: - - sphinxext-opengraph - - git+https://github.com/andriihomiak/pytest-cookies.git@fix/quotes_in_user_config diff --git a/{{cookiecutter.project_slug}}/.github/workflows/main.yml b/{{cookiecutter.project_slug}}/.github/workflows/main.yml index f61c9b2..381a926 100644 --- a/{{cookiecutter.project_slug}}/.github/workflows/main.yml +++ b/{{cookiecutter.project_slug}}/.github/workflows/main.yml @@ -5,9 +5,6 @@ concurrency: group: ${{ github.head_ref || github.run_id }} cancel-in-progress: true -env: - CONDA_EXE: mamba - on: push: branches: @@ -31,20 +28,14 @@ jobs: steps: - uses: actions/checkout@v4 - - uses: mamba-org/provision-with-micromamba@main + - uses: prefix-dev/setup-pixi@v0.6.0 with: - environment-file: false - environment-name: gha-testing - channels: conda-forge,nodefaults - extra-specs: | - python=${{ matrix.python-version }} - mamba - tox-conda - cache-downloads: true + pixi-version: v0.20.1 + cache: true - name: Run tests and doctests. shell: bash -l {0} - run: tox -e pytest + run: pixi run test - name: Upload coverage report uses: codecov/codecov-action@v4 diff --git a/{{cookiecutter.project_slug}}/environment.yml b/{{cookiecutter.project_slug}}/environment.yml deleted file mode 100644 index e135210..0000000 --- a/{{cookiecutter.project_slug}}/environment.yml +++ /dev/null @@ -1,38 +0,0 @@ -name: {{ cookiecutter.conda_environment_name }} - -channels: - - conda-forge - - nodefaults - -dependencies: - - python =={{ cookiecutter.python_version }} - - pip >=21.1 - - setuptools_scm - - toml - - # Reproducibility - - conda-lock - - # Package dependencies - - pytask >=0.4 - - # Misc - - black - - ipython - - pre-commit - - pytest - - pytest-cov - - pytest-xdist - - tox-conda - - # Documentation - - furo - - myst-parser - - nbsphinx - - sphinx - - sphinx-copybutton - - sphinx-panels - - - pip: - - sphinxext-opengraph - - -e . diff --git a/{{cookiecutter.project_slug}}/pyproject.toml b/{{cookiecutter.project_slug}}/pyproject.toml index da9726f..f9946b9 100644 --- a/{{cookiecutter.project_slug}}/pyproject.toml +++ b/{{cookiecutter.project_slug}}/pyproject.toml @@ -93,3 +93,26 @@ convention = "numpy" addopts = ["--doctest-modules"] testpaths = ["src", "tests"] norecursedirs = [".idea", ".tox"] + +[tool.pixi.project] +channels = ["conda-forge"] +platforms = ["linux-64"] + +[tool.pixi.dependencies] +pytask = ">=0.4.7,<0.5" + +[tool.pixi.pypi-dependencies] +reproducible_research_template = { path = ".", editable = true } + +[tool.pixi.environments] +default = { solve-group = "default" } +docs = { features = ["docs"], solve-group = "default" } +test = { features = ["test"], solve-group = "default" } + +[tool.pixi.tasks] + +[tool.pixi.features.test.tasks] +test = "pytest --cov src --cov tests" + +[tool.pixi.features.docs.tasks] +docs = "sphinx-build -b html docs/source docs/build" diff --git a/{{cookiecutter.project_slug}}/tox.ini b/{{cookiecutter.project_slug}}/tox.ini deleted file mode 100644 index 76e568a..0000000 --- a/{{cookiecutter.project_slug}}/tox.ini +++ /dev/null @@ -1,25 +0,0 @@ -[tox] -requires = tox>=4 -envlist = docs, test - -[testenv] -package = editable - -[testenv:test] -conda_channels = - conda-forge - nodefaults -conda_deps = - # pytest - pytest - pytest-cov - pytest-xdist - -commands = - pytest {posargs} - -[testenv:docs] -extras = docs, test -commands = - - sphinx-build -n -T -b html -d {envtmpdir}/doctrees docs/source docs/build/html - - sphinx-build -n -T -b doctest -d {envtmpdir}/doctrees docs/source docs/build/html From 68cd1f8c53062ec2fd0f522dd366776fc3c3f3fe Mon Sep 17 00:00:00 2001 From: Tobias Raabe Date: Fri, 3 May 2024 20:34:30 +0200 Subject: [PATCH 05/19] fix: --- .github/workflows/main.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 64e6270..fd53f1d 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -37,6 +37,7 @@ jobs: with: pixi-version: v0.20.1 cache: true + run-install: false - run: pip install tox-uv From a6bce9d833a85e9482d2bdf207b9226dc413d04a Mon Sep 17 00:00:00 2001 From: Tobias Raabe Date: Fri, 3 May 2024 20:35:21 +0200 Subject: [PATCH 06/19] fix. --- .github/workflows/main.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index fd53f1d..1bdda00 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -36,7 +36,6 @@ jobs: - uses: prefix-dev/setup-pixi@v0.6.0 with: pixi-version: v0.20.1 - cache: true run-install: false - run: pip install tox-uv From 3902fec9098d65381e7df0b3d3ba3ee360c49f23 Mon Sep 17 00:00:00 2001 From: Tobias Raabe Date: Fri, 3 May 2024 20:40:02 +0200 Subject: [PATCH 07/19] test with pixi. --- tests/test_cookie.py | 25 ++++++++----------------- 1 file changed, 8 insertions(+), 17 deletions(-) diff --git a/tests/test_cookie.py b/tests/test_cookie.py index 79aa5ce..0e71f8c 100644 --- a/tests/test_cookie.py +++ b/tests/test_cookie.py @@ -112,35 +112,26 @@ def test_check_conda_environment_creation_and_run_all_checks(cookies): check=True, ) - # Check linting, but not on the first try since formatters fix stuff. + # Install pre-commit. subprocess.run( - ("conda", "run", "-n", "__test__", "pre-commit", "run", "--all-files"), - cwd=result.project_path, - check=False, + ("pixi", "install", "pre-commit"), cwd=result.project_path, check=True ) + # Check linting, but not on the first try since formatters fix stuff. subprocess.run( - ("conda", "run", "-n", "__test__", "pre-commit", "run", "--all-files"), + ("pixi", "run", "pre-commit", "--all-files"), cwd=result.project_path, - check=True, + check=False, ) - - # Install package. subprocess.run( - ("conda", "run", "-n", "__test__", "pip", "install", "-e", "."), + ("pixi", "run", "pre-commit", "--all-files"), cwd=result.project_path, check=True, ) # Run tests. - subprocess.run( - ("conda", "run", "-n", "__test__", "pytest"), - cwd=result.project_path, - check=True, - ) + subprocess.run(("pixi", "run", "test"), cwd=result.project_path, check=True) # Test building documentation subprocess.run( - ("conda", "run", "-n", "__test__", "make", "html"), - cwd=result.project_path / "docs", - check=True, + ("pixi", "run", "docs"), cwd=result.project_path, check=True ) From 199a385adf274b7919fe54a34dc785c30a58d146 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 3 May 2024 18:40:12 +0000 Subject: [PATCH 08/19] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- tests/test_cookie.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tests/test_cookie.py b/tests/test_cookie.py index 0e71f8c..a50ca17 100644 --- a/tests/test_cookie.py +++ b/tests/test_cookie.py @@ -132,6 +132,4 @@ def test_check_conda_environment_creation_and_run_all_checks(cookies): subprocess.run(("pixi", "run", "test"), cwd=result.project_path, check=True) # Test building documentation - subprocess.run( - ("pixi", "run", "docs"), cwd=result.project_path, check=True - ) + subprocess.run(("pixi", "run", "docs"), cwd=result.project_path, check=True) From 2c5841806a3133ec00a002d5cfbb23cb64434f47 Mon Sep 17 00:00:00 2001 From: Tobias Raabe Date: Fri, 3 May 2024 20:47:24 +0200 Subject: [PATCH 09/19] Remove conda leftovers. --- README.md | 4 +-- cookiecutter.json | 2 -- docs/source/faq.md | 41 --------------------------- docs/source/index.md | 59 +++++++++++++++++++++++++++++---------- hooks/post_gen_project.py | 50 --------------------------------- hooks/pre_gen_project.py | 7 ----- tests/test_cookie.py | 8 ++---- 7 files changed, 49 insertions(+), 122 deletions(-) delete mode 100644 docs/source/faq.md diff --git a/README.md b/README.md index 8327f00..3c8777b 100644 --- a/README.md +++ b/README.md @@ -27,9 +27,7 @@ cookiecutter https://github.com/pytask-dev/cookiecutter-pytask-project ## Documentation -You find the documentation at with -a -[quickstart guide](https://cookiecutter-pytask-project.readthedocs.io/en/latest/quickstart.html). +You find the documentation at . ## Changes diff --git a/cookiecutter.json b/cookiecutter.json index 761bb8e..364b088 100644 --- a/cookiecutter.json +++ b/cookiecutter.json @@ -20,7 +20,5 @@ "Not open source" ], "make_initial_commit": ["no", "yes"], - "conda_environment_name": "{{ cookiecutter.project_slug }}", - "create_conda_environment_at_finish": ["no", "yes"], "_copy_without_render": [".github/workflows/main.yml"] } diff --git a/docs/source/faq.md b/docs/source/faq.md deleted file mode 100644 index 58d8eb2..0000000 --- a/docs/source/faq.md +++ /dev/null @@ -1,41 +0,0 @@ -# FAQ - -Q: Why are the source files nested in `src/`? - -A: This is called the src layout and the advantages are discussed in this -[article by Hynek Schlawack](https://hynek.me/articles/testing-packaging/). - -Although the article discusses the src layout in terms of Python packages, it is also -beneficial to structure a project the same way. Next to the reasons discussed there, it -is possible to use a single Python environment for multiple projects without messing -with your PYTHONPATH (via `pip install -e .` or `conda develop .`) each time and still -import modules. - -Q: My project is a Python package, but it does not seem to have a version. Where is it? - -A: The cookiecutter uses [setuptools_scm](https://github.com/pypa/setuptools_scm/) to -manage the version number. When you install your created project as a Python package -with `pip install -e .`, setuptools_scm tries to infer the version number from the tags -created on the repo. - -For example, if you have switched to a commit associated with the tag `v0.2.0`, -setuptools_scm will create a `src//_version.py` with a variable containing -`version = '0.2.0'` which you can use in your `src//__init__.py`. If you -are one commit ahead of the tag, you version will be something like `0.2.0.dev1+...` -indicating you are one commit ahead of the tag `v0.2.0`. - -If you want to switch to the tradition setup, replace the following code in your -`pyproject.toml` - -```toml -[build-system] -requires = ["setuptools>=45", "wheel", "setuptools_scm[toml]>=6.0"] -``` - -with - -```toml -[build-system] -requires = ["setuptools"] -build-backend = "setuptools.build_meta" -``` diff --git a/docs/source/index.md b/docs/source/index.md index 0093590..4863e05 100644 --- a/docs/source/index.md +++ b/docs/source/index.md @@ -15,36 +15,67 @@ This repository contains a minimal cookiecutter template for a project with First, install cookiecutter. ```console -$ pip install cookiecutter +pip install cookiecutter -$ conda install -c conda-forge cookiecutter +conda install -c conda-forge cookiecutter ``` Then, set up the template with ```console -$ cookiecutter https://github.com/pytask-dev/cookiecutter-pytask-project +cookiecutter https://github.com/pytask-dev/cookiecutter-pytask-project ``` -## Documentation +## Features -If you are new to pytask, just follow the -[tutorials](https://pytask-dev.readthedocs.io/en/stable/tutorials/index.html) which will -help you with your first steps like how to write the first task. +TODO!!! -If you are already familiar with pytask, the -[how-to guides](https://pytask-dev.readthedocs.io/en/stable/how_to_guides/index.html) -offer more in-depth guidance on complex projects. +## FAQ -In general, you will find most guidance in the -[documentation](https://pytask-dev.readthedocs.io/en/stable/index.html) and some advice -in the FAQ below. +Q: Why are the source files nested in `src/`? + +A: This is called the src layout and the advantages are discussed in this +[article by Hynek Schlawack](https://hynek.me/articles/testing-packaging/). + +Although the article discusses the src layout in terms of Python packages, it is also +beneficial to structure a project the same way. Next to the reasons discussed there, it +is possible to use a single Python environment for multiple projects without messing +with your PYTHONPATH (via `pip install -e .` or `conda develop .`) each time and still +import modules. + +Q: My project is a Python package, but it does not seem to have a version. Where is it? + +A: The cookiecutter uses [setuptools_scm](https://github.com/pypa/setuptools_scm/) to +manage the version number. When you install your created project as a Python package +with `pip install -e .`, setuptools_scm tries to infer the version number from the tags +created on the repo. + +For example, if you have switched to a commit associated with the tag `v0.2.0`, +setuptools_scm will create a `src//_version.py` with a variable containing +`version = '0.2.0'` which you can use in your `src//__init__.py`. If you +are one commit ahead of the tag, you version will be something like `0.2.0.dev1+...` +indicating you are one commit ahead of the tag `v0.2.0`. + +If you want to switch to the tradition setup, replace the following code in your +`pyproject.toml` + +```toml +[build-system] +requires = ["setuptools>=45", "wheel", "setuptools_scm[toml]>=6.0"] +``` + +with + +```toml +[build-system] +requires = ["setuptools"] +build-backend = "setuptools.build_meta" +``` ```{toctree} --- caption: 'Contents:' maxdepth: 1 --- -faq changes ``` diff --git a/hooks/post_gen_project.py b/hooks/post_gen_project.py index d45c3c6..b811751 100644 --- a/hooks/post_gen_project.py +++ b/hooks/post_gen_project.py @@ -62,56 +62,6 @@ def main() -> None: capture_output=True, ) - if "{{ cookiecutter.create_conda_environment_at_finish }}" == "yes": - if shutil.which("mamba") is not None: - conda_exe = shutil.which("mamba") - else: - conda_exe = shutil.which("conda") - - if conda_exe: - subprocess.run( - ( - conda_exe, - "env", - "create", - "-f", - (project_path / "environment.yml").absolute().as_posix(), - "--force", - ), - check=True, - capture_output=True, - ) - # Install pre-commit hooks and run them. - subprocess.run( # noqa: PLW1510 - ( - conda_exe, - "run", - "-n", - "{{ cookiecutter.conda_environment_name }}", - "pre-commit", - "install", - ), - capture_output=True, - ) - subprocess.run( # noqa: PLW1510 - ( - conda_exe, - "run", - "-n", - "{{ cookiecutter.conda_environment_name }}", - "pre-commit", - "run", - "--all-files", - ), - capture_output=True, - ) - else: - warnings.warn( - "conda environment could not be created since no conda or mamba " - "executable was found.", - stacklevel=1, - ) - if __name__ == "__main__": main() diff --git a/hooks/pre_gen_project.py b/hooks/pre_gen_project.py index 5809730..e3db32d 100644 --- a/hooks/pre_gen_project.py +++ b/hooks/pre_gen_project.py @@ -33,13 +33,6 @@ def main() -> None: if not re.match(MODULE_REGEX, module_name): raise ValueError(EXCEPTION_MSG_MODULE_NAME.format(module_name=module_name)) - environment_name = "{{ cookiecutter.conda_environment_name }}" - - if not re.match(ENVIRON_REGEX, environment_name): - raise ValueError( - EXCEPTION_MSG_ENVIRON_NAME.format(environment_name=environment_name), - ) - python_version = "{{ cookiecutter.python_version }}" if not re.match(PYTHONVERSION_REGEX, python_version): diff --git a/tests/test_cookie.py b/tests/test_cookie.py index 0e71f8c..350ad57 100644 --- a/tests/test_cookie.py +++ b/tests/test_cookie.py @@ -89,14 +89,12 @@ def test_remove_license(cookies): @pytest.mark.end_to_end() @pytest.mark.skipif(os.environ.get("CI") is None, reason="Run only in CI.") -def test_check_conda_environment_creation_and_run_all_checks(cookies): - """Test that the conda environment is created and pre-commit passes.""" +def test_check_pixi_and_run_all_checks(cookies): + """Test pixi and pre-commit passes.""" result = cookies.bake( extra_context={ - "conda_environment_name": "__test__", "make_initial_commit": "yes", - "create_conda_environment_at_finish": "yes", - "python_version": _PYTHON_VERSION, + "python_version": _PYTHON_VERSION }, ) From 0c359acaf0964b9c8455e7153f25a1a190bdc413 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 3 May 2024 18:47:51 +0000 Subject: [PATCH 10/19] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- hooks/post_gen_project.py | 1 - tests/test_cookie.py | 5 +---- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/hooks/post_gen_project.py b/hooks/post_gen_project.py index b811751..002affb 100644 --- a/hooks/post_gen_project.py +++ b/hooks/post_gen_project.py @@ -4,7 +4,6 @@ import shutil import subprocess -import warnings from contextlib import suppress from pathlib import Path diff --git a/tests/test_cookie.py b/tests/test_cookie.py index 5b9bcbd..bc28592 100644 --- a/tests/test_cookie.py +++ b/tests/test_cookie.py @@ -92,10 +92,7 @@ def test_remove_license(cookies): def test_check_pixi_and_run_all_checks(cookies): """Test pixi and pre-commit passes.""" result = cookies.bake( - extra_context={ - "make_initial_commit": "yes", - "python_version": _PYTHON_VERSION - }, + extra_context={"make_initial_commit": "yes", "python_version": _PYTHON_VERSION}, ) assert result.exit_code == 0 From 95c8737eb6ae0bd86bd4622cafc89e2e62415831 Mon Sep 17 00:00:00 2001 From: Tobias Raabe Date: Fri, 3 May 2024 20:50:50 +0200 Subject: [PATCH 11/19] fix global install. --- tests/test_cookie.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_cookie.py b/tests/test_cookie.py index bc28592..25e6096 100644 --- a/tests/test_cookie.py +++ b/tests/test_cookie.py @@ -109,7 +109,7 @@ def test_check_pixi_and_run_all_checks(cookies): # Install pre-commit. subprocess.run( - ("pixi", "install", "pre-commit"), cwd=result.project_path, check=True + ("pixi", "global", "install", "pre-commit"), cwd=result.project_path, check=True ) # Check linting, but not on the first try since formatters fix stuff. subprocess.run( From c136289284314cfbe1ae035e81f5c2bf6215baf1 Mon Sep 17 00:00:00 2001 From: Tobias Raabe Date: Fri, 3 May 2024 20:52:31 +0200 Subject: [PATCH 12/19] Fix. --- docs/source/index.md | 2 +- {{cookiecutter.project_slug}}/pyproject.toml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/source/index.md b/docs/source/index.md index 4863e05..ba0f26b 100644 --- a/docs/source/index.md +++ b/docs/source/index.md @@ -28,7 +28,7 @@ cookiecutter https://github.com/pytask-dev/cookiecutter-pytask-project ## Features -TODO!!! +- [pixi](https://pixi.sh/latest/) as the environment and package manager. ## FAQ diff --git a/{{cookiecutter.project_slug}}/pyproject.toml b/{{cookiecutter.project_slug}}/pyproject.toml index f9946b9..c5479f3 100644 --- a/{{cookiecutter.project_slug}}/pyproject.toml +++ b/{{cookiecutter.project_slug}}/pyproject.toml @@ -111,8 +111,8 @@ test = { features = ["test"], solve-group = "default" } [tool.pixi.tasks] -[tool.pixi.features.test.tasks] +[tool.pixi.feature.test.tasks] test = "pytest --cov src --cov tests" -[tool.pixi.features.docs.tasks] +[tool.pixi.feature.docs.tasks] docs = "sphinx-build -b html docs/source docs/build" From ef3a6b3f4a64879b76b5ea7b07e0b3502ba99eb3 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 3 May 2024 18:55:23 +0000 Subject: [PATCH 13/19] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- tests/test_cookie.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/test_cookie.py b/tests/test_cookie.py index 25e6096..4f7b747 100644 --- a/tests/test_cookie.py +++ b/tests/test_cookie.py @@ -109,7 +109,9 @@ def test_check_pixi_and_run_all_checks(cookies): # Install pre-commit. subprocess.run( - ("pixi", "global", "install", "pre-commit"), cwd=result.project_path, check=True + ("pixi", "global", "install", "pre-commit"), + cwd=result.project_path, + check=True, ) # Check linting, but not on the first try since formatters fix stuff. subprocess.run( From 856d03a129f0a61281c596adccf9a5e938fcb7e7 Mon Sep 17 00:00:00 2001 From: Tobias Raabe Date: Fri, 3 May 2024 20:55:43 +0200 Subject: [PATCH 14/19] fix. --- docs/source/index.md | 5 +++-- tests/test_cookie.py | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/docs/source/index.md b/docs/source/index.md index ba0f26b..aeaf70f 100644 --- a/docs/source/index.md +++ b/docs/source/index.md @@ -12,18 +12,19 @@ This repository contains a minimal cookiecutter template for a project with ## Usage -First, install cookiecutter. +First, install cookiecutter with the package manager of your choice. ```console pip install cookiecutter - conda install -c conda-forge cookiecutter +pixi global install cookiecutter ``` Then, set up the template with ```console cookiecutter https://github.com/pytask-dev/cookiecutter-pytask-project +pixi run cookiecutter https://github.com/pytask-dev/cookiecutter-pytask-project ``` ## Features diff --git a/tests/test_cookie.py b/tests/test_cookie.py index 25e6096..a801432 100644 --- a/tests/test_cookie.py +++ b/tests/test_cookie.py @@ -113,12 +113,12 @@ def test_check_pixi_and_run_all_checks(cookies): ) # Check linting, but not on the first try since formatters fix stuff. subprocess.run( - ("pixi", "run", "pre-commit", "--all-files"), + ("pixi", "run", "pre-commit", "run", "--all-files"), cwd=result.project_path, check=False, ) subprocess.run( - ("pixi", "run", "pre-commit", "--all-files"), + ("pixi", "run", "pre-commit", "run", "--all-files"), cwd=result.project_path, check=True, ) From 727f86aabe9bfd53f5774bac766eb5f28058dffd Mon Sep 17 00:00:00 2001 From: Tobias Raabe Date: Fri, 3 May 2024 20:58:14 +0200 Subject: [PATCH 15/19] ALlow all common platforms. --- {{cookiecutter.project_slug}}/pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/{{cookiecutter.project_slug}}/pyproject.toml b/{{cookiecutter.project_slug}}/pyproject.toml index c5479f3..0caf9be 100644 --- a/{{cookiecutter.project_slug}}/pyproject.toml +++ b/{{cookiecutter.project_slug}}/pyproject.toml @@ -96,7 +96,7 @@ norecursedirs = [".idea", ".tox"] [tool.pixi.project] channels = ["conda-forge"] -platforms = ["linux-64"] +platforms = ["win-64", "linux-64", "osx-64", "osx-arm64"] [tool.pixi.dependencies] pytask = ">=0.4.7,<0.5" From 8c3754d511b33dea8617e743d7c6e814d1c0324e Mon Sep 17 00:00:00 2001 From: Tobias Raabe Date: Fri, 3 May 2024 21:02:25 +0200 Subject: [PATCH 16/19] fix docs: --- tests/test_cookie.py | 63 +++++++++---------- .../docs/source/conf.py | 2 +- 2 files changed, 32 insertions(+), 33 deletions(-) diff --git a/tests/test_cookie.py b/tests/test_cookie.py index 7257e10..6f3d27f 100644 --- a/tests/test_cookie.py +++ b/tests/test_cookie.py @@ -98,35 +98,34 @@ def test_check_pixi_and_run_all_checks(cookies): assert result.exit_code == 0 assert result.exception is None - if sys.platform != "win32": - # Switch branch before pre-commit because otherwise failure because on main - # branch. - subprocess.run( - ("git", "checkout", "-b", "test"), - cwd=result.project_path, - check=True, - ) - - # Install pre-commit. - subprocess.run( - ("pixi", "global", "install", "pre-commit"), - cwd=result.project_path, - check=True, - ) - # Check linting, but not on the first try since formatters fix stuff. - subprocess.run( - ("pixi", "run", "pre-commit", "run", "--all-files"), - cwd=result.project_path, - check=False, - ) - subprocess.run( - ("pixi", "run", "pre-commit", "run", "--all-files"), - cwd=result.project_path, - check=True, - ) - - # Run tests. - subprocess.run(("pixi", "run", "test"), cwd=result.project_path, check=True) - - # Test building documentation - subprocess.run(("pixi", "run", "docs"), cwd=result.project_path, check=True) + # Switch branch before pre-commit because otherwise failure because on main + # branch. + subprocess.run( + ("git", "checkout", "-b", "test"), + cwd=result.project_path, + check=True, + ) + + # Install pre-commit. + subprocess.run( + ("pixi", "global", "install", "pre-commit"), + cwd=result.project_path, + check=True, + ) + # Check linting, but not on the first try since formatters fix stuff. + subprocess.run( + ("pixi", "run", "pre-commit", "run", "--all-files"), + cwd=result.project_path, + check=False, + ) + subprocess.run( + ("pixi", "run", "pre-commit", "run", "--all-files"), + cwd=result.project_path, + check=True, + ) + + # Run tests. + subprocess.run(("pixi", "run", "test"), cwd=result.project_path, check=True) + + # Test building documentation + subprocess.run(("pixi", "run", "docs"), cwd=result.project_path, check=True) diff --git a/{{cookiecutter.project_slug}}/docs/source/conf.py b/{{cookiecutter.project_slug}}/docs/source/conf.py index d9c3d2c..0afcfcc 100644 --- a/{{cookiecutter.project_slug}}/docs/source/conf.py +++ b/{{cookiecutter.project_slug}}/docs/source/conf.py @@ -37,8 +37,8 @@ "sphinxext.opengraph", "sphinx.ext.viewcode", "sphinx_copybutton", - "sphinx_panels", "myst_parser", + "sphinx_design", ] # Add any paths that contain templates here, relative to this directory. From c23bc26a3712e9566a2ad6c65fc4aebb09b68ec9 Mon Sep 17 00:00:00 2001 From: Tobias Raabe Date: Fri, 3 May 2024 21:21:37 +0200 Subject: [PATCH 17/19] Add fetures. --- README.md | 15 ----------- docs/source/index.md | 33 ++++++++++++++++++----- {{cookiecutter.project_slug}}/MANIFEST.in | 9 ------- 3 files changed, 27 insertions(+), 30 deletions(-) delete mode 100644 {{cookiecutter.project_slug}}/MANIFEST.in diff --git a/README.md b/README.md index 3c8777b..7d1619e 100644 --- a/README.md +++ b/README.md @@ -10,21 +10,6 @@ This repository contains a minimal cookiecutter template for a project with [pytask](https://github.com/pytask-dev/pytask). -## Usage - -First, install cookiecutter. - -```console -pip install cookiecutter -conda install -c conda-forge cookiecutter -``` - -Then, set up the template with - -```console -cookiecutter https://github.com/pytask-dev/cookiecutter-pytask-project -``` - ## Documentation You find the documentation at . diff --git a/docs/source/index.md b/docs/source/index.md index aeaf70f..bca0ea8 100644 --- a/docs/source/index.md +++ b/docs/source/index.md @@ -10,26 +10,47 @@ This repository contains a minimal cookiecutter template for a project with [pytask](https://github.com/pytask-dev/pytask). -## Usage +## Installation -First, install cookiecutter with the package manager of your choice. +The template uses [pixi](https://pixi.sh/) as the package and environment manager which +is the successor of conda/mamba/micromamba. Please, install it. + +```{info} +Of course, the template can be used with any other package manager. But, we recommend +pixi which can install packages from conda, PyPI, etc.. or [rye](https://rye-up.com/) +for PyPI-only projects. +``` + +Then, install cookiecutter. ```console -pip install cookiecutter -conda install -c conda-forge cookiecutter pixi global install cookiecutter ``` -Then, set up the template with +Now, set up the template with ```console -cookiecutter https://github.com/pytask-dev/cookiecutter-pytask-project pixi run cookiecutter https://github.com/pytask-dev/cookiecutter-pytask-project ``` +Many formatting issues exist after the project is created. Run pre-commit to polish the +template. + +```console +pixi global install pre-commit +pixi run pre-commit run -a +``` + ## Features +Here is a feature list of the template. + - [pixi](https://pixi.sh/latest/) as the environment and package manager. +- Supports pre-commit and some popular hooks like ruff and refurb. +- Initialized documentation in `docs`. +- Preconfigured GitHub actions and dependabot. +- Preconfigured readthedocs. +- Preconfigured CodeCov. ## FAQ diff --git a/{{cookiecutter.project_slug}}/MANIFEST.in b/{{cookiecutter.project_slug}}/MANIFEST.in deleted file mode 100644 index 95e45be..0000000 --- a/{{cookiecutter.project_slug}}/MANIFEST.in +++ /dev/null @@ -1,9 +0,0 @@ -include CITATION -{% if cookiecutter.open_source_license != 'Not open source' %}include LICENSE -{% endif %} -exclude *.yaml -exclude *.yml -exclude tox.ini - -prune docs -prune tests From db8aecd2e29fa5608c1dc456278f4802a5d1f8da Mon Sep 17 00:00:00 2001 From: Tobias Raabe Date: Fri, 3 May 2024 21:23:41 +0200 Subject: [PATCH 18/19] Fix docs. --- docs/source/index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/source/index.md b/docs/source/index.md index bca0ea8..2dfa30e 100644 --- a/docs/source/index.md +++ b/docs/source/index.md @@ -15,7 +15,7 @@ This repository contains a minimal cookiecutter template for a project with The template uses [pixi](https://pixi.sh/) as the package and environment manager which is the successor of conda/mamba/micromamba. Please, install it. -```{info} +```{note} Of course, the template can be used with any other package manager. But, we recommend pixi which can install packages from conda, PyPI, etc.. or [rye](https://rye-up.com/) for PyPI-only projects. From caeec1677c14b8052a07e1a5c585b49b62d46fa3 Mon Sep 17 00:00:00 2001 From: Tobias Raabe Date: Fri, 3 May 2024 21:32:18 +0200 Subject: [PATCH 19/19] install generated package. --- {{cookiecutter.project_slug}}/pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/{{cookiecutter.project_slug}}/pyproject.toml b/{{cookiecutter.project_slug}}/pyproject.toml index 0caf9be..e41393b 100644 --- a/{{cookiecutter.project_slug}}/pyproject.toml +++ b/{{cookiecutter.project_slug}}/pyproject.toml @@ -102,7 +102,7 @@ platforms = ["win-64", "linux-64", "osx-64", "osx-arm64"] pytask = ">=0.4.7,<0.5" [tool.pixi.pypi-dependencies] -reproducible_research_template = { path = ".", editable = true } +{{ cookiecutter.project_slug }} = { path = ".", editable = true } [tool.pixi.environments] default = { solve-group = "default" }