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

Switch from Poetry to uv #3033

Open
2 tasks done
cyberw opened this issue Jan 16, 2025 · 3 comments
Open
2 tasks done

Switch from Poetry to uv #3033

cyberw opened this issue Jan 16, 2025 · 3 comments
Assignees

Comments

@cyberw
Copy link
Collaborator

cyberw commented Jan 16, 2025

Prerequisites

Description

Poetry is too slow and cumbersome. And the whole community seems to be moving over as well.

I think we could also remove tox while we are at it.

Here's some inspiration from locust-cloud.

...
[build-system]
requires = ["hatchling", "hatch-vcs"]
build-backend = "hatchling.build"

[tool.hatch.build.targets.wheel]
include = [
    "locust_cloud/**/*"
]

[tool.hatch.version]
source = "vcs"

[tool.hatch.version.raw-options]
local_scheme = "no-local-version"

[tool.hatch.build.hooks.custom]
[tool.hatch.build.targets.BuildFrontend.hooks.custom]
...
    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0
          fetch-tags: true
      - uses: actions/setup-python@v5
        with:
            python-version: '3.11'
      - uses: astral-sh/setup-uv@v2
      - uses: actions/setup-node@v4
        with:
          node-version: 22.x
      - uses: actions/setup-python@v5
        with:
            python-version: '3.11'
      - uses: astral-sh/setup-uv@v2
      - uses: actions/setup-node@v4
        with:
          node-version: 22.x
      - run: uv venv --python 3.11
      # any local changes would make hatch-vcs set a "local version" (+dev0...), so we ignore any uv.lock updates:
      - run: git update-index --assume-unchanged uv.lock
      - run: python -m unittest discover []

hatch_build.py in root folder:

import subprocess

from hatchling.builders.hooks.plugin.interface import BuildHookInterface  # type: ignore


class BuildFrontend(BuildHookInterface):
    def initialize(self, version, build_data):
        try:
            subprocess.check_output("yarn install", cwd="locust/webui", shell=True, stderr=subprocess.STDOUT)
            subprocess.check_output("yarn build", cwd="locust/webui", shell=True, stderr=subprocess.STDOUT)
        except subprocess.CalledProcessError as e:
            raise RuntimeError(f"'{e.cmd}' got exit code {e.returncode}: {e.output}")

        return super().initialize(version, build_data)
@mquinnfd
Copy link
Contributor

Hey hey,

I'll look at picking this up, thank you Locust Cloud 😄

@mquinnfd
Copy link
Contributor

mquinnfd commented Jan 29, 2025

Just for visibility, I'm working from this draft PR here https://github.com/locustio/locust/pull/3039/files

  • Poetry etc. switched to hatch/uv
  • Dynamic versioning stuff working OK locally
  • Local build with front end compilation working
  • Started moving tox targets over to hatch envs
  • Running existing tests via pytest (which was already added) plus coverage

Probably going to be next week before I tackle the pipeline, as this takes longer generally, but I'd say it's going well 🥳

@cyberw
Copy link
Collaborator Author

cyberw commented Jan 29, 2025

Awesome!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants