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

Continue migration to uv #705

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 13 additions & 8 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,14 @@ jobs:
pip install --constraint=.github/workflows/constraints.txt pip
pip --version

- name: Install Poetry
- name: Install UV
run: |
pip install --constraint=.github/workflows/constraints.txt poetry
poetry --version
pipx install --pip-args=--constraint=.github/workflows/constraints.txt uv
uv --version

- name: Install tomlq
run: |
uv pip install tomlq
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be pip install tomlq?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Basilio, we are experimenting with uv to speed things up. uv has a pip compatibility mode, which we are using in this row. The use of uv is deliberate

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good to know. I'm not familiar with uv, I'll check it out


- name: Check if there is a parent commit
id: check-parent-commit
Expand All @@ -56,18 +60,19 @@ jobs:
uses: salsify/action-detect-and-tag-new-version@b1778166f13188a9d478e2d1198f993011ba9864 # v2.0.3
with:
version-command: |
bash -o pipefail -c "poetry version | awk '{ print \$2 }'"
bash -o pipefail -c "tomlq -r '.project.version' pyproject.toml

- name: Bump version for developmental release
if: "! steps.check-version.outputs.tag"
run: |
poetry version patch &&
version=$(poetry version | awk '{ print "$2" }') &&
poetry version "$version".dev."$(date +%s)"
version=$(tomlq -r '.project.version' pyproject.toml) &&
base_version="${version///\.dev.*//}" &&
new_version="${base_version}.dev.$(date +%s)" &&
tomlq -i ".project.version = ${new_version}" pyproject.toml

- name: Build package
run: |
poetry build --ansi
uv build

# - name: Publish package on PyPI
# if: steps.check-version.outputs.tag
Expand Down
11 changes: 4 additions & 7 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,27 +48,24 @@ Using SSH keys to check out the repository is ideal, as we require contributors

You need Python 3.9+ and the following tools:

- [Poetry]
- [uv]
- [Nox]
- [nox-poetry]

Install the package with development requirements:

```console
poetry install
UV_PREVIEW=1 uv sync
```

You can now run an interactive Python session,
or the command-line interface:

```console
poetry run python
poetry run devops-deployment-metrics
devops-deployment-metrics
```

[poetry]: https://python-poetry.org/
[uv]: https://github.com/astral-sh/uv
[nox]: https://nox.thea.codes/
[nox-poetry]: https://nox-poetry.readthedocs.io/

### Git pre-commit hooks

Expand Down
23 changes: 6 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,25 +1,15 @@
# DevOps Deployments Metrics

[![PyPI](https://img.shields.io/pypi/v/devops-deployment-metrics.svg)][pypi_]
[![Status](https://img.shields.io/pypi/status/devops-deployment-metrics.svg)][status]
[![Python Version](https://img.shields.io/pypi/pyversions/devops-deployment-metrics)][python version]
[![License](https://img.shields.io/pypi/l/devops-deployment-metrics)][license]

[![Read the documentation at https://devops-deployment-metrics.readthedocs.io/](https://img.shields.io/readthedocs/devops-deployment-metrics/latest.svg?label=Read%20the%20Docs)][read the docs]
[![Tests](https://github.com/flexion/devops-deployment-metrics/workflows/Tests/badge.svg)][tests]
[![Codecov](https://codecov.io/gh/flexion/devops-deployment-metrics/branch/main/graph/badge.svg)][codecov]

[![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&logoColor=white)][pre-commit]
[![Black](https://img.shields.io/badge/code%20style-black-000000.svg)][black]
[![ruff](https://img.shields.io/badge/ruff-enabled-brightgreen?logo=astral&logoColor=white)][ruff]

[pypi_]: https://pypi.org/project/devops-deployment-metrics/
[status]: https://pypi.org/project/devops-deployment-metrics/
[python version]: https://pypi.org/project/devops-deployment-metrics
[read the docs]: https://devops-deployment-metrics.readthedocs.io/
[tests]: https://github.com/flexion/devops-deployment-metrics/actions?workflow=Tests
[codecov]: https://app.codecov.io/gh/flexion/devops-deployment-metrics
[pre-commit]: https://github.com/pre-commit/pre-commit
[black]: https://github.com/psf/black
[ruff]: https://astral.sh/ruff

An application that generates DevOps deployment metrics from GitHub repositories using a GitHub Action workflow to deploy a product.

Expand Down Expand Up @@ -57,13 +47,13 @@ metric is reported in hours.
## Requirements

- Python 3.9+
- Poetry (installation instructions provided [here](https://python-poetry.org/docs/#installing-with-the-official-installer))
- uv (installation instructions provided [here](https://github.com/astral-sh/uv?tab=readme-ov-file#installation))
- Supported OS: Windows 10, Windows 11, Linux, MacOS

## Installation

```shell
poetry install
uv sync
```

## Usage
Expand Down Expand Up @@ -108,7 +98,7 @@ Just the filename, not the path.
### Launching the application

```shell
poetry run devops-deployment-metrics -v -c my-config.toml
devops-deployment-metrics -v -c my-config.toml
```

Please see the [Command-line Reference] for more details.
Expand All @@ -130,7 +120,7 @@ please [file an issue] along with a detailed description.

## Credits

This project was generated from [@cjolowicz]'s [Hypermodern Python Cookiecutter] template.
This project was initially generated from [@cjolowicz]'s [Hypermodern Python Cookiecutter] template.

[@cjolowicz]: https://github.com/cjolowicz
[hypermodern python cookiecutter]: https://github.com/cjolowicz/cookiecutter-hypermodern-python
Expand All @@ -140,4 +130,3 @@ This project was generated from [@cjolowicz]'s [Hypermodern Python Cookiecutter]

[license]: https://github.com/flexion/devops-deployment-metrics/blob/main/LICENSE
[contributor guide]: https://github.com/flexion/devops-deployment-metrics/blob/main/CONTRIBUTING.md
[command-line reference]: https://devops-deployment-metrics.readthedocs.io/en/latest/usage.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# Replace Poetry with uv for Dependency Management

## Context

Our project previously used **Poetry** for dependency management, packaging, and versioning. While Poetry provides a comprehensive toolset for Python projects, we identified several pain points:

- **Performance**: Poetry can be slow, particularly in resolving dependencies and managing lockfiles.
- **Complexity**: The Poetry CLI has a large feature set, but we were primarily using it for dependency management and builds, making some features redundant.
- **Compatibility**: Our project needs fast, reliable dependency management with reproducible builds, and we are looking for a more minimalistic and modern solution.

**uv** from **astal.sh** is a new Python packaging tool designed to simplify dependency management, improve performance, and provide reproducible builds with a straightforward workflow.

## **Decision**

We will replace **Poetry** with **uv** for managing dependencies, creating lockfiles, and building the project.

## Alternatives Considered

1. **Continue Using Poetry**

- Pros:
- Well-established and widely adopted in the Python community.
- Comprehensive feature set.
- Cons:
- Slower dependency resolution and build times.
- More complex than needed for our current workflow.

2. **Switch to pip-tools**

- Pros:
- Lightweight toolset for managing dependencies.
- Works well with native `pip`.
- Cons:
- No built-in support for project metadata (PEP 621).
- Requires additional tools to handle building and packaging.

3. **Adopt uv** (Chosen)
- Pros:
- Faster dependency resolution and lockfile creation.
- Native support for `pyproject.toml` and PEP 621.
- Minimalistic and modern toolchain.
- Cons:
- Newer tool with a smaller community compared to Poetry.
- Requires some workflow adjustments (e.g., versioning).

## Consequences

### Positive Impacts

- **Faster Builds**: uv provides faster dependency resolution and package builds.
- **Simplified Workflow**: The tool is more aligned with our goal of a lean, efficient build process.
- **Reproducible Builds**: uv generates a `uv.lock` file to ensure consistent environments across installations.

### Negative Impacts

- **Learning Curve**: Team members need to become familiar with uv’s CLI.
- **Ecosystem**: uv is a newer tool, so it may have fewer third-party resources and integrations compared to Poetry.

## Status

Approved

## **Consequences of Not Making This Change**

- Continued slow builds and dependency resolution times.
- Complexity in maintaining our dependency management workflows.
- Potential frustration with overly complex tooling for our use case.
Loading