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

Questions: Migrating from poetry #7245

Closed
EdgyEdgemond opened this issue Sep 10, 2024 · 5 comments
Closed

Questions: Migrating from poetry #7245

EdgyEdgemond opened this issue Sep 10, 2024 · 5 comments
Labels
question Asking for clarification or support

Comments

@EdgyEdgemond
Copy link

I came here looking for information on poetry env info but found another comment on a closed issue that covered a few other points. So I hijacked that comment.

Originally posted by @mikeleppane in #6668 (comment)

After using Poetry for years, I've decided to try uv. And it's great 👏. Here are some thoughts I had while using uv. Some of these may have been discussed already.

  • export only dev-dependencies from uv.lock to requirements-dev.txt (this is useful at least in the CI); poetry export --without-hashes --without-urls --only=dev -o requirements-dev.txt
  • uv sync/pip install only dev-dependencies (like above useful in the CI)
  • show the latest version but only for outdated packages; poetry show --outdated / poetry show --outdated --only=dev has been useful.
  • how do get info about the current virtual env? E.g. Poetry has poetry env info command to display info about current env
  • is it possible to only update dev-dependencies like poetry update --only=dev?

Thanks!

Originally posted by @mikeleppane in #6668 (comment)

@EdgyEdgemond
Copy link
Author

EdgyEdgemond commented Sep 10, 2024

to add to this, I can see how to do forks in resolving dependencies, and adding sources. Is the following case covered in uv currently?

 
[tool.poetry.dependencies]
torch = [
    { markers = "sys_platform == 'darwin' and platform_machine == 'arm64'", url = "https://download.pytorch.org/whl/cpu/torch-2.0.1-cp310-none-macosx_11_0_arm64.whl" },
    { markers = "sys_platform == 'darwin' and platform_machine == 'x86_64'", url = "https://download.pytorch.org/whl/cpu/torch-2.0.1-cp310-none-macosx_10_9_x86_64.whl" },
    { platform = "linux", version = "=2.0.1", source = "pytorch-cpu" },
]

[[tool.poetry.source]]
name = "pytorch-cpu"
url = "https://download.pytorch.org/whl/cpu"
priority = "explicit"

@charliermarsh
Copy link
Member

charliermarsh commented Sep 10, 2024

A lot of different questions here but I'll try to answer them:

export only dev-dependencies from uv.lock to requirements-dev.txt (this is useful at least in the CI); poetry export --without-hashes --without-urls --only=dev -o requirements-dev.txt

uv sync/pip install only dev-dependencies (like above useful in the CI)

These don't exist right now, see #6472.

show the latest version but only for outdated packages; poetry show --outdated / poetry show --outdated --only=dev has been useful.

--outdated isn't supported yet, see #2150.

how do get info about the current virtual env? E.g. Poetry has poetry env info command to display info about current env

We intentionally don't support using an arbitrary virtual environment for the uv "project" APIs (uv sync, uv lock, etc.), it also lives in .venv. What information would you want here?

is it possible to only update dev-dependencies like poetry update --only=dev?

Same thing, we don't support this kind of only-dev workflow right now.

to add to this, I can see how to do forks in resolving dependencies, and adding sources. Is the following case covered in uv currently?

You can accomplish this without tool.uv.sources, i.e., using only standards-compliant metadata, but tool.uv.sources doesn't support a list like that right now (see #3397):

[project]
dependencies = [
    "torch @ https://download.pytorch.org/whl/cpu/torch-2.0.1-cp310-none-macosx_11_0_arm64.whl ; sys_platform == 'darwin' and platform_machine == 'arm64'",
    "torch @ https://download.pytorch.org/whl/cpu/torch-2.0.1-cp310-none-macosx_10_9_x86_64.whl ; sys_platform == 'darwin' and platform_machine == 'x86_64'",
    "torch==2.0.1 ; sys_platform != 'darwin' or platform_machine != 'arm64' or platform_machine != 'x86_64'"
]

Then you'd set https://download.pytorch.org/whl/cpu as your extra-index-url.

That last feature (explicit pinning) is tracked in #171.

@charliermarsh charliermarsh added the question Asking for clarification or support label Sep 10, 2024
@EdgyEdgemond
Copy link
Author

EdgyEdgemond commented Sep 10, 2024

-edit- Just rereading your response, are you saying it always lives in .venv, if so I am happy to move forward with that assumption -/edit-

Thanks for the prompt response @charliermarsh

In terms of poetry env info it is used to determine where the venv is currently located (if in project, in a poetry directory etc.) So that the location can be used dynamically in a script without knowing what the current dev did in their poetry/uv setup etc.

This is the one that I am most interested in "location of current venv"

>> poetry env info -p
/home/edgy/code/test-uv/.venv

Example of full output

>> poetry env info

Virtualenv
Python:         3.12.4
Implementation: CPython
Path:           /home/edgy/code/test-uv/.venv
Executable:     /home/edgy/code/test-uv/.venv/bin/python
Valid:          True

Base
Platform:   linux
OS:         posix
Python:     3.12.4
Path:       /usr
Executable: /usr/bin/python3.12

@EdgyEdgemond
Copy link
Author

In terms of my torch question, it looks like find-links might have been what I was after. Have yet to confirm with a colleague on a mac that it is working, but the following #worksonmymachine and is a lot simpler.

dependencies = [
    "torch == 2.0.1+cpu",
]

[tool.uv]
find-links = ["https://download.pytorch.org/whl/torch_stable.html"]

@EdgyEdgemond
Copy link
Author

@mikeleppane some answers to some of your questions as well.

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

No branches or pull requests

2 participants