Skip to content
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

Manage versioning of Poetry tool dependency #294

Merged
merged 2 commits into from
Jun 14, 2024
Merged

Manage versioning of Poetry tool dependency #294

merged 2 commits into from
Jun 14, 2024

Conversation

per1234
Copy link
Collaborator

@per1234 per1234 commented Jun 14, 2024

The project's Python package dependencies are managed by the Poetry tool.

Previously, the version of Poetry was managed in two inconsistent and sub-ideal ways:

  • The version used during execution of the action was hardcoded in the action metadata file.
  • The version used locally by contributors and by the GitHub Actions workflows was not managed at all.

The first is problematic because there is no mechanism to facilitate updates, which means it will never be updated.

The second is problematic because some versions might be incompatible, or produce different results than the version used by the action.

The better solution is to take the same approach for managing the Poetry dependency as done for the project's other dependencies:

  • Install a specific version of Poetry according to a single source of versioning data.
  • Use the Dependabot service to get automated update pull requests.

The logical place to define the poetry package dependency version is in pyproject.toml, as is done for all direct Python package dependencies.

Dependabot recognizes two forms of dependency data in the pyproject.toml file:

Since Poetry can't be used to manage itself (it is instead installed using pipx, the obvious approach would be to define the poetry dependency in a PEP 621 field in the file. However, this is not possible because if Dependabot finds Poetry data in pyproject.toml, it ignores the PEP 621 fields. So it is necessary to define the Poetry dependency in the Poetry fields of the file. A special dependencies group is created for this purpose. That group is configured as "optional" so that it won't be installed redundantly by poetry install commands.

Unfortunately pipx doesn't support using pyproject.toml as a dependency configuration file so it is necessary to generate the dependency argument in the pipx command by parsing the project.toml file. The yq tool is used for this purpose.

The project's Python package dependencies are managed by the Poetry tool.

In addition to the packages used by the action script, project development tools from Python packages are also managed
by Poetry. For this reason, Poetry is a dependency of several of the tasks in the taskfile.

Previously, there was an undocumented requirement that the contributor have Poetry installed and in their system path.
The reason for that approach was that, at the time, the practice was to make a global system installation of Poetry,
which might cause problems for some contributors. Since that time, the project has migrated to using pipx to install
Poetry. This tool installs Poetry in an virtual environment.

Of course, even though this means manual installation of Poetry is no longer the responsibility of the contributor,
installation of pipx is. However, the officially recommended mechanism for installing Poetry is now pipx so the
contributor would have likely ended up manually installing pipx anyway as a prerequisite for the Poetry installation
procedure.
The project's Python package dependencies are managed by the Poetry tool.

Previously, the version of Poetry was managed in two inconsistent and sub-ideal ways:

* The version used during execution of the action was hardcoded in the action metadata file.
* The version used locally by contributors and by the GitHub Actions workflows was not managed at all.

The first is problematic because there is no mechanism to facilitate updates, which means it will never be updated.

The second is problematic because some versions might be incompatible, or produce different results than the version
used by the action.

The better solution is to take the same approach for managing the Poetry dependency as done for the project's other
dependencies:

* Install a specific version of Poetry according to a single source of versioning data.
* Use the Dependabot service to get automated update pull requests.

The logical place to define the Poetry package dependency version is in pyproject.toml, as is done for all direct Python
package dependencies.

Dependabot recognizes two forms of dependency data in the pyproject.toml file:

* Poetry
* PEP 621

Since Poetry can't be used to manage itself, the obvious approach would be to define the Poetry dependency in a PEP 621
field in the file. However, this is not possible because if Dependabot finds Poetry data in pyproject.toml, it ignores
the PEP 621 fields. So it is necessary to define the Poetry dependency in the Poetry fields of the file. A special
dependencies group is created for this purpose. That group is configured as "optional" so that it won't be installed
redundantly by `poetry install` commands.

Unfortunately pipx doesn't support using pyproject.toml as a dependency configuration file so it is necessary to
generate the dependency argument in the pipx command by parsing the project.toml file.
@per1234 per1234 added type: enhancement Proposed improvement topic: infrastructure Related to project infrastructure labels Jun 14, 2024
@per1234 per1234 self-assigned this Jun 14, 2024
@codecov-commenter
Copy link

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.81%. Comparing base (1719ade) to head (e5f98c3).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #294   +/-   ##
=======================================
  Coverage   99.81%   99.81%           
=======================================
  Files           2        2           
  Lines        1623     1623           
=======================================
  Hits         1620     1620           
  Misses          3        3           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@per1234 per1234 merged commit 670c810 into arduino:main Jun 14, 2024
41 checks passed
@per1234 per1234 deleted the dependabot-poetry branch June 14, 2024 02:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: infrastructure Related to project infrastructure type: enhancement Proposed improvement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants