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

Expand environment variables in URLs #640

Merged
merged 1 commit into from
Dec 14, 2023
Merged

Expand environment variables in URLs #640

merged 1 commit into from
Dec 14, 2023

Conversation

charliermarsh
Copy link
Member

Summary

This PR enables users to express relative dependencies via environment variables. Like pip, PDM, Hatch, Rye, and others, we now allow users to express dependencies like:

flask @ file://${PROJECT_ROOT}/flask-3.0.0-py3-none-any.whl

In the compiled requirements file, we'll also preserve the unexpanded environment variable.

Closes #592.

Comment on lines +109 to +110
std::env::var(name).unwrap_or_else(|_| match name {
"PROJECT_ROOT" => PROJECT_ROOT_FRAGMENT.clone(),
Copy link
Member

Choose a reason for hiding this comment

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

Is it intentional that PROJECT_ROOT defined in the user env takes precedence over `PROJECT_ROOT?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah

@charliermarsh charliermarsh force-pushed the charlie/relative branch 2 times, most recently from 098f220 to 2d86a8c Compare December 14, 2023 14:59
Base automatically changed from charlie/relative to main December 14, 2023 15:03
@charliermarsh charliermarsh enabled auto-merge (squash) December 14, 2023 15:05
@charliermarsh charliermarsh merged commit 22c7057 into main Dec 14, 2023
3 checks passed
@charliermarsh charliermarsh deleted the charlie/env-var branch December 14, 2023 15:09
@alelavelli
Copy link

How it is possible to dynamically read the local package content like in poetry with my-local-package = { path = "local/package/path", develop = true }?

Because for now, the only solution I found is to recompile the pypropject.toml with --refresh-package my-local-packageand then reinstall it

@charliermarsh
Copy link
Member Author

@alelavelli -- Are you looking for uv pip install -e ./local/package/path?

@alelavelli
Copy link

alelavelli commented Mar 12, 2024

@charliermarsh

Yes but directly from the pyproject.toml. Something like poetry:

[tool.poetry.dependencies]
my-local-package = {path = "../my-local-package", develop = true}

but with uv, like this:
[project]
dependencies = [
"my-package @ file:/path/to/my/package" # with something to say -e
]

@charliermarsh
Copy link
Member Author

Unfortunately I think it's not possible in pyproject.toml, because it's just not part of the standard PEP 508 specification.

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.

Expand environment variables when resolving URLs
3 participants