-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Migrate from Poetry 1.1 to Hatch #58
Conversation
- Remove `poetry.lock` - Remove `poetry.toml` - Remove `[tool.poetry]` sections from `pyproject.toml` - Update `[build-system]` section in `pyproject.toml` for Hatchling - Move version number to `inboard/__init__.py`, which allows Python projects to import it with `import inboard` then `inboard.__version__` - Add project metadata to new `[project]` section in `pyproject.toml`, bringing this project in line with Python project metadata standards - Add optional dependencies to `[project.optional-dependencies]` groups - Pin asgiref and mypy to avoid breaking changes to type checking that could be introduced by changes to mypy strict mode (2cbc99c) or by changes to asgiref `TypedDict` keys (d729fdf) - Add environments to `[tool.hatch.envs.*]` tables, using `features` for optional dependency groups, and `path = ".venv"` for an in-project virtualenv in the same location as a Poetry in-project virtualenv https://hatch.pypa.io/latest/config/environment/overview/ https://hatch.pypa.io/latest/plugins/environment/virtual/ - Add Hatch environment names to `.gitignore`
- Remove `poetry.lock` and `poetry.toml` from `COPY` step - Add README.md to `COPY` step (README.md is part of the Python package) - Break `ARG` and `ENV` commands onto multiple lines for readability - Add `HATCH_VERSION` build arg - Set `HATCH_ENV_TYPE_VIRTUAL_PATH=".venv"` to ensure consistent in-project virtualenv location - Install Hatch with `pipx` - Continue installing Poetry 1.1 with `pipx` for backwards compatibility for now. Poetry 1.1 is unmaintained, and so it will eventually need to be removed. Notice will be given at least one minor version ahead. - Replace `poetry install` commands with `hatch env create` commands. There is no direct command to manually install or sync dependencies. The Hatch docs say, "You never need to manually create environments as spawning a shell or running commands within one will automatically trigger creation." The `hatch env create` command will create the virtual environment and install the appropriate dependencies. https://hatch.pypa.io/latest/environment/
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Sourcery Code Quality Report❌ Merging this PR will decrease code quality in the affected files by 0.48%.
Here are some functions in these files that still need a tune-up:
Legend and ExplanationThe emojis denote the absolute quality of the code:
The 👍 and 👎 indicate whether the quality has improved or gotten worse with this pull request. Please see our documentation here for details on how these metrics are calculated. We are actively working on this report - lots more documentation and extra metrics to come! Help us improve this quality report! |
The Sourcery report from @sourcery-ai[bot] suggests that adding |
- Update test that ensures `pipx` installs correct version of Hatch - Update test for consistent in-project virtualenv directory (`.venv`) - Update caching for `pip` so that GitHub Actions caches dependencies - Update `poetry run` commands for Hatch, ensuring correct environment is selected with the `HATCH_ENV` environment variable or by prefixing each command with the environment name - Update package build and PyPI publish commands for Hatch
- Add new user words to `cspell.json` - Add Hatch description and instructions to contributing.md - Update Poetry references in docs for Hatch - Move instructions for code quality checks below instructions for Hatch so that contributors understand how to set up the project prior to running code quality checks
Move project install command after Hatch install command #58
PR #58 reorganized `pyproject.toml` for Hatch, bringing it _almost_ in line with PEP 621 standards. There was one oversight - the `repository` URL used to be in the `[tool.poetry]` table, and should have been moved to the `[project.urls]` table for Hatch. This commit will do so. #58 https://packaging.python.org/en/latest/specifications/declaring-project-metadata/ https://peps.python.org/pep-0621/
This commit provides a small follow-up to #58. The Hatch environment was specified directly in the `hatch env create` command, but other commands specified the environment implicitly with the `$HATCH_ENV` variable. This commit will update `hatch env create` and `hatch run` commands to reference the same environment variable directly.
Description
This PR will migrate inboard from Poetry 1.1 to Hatch. See #56 for more details and context around the motivations for this change.
Note that projects using inboard are not required to migrate to Hatch. The Docker images will retain Poetry 1.1 for backwards compatibility for now. Poetry 1.1 is unmaintained, and so it will eventually need to be removed, but there will be notice given at least one minor version ahead of time. If projects using inboard require
poetry>1.2
, they can addpipx upgrade poetry
orpipx install poetry>1.2 --force
to their Dockerfiles as described in the updated docs in this PR (on the Docker page, under "Docker and Poetry").Changes
Update configuration files for Hatch
poetry.lock
poetry.toml
[tool.poetry]
sections frompyproject.toml
[build-system]
section inpyproject.toml
for Hatchlinginboard/__init__.py
, which allows Python projects to import it withimport inboard
theninboard.__version__
[project]
section inpyproject.toml
, bringing this project in line with Python project metadata standards[project.optional-dependencies]
groupsTypedDict
keys (d729fdf)[tool.hatch.envs.*]
tables, usingfeatures
for optional dependency groups, andpath = ".venv"
for an in-project virtualenv in the same location as a Poetry in-project virtualenv.gitignore
Update Dockerfile for Hatch
poetry.lock
andpoetry.toml
fromCOPY
stepCOPY
step (README.md is part of the Python package)ARG
andENV
commands onto multiple lines for readabilityHATCH_VERSION
build argHATCH_ENV_TYPE_VIRTUAL_PATH=".venv"
to ensure consistent in-project virtualenv locationpipx
pipx
for backwards compatibility for now. Poetry 1.1 is unmaintained, and so it will eventually need to be removed, but there will be notice given at least one minor version ahead of time.poetry install
commands withhatch env create
commands. There is no direct command to manually install or sync dependencies. The Hatch docs say, "You never need to manually create environments as spawning a shell or running commands within one will automatically trigger creation." Thehatch env create
command will create the virtual environment and install the appropriate dependencies. Note that commands for directly installing or syncing environments may be added in the future.Update GitHub Actions workflows for Hatch
pipx
installs correct version of Hatch.venv
)pip
so that GitHub Actions caches dependenciespoetry run
commands for Hatch, ensuring correct environment is selected with theHATCH_ENV
environment variableUpdate docs for Hatch
cspell.json
Related