uv icon indicating copy to clipboard operation
uv copied to clipboard

Keep editable "." install when locking and syncing

Open PetterS opened this issue 1 year ago • 10 comments

I saw a few other issues tagged with question, so I thought it could be OK so a ask one like this.

I have a codebase with some dependencies and some code. I would like to create a venv where all of that is available.

So far uv works if I do this:

uv pip compile pyproject.toml -o requirements.txt
...
uv pip sync requirements.txt
uv pip install -e .

I would like to not have to run the last command after every sync. How can I somehow specify the editable install of the current project in pyproject?

  • In poetry, I used a packages key under [tool.poetry] but that is obviously not going to work here.
  • Adding "myproject @ ." as a dependency results in a relative path without a working directory: . message from uv

PS the speed of uv looks absolutely fantastic!

PetterS avatar Feb 18 '24 06:02 PetterS

👋 It looks like you're looking for the behavior described in

  • https://github.com/astral-sh/uv/pull/1000

Let me know if that works for you!

zanieb avatar Feb 18 '24 08:02 zanieb

You mean a dependency like "my-project @ file://."? That also gives the "relative path without a working directory" error

PetterS avatar Feb 18 '24 09:02 PetterS

Can you share the full output with the -v flag?

zanieb avatar Feb 18 '24 17:02 zanieb

It’s possible that we parse pyproject.toml without passing the relative dir down. I can take a look this week to understand what the correct behavior is and whether we’re matching it.

charliermarsh avatar Feb 18 '24 17:02 charliermarsh

One option is that you should be able to do my-project @ file://${PROJECT_ROOT}. Do you mind trying that?

charliermarsh avatar Feb 20 '24 02:02 charliermarsh

my-project @ file://${PROJECT_ROOT}

I then get error: my-project 1 depends on itself

PetterS avatar Feb 20 '24 18:02 PetterS

my-project @ file://${PROJECT_ROOT}

I then get error: my-project 1 depends on itself

Update: that worked when I installed the latest version of uv. Great!

PetterS avatar Feb 20 '24 19:02 PetterS

One option is that you should be able to do my-project @ file://${PROJECT_ROOT}. Do you mind trying that?

Hello! ''my-sub-project @ file://${PROJECT_ROOT}/../relative/path#egg=sub_package'' worked, but only halfway: error: Distribution not found at: file:///resolved/path%23egg=sub_package

serjflint avatar Feb 20 '24 21:02 serjflint

Hi, I am trying out something similar, using ${PROJECT_ROOT} does work but when we have chain of libraries, it doesn't compile, it take relative path of my current project directly even of dependent libraries.

https://stackoverflow.com/questions/78042589/pip-requirements-for-relative-packages

debugger24 avatar Feb 22 '24 19:02 debugger24

I think we intentionally don't allow relative paths in pyproject.toml because it's not part of the PEP standard, and that file needs to follow standards, whereas requirements.txt is not standardized and already does a few things that don't adhere to them.

charliermarsh avatar Mar 08 '24 20:03 charliermarsh

my-project @ file://${PROJECT_ROOT} does not install my-project as editable in 0.1.24. It makes a copy. In fact, it seems difficult to ever upgrade it without deleting the .venv. pip compile and pip sync does not change anything

The local project is copied into .venv/lib/python3.10/site-packages and then never changed

PetterS avatar Mar 23 '24 09:03 PetterS

You need to install with -e in order to install as editable. For example, “uv pip install -e .”

charliermarsh avatar Mar 23 '24 12:03 charliermarsh

Yes, that works. Would be nice to somehow specify that the project itself should be installed editable. But maybe the pyproject syntax does not allow this

PetterS avatar Mar 23 '24 21:03 PetterS