Skip to content

Commit

Permalink
Remove "path" in environment again
Browse files Browse the repository at this point in the history
  • Loading branch information
FlorianWilhelm committed Nov 30, 2023
1 parent 5c804d9 commit c4ca8eb
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 7 deletions.
1 change: 0 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

- New: use `post-install-commands = ["pre-commit install"]` in `pyproject.toml` to make sure the pre-commit hook is installed
- Change: have a clean `default` environment and test-related tools are now in `test` environment
- Change: set `path=.direnv` in `pyproject.toml` directly for VSCode support, instead of giving the hint to set it globally
- New: add [pytest-sugar](https://github.com/Teemu/pytest-sugar/) to `test` environment
- New: experimental lock-file support using [hatch-pip-compile](https://github.com/juftin/hatch-pip-compile)

Expand Down
9 changes: 8 additions & 1 deletion {{cookiecutter.project_slug}}/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,13 @@
To set up [hatch] and [pre-commit] for the first time:

1. install [hatch] globally, e.g. with [pipx], i.e. `pipx install hatch`,
2. make sure `pre-commit` is installed globally, e.g. with `pipx install pre-commit`,
{% if cookiecutter.lock_file_support -%}
2. optionally run `hatch config set dirs.env.virtual .direnv` and `hatch config set dirs.env.pip-compile .direnv`
to let [VS Code] find your virtual environments,
{% else -%}
2. optionally run `hatch config set dirs.env.virtual .direnv` to let [VS Code] find your virtual environments,
{% endif -%}
3. make sure `pre-commit` is installed globally, e.g. with `pipx install pre-commit`,

A special feature that makes hatch very different from other familiar tools is that you almost never
activate, or enter, an environment. Instead, you use `hatch run env_name:command` and the `default` environment
Expand Down Expand Up @@ -44,6 +50,7 @@ This package was created with [The Hatchlor] project template.
[pipx]: https://pypa.github.io/pipx/
[hatch]: https://hatch.pypa.io/
[pre-commit]: https://pre-commit.com/
[VS Code]: https://code.visualstudio.com/docs/python/environments#_where-the-extension-looks-for-environments
{%- if cookiecutter.lock_file_support %}
[hatch-pip-compile]: https://github.com/juftin/hatch-pip-compile
{%- endif %}
14 changes: 9 additions & 5 deletions {{cookiecutter.project_slug}}/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,6 @@ requires = ["hatch-pip-compile~=1.2"]
# Default environment with production dependencies
[tool.hatch.envs.default]
python = "{{ cookiecutter.target_python_version }}"
path = ".direnv" # to have VSCode support
post-install-commands = ["pre-commit install"]
{%- if cookiecutter.lock_file_support %}
type = "pip-compile"
Expand All @@ -229,18 +228,23 @@ upgrade-all = "PIP_COMPILE_UPGRADE=1 hatch env run --env {env_name} -- python --
upgrade-pkg = "PIP_COMPILE_UPGRADE='{args}' hatch env run --env {env_name} -- python --version"
{%- endif %}

# Test environment, i.e. development dependencies
# Test environment with test-only dependencies
[tool.hatch.envs.test]
dependencies = [ # ToDo: Modify according to your needs!
dependencies = [
# required test dependencies
"coverage[toml]>=6.2",
"pytest",
"pytest-cov",
"pytest-mock",
"pytest-vcr",
"pytest-sugar",
# additional test & development dependencies
# ToDo: Modify according to your needs!
"hypothesis",
"mypy",
"ruff"
"jupyterlab",
"ipython",
"seaborn",
"pandas",
]
[tool.hatch.envs.test.scripts]
cov = "pytest --cov-report=term-missing --cov-config=pyproject.toml --cov=src/{{ cookiecutter.pkg_name }} --cov=tests {args}"
Expand Down

0 comments on commit c4ca8eb

Please sign in to comment.