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

[DO NOT MERGE] Dropping poetry for uv #112

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from
Draft

[DO NOT MERGE] Dropping poetry for uv #112

wants to merge 7 commits into from

Conversation

Batalex
Copy link
Contributor

@Batalex Batalex commented Oct 25, 2024

A little side project of mine while I was waiting for CI to complete.

This PR showcases how we could use uv for:

  • Dependency management
    • Basic dependencies
    • Charm-lib
    • Workflow dependencies (git based)
    • Development dependencies with groups (waiting on PEP 735 to land in uv)
    • Renovate rule for charm-libs
  • Task runner with tox
  • Build (not yet working with strict deps)
  • CI

Building with strict deps does not yet work, and the logs do not give me the missing deps:

2024-10-25 11:23:26.483 :: 2024-10-25 11:23:25.808 :: Traceback (most recent call last):
2024-10-25 11:23:26.483 :: 2024-10-25 11:23:25.808 ::   File "/snap/charmcraft/4914/lib/python3.10/site-packages/charmcraft/charm_builder.py", line 483, in <module>
2024-10-25 11:23:26.483 :: 2024-10-25 11:23:25.808 ::     main()
2024-10-25 11:23:26.483 :: 2024-10-25 11:23:25.808 ::   File "/snap/charmcraft/4914/lib/python3.10/site-packages/charmcraft/charm_builder.py", line 478, in main
2024-10-25 11:23:26.483 :: 2024-10-25 11:23:25.808 ::     builder.build_charm()
2024-10-25 11:23:26.483 :: 2024-10-25 11:23:25.809 ::   File "/snap/charmcraft/4914/lib/python3.10/site-packages/charmcraft/charm_builder.py", line 93, in build_charm
2024-10-25 11:23:26.483 :: 2024-10-25 11:23:25.809 ::     self.handle_dependencies()
2024-10-25 11:23:26.483 :: 2024-10-25 11:23:25.809 ::   File "/snap/charmcraft/4914/lib/python3.10/site-packages/charmcraft/charm_builder.py", line 354, in handle_dependencies
2024-10-25 11:23:26.483 :: 2024-10-25 11:23:25.809 ::     self._install_dependencies(staging_venv_dir)
2024-10-25 11:23:26.483 :: 2024-10-25 11:23:25.809 ::   File "/snap/charmcraft/4914/lib/python3.10/site-packages/charmcraft/instrum.py", line 152, in _f
2024-10-25 11:23:26.483 :: 2024-10-25 11:23:25.809 ::     return func(*args, **kwargs)
2024-10-25 11:23:26.483 :: 2024-10-25 11:23:25.809 ::   File "/snap/charmcraft/4914/lib/python3.10/site-packages/charmcraft/charm_builder.py", line 253, in _install_dependencies
2024-10-25 11:23:26.483 :: 2024-10-25 11:23:25.809 ::     self._install_strict_dependencies(pip_cmd)
2024-10-25 11:23:26.483 :: 2024-10-25 11:23:25.809 ::   File "/snap/charmcraft/4914/lib/python3.10/site-packages/charmcraft/charm_builder.py", line 300, in _install_strict_dependencies
2024-10-25 11:23:26.483 :: 2024-10-25 11:23:25.809 ::     validate_strict_dependencies(
2024-10-25 11:23:26.483 :: 2024-10-25 11:23:25.810 ::   File "/snap/charmcraft/4914/lib/python3.10/site-packages/charmcraft/utils/package.py", line 165, in validate_strict_dependencies
2024-10-25 11:23:26.483 :: 2024-10-25 11:23:25.810 ::     raise errors.MissingDependenciesError(extra_packages)
2024-10-25 11:23:26.483 :: 2024-10-25 11:23:25.810 :: charmcraft.errors.MissingDependenciesError: Some dependencies were not included in requirements files.
2024-10-25 11:23:26.483 :: 2024-10-25 11:23:25.918 :: error:
2024-10-25 11:23:26.483 :: 2024-10-25 11:23:25.919 :: Traceback (most recent call last):
2024-10-25 11:23:26.483 :: 2024-10-25 11:23:25.919 ::   File "/snap/charmcraft/current/lib/python3.10/site-packages/craft_parts/ctl.py", line 110, in main
2024-10-25 11:23:26.483 :: 2024-10-25 11:23:25.919 ::     ret = CraftCtl.run(cmd, args)
2024-10-25 11:23:26.483 :: 2024-10-25 11:23:25.919 ::   File "/snap/charmcraft/current/lib/python3.10/site-packages/craft_parts/ctl.py", line 44, in run
2024-10-25 11:23:26.483 :: 2024-10-25 11:23:25.919 ::     _client(cmd, args)
2024-10-25 11:23:26.483 :: 2024-10-25 11:23:25.919 ::   File "/snap/charmcraft/current/lib/python3.10/site-packages/craft_parts/ctl.py", line 97, in _client
2024-10-25 11:23:26.483 :: 2024-10-25 11:23:25.919 ::     raise RuntimeError(message)

@Batalex Batalex self-assigned this Oct 25, 2024
- rustc
- cargo
override-build: |
rustup default stable
Copy link
Contributor Author

Choose a reason for hiding this comment

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

With this, we can drop the constraint on rdps-py in pyproject.toml, courtesy of the sql team 💯

set_env =
PYTHONPATH = {tox_root}/lib:{[vars]src_path}
UV_PROJECT_ENVIRONMENT={work_dir}/{env_name}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

uv chose to not treat VIRTUAL_ENV as the active environment. This var setup force uv to respect the "tox way" of creating a different venv for each command.
Without it, .venv would be overwritten on each tox invocation

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

Successfully merging this pull request may close these issues.

1 participant