-
Notifications
You must be signed in to change notification settings - Fork 16.6k
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
infra: migrate to uv #29566
infra: migrate to uv #29566
Conversation
This reverts commit 7a8d558.
# Conflicts: # libs/community/extended_testing_deps.txt
poetry run pip install dist/*.whl | ||
VIRTUAL_ENV=.venv uv pip install dist/*.whl |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As a minor note, we should detect .venv
as the target automatically here
e.g.
❯ uv venv
Using CPython 3.12.6
Creating virtual environment at: .venv
Activate with: source .venv/bin/activate
❯ uv pip install anyio
Resolved 4 packages in 85ms
Installed 4 packages in 4ms
+ anyio==4.8.0
+ idna==3.10
+ sniffio==1.3.1
+ typing-extensions==4.12.2
❯ ls .venv/lib/python3.12/site-packages
__pycache__ anyio-4.8.0.dist-info sniffio-1.3.1.dist-info
_virtualenv.pth idna typing_extensions-4.12.2.dist-info
_virtualenv.py idna-3.10.dist-info typing_extensions.py
anyio sniffio
Not that it's bad to be explicit — otherwise another VIRTUAL_ENV
could overlap.
The following is also valid, if you prefer
uv pip install -p .venv ...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ccurme weren't you running into some issues here where it was using some global context instead of the local install here, requiring the added environment variable specification?
I might be remembering wrong
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think astral-sh/setup-uv
may activate a virtual environment by default, which would cause that behavior and be a bit annoying in this context — if that's the case I can look into changing that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤦♂️ didn't hit submit yesterday - will go through and resolve things we talked about async
@@ -0,0 +1,23 @@ | |||
# TODO: https://docs.astral.sh/uv/guides/integration/github/#caching |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume this interacts ok with python-version
but that would be main suspect if things go wrong with enable-cache: true
@@ -304,7 +307,7 @@ def _get_configs_for_multi_dirs( | |||
f"Unknown lib: {file}. check_diff.py likely needs " | |||
"an update for this new library!" | |||
) | |||
elif file.startswith("docs/") or file in ["pyproject.toml", "poetry.lock"]: # docs or root poetry files | |||
elif file.startswith("docs/") or file in ["pyproject.toml", "uv.lock"]: # docs or root uv files |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
might be worth adding a lint case that confirms there are no poetry.lock files in the tree
dependencies = toml_data["project"]["dependencies"] | ||
for dep_version in dependencies: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what changed here? why isn't it iterating over the keys anymore?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dependencies
is no longer a dict matching dependency names to version constraints / markers etc. It is a list of dependency specifier strings.
@@ -87,21 +63,12 @@ jobs: | |||
if: ${{ ! startsWith(inputs.working-directory, 'libs/partners/') }} | |||
working-directory: ${{ inputs.working-directory }} | |||
run: | | |||
poetry install --with test | |||
uv sync --group test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
technically I think this is a functional change because this will remove lint/typing deps, whereas poetry install (without --sync
) would only add deps, and not remove anything
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated in 06b99bd
@@ -184,13 +188,11 @@ jobs: | |||
# - The package is published, and it breaks on the missing dependency when | |||
# used in the real world. | |||
|
|||
- name: Set up Python + Poetry ${{ env.POETRY_VERSION }} | |||
uses: "./.github/actions/poetry_setup" | |||
- name: Set up Python + uv |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
uv versioning maybe worth declaring - but assume different based on frozen thing
|
||
- name: Import test dependencies | ||
run: poetry install --with test --no-root | ||
run: uv sync --group test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This might reinstall the "current project" which we don't want - we want to install the built wheel we're testing. That's what --no-root
was handling
happy to discuss this one
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed, you probably want uv sync --inexact --only-group test
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But the subsequent step does say
Overwrite the local version of the package with the built version
which would replace it.
You probably want to skip the project dependencies regardless to ensure the wheel isn't missing declaration of any dependencies?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This workflow has
uv pip install dist/*.whl
make tests <-- basically uv run --group test pytest ...
As I understand it the problem is that make tests
will replace the wheel install with the local project.
In 8b8678f I set UV_NO_SYNC=true
. Let me know if this isn't sufficient.
>>> uv pip install dist/*.whl
>>> uv pip freeze | grep langchain
langchain @ file:///.../libs/langchain/dist/langchain-0.3.18-py3-none-any.whl
>>> make tests
>>> uv pip freeze | grep langchain
-e file:///Users/chestercurme/repos/langchain/libs/langchain
^ If I set UV_NO_SYNC=true
, I get the wheel install in the second pip freeze.
poetry run pip install dist/*.whl | ||
VIRTUAL_ENV=.venv uv pip install dist/*.whl |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ccurme weren't you running into some issues here where it was using some global context instead of the local install here, requiring the added environment variable specification?
I might be remembering wrong
No description provided.