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

Shifting dependency from remote git to local editable does not work #5743

Closed
2 of 3 tasks
dpompeu-xgeeks opened this issue Jun 1, 2022 · 7 comments
Closed
2 of 3 tasks
Labels
kind/bug Something isn't working as expected

Comments

@dpompeu-xgeeks
Copy link

dpompeu-xgeeks commented Jun 1, 2022

  • I am on the latest Poetry version.

  • I have searched the issues of this repo and believe that this is not a duplicate.

  • If an exception occurs when executing a command, I executed it again in debug mode (-vvv option).

  • OS: Windows 10 but using WSL with Ubuntu 20.04,4 LTS:

  • Poetry version: 1.1.3:

  • pyproject.toml file:

Issue

I have some libraries and applications: the applications import the libraries, which are hosted on git. While debugging a library, I'd like to use a local version temporarily in editable mode, such that I can quickly get the changes and test them.

However, this does not work as expected.

When shifting to files and develop and re-installing, poetry reads the new files and all the messages seem to indicate a successful change, but when running the application the changes are not there.

Strangely, changing from remote git to to local mode without the development flag, works as expected, but not really fit for my workflow.

Reproduction

$ poetry add git+ssh://[email protected]:dpompeu-xgeeks/example-lib.git#cad773cb633c3d8be5ddd16ef6767d5d0bc6e7cc
$ cat .venv/lib/python3.8/site-packages/mylib/mylib.py
$ poetry run python myapp.py
Hello World from git tag
$ echo 'print("Hello world from local dev")' > ../mylib/mylib/mylib.py
$ vim ../mylib/pyproject.toml # bump version (not sure if needed)
$ vim pyproject.toml # mylib = {path = "../mylib/", develop = true }
$ poetry lock; poetry install
Updating dependencies
Resolving dependencies... (0.1s)

Writing lock file
Installing dependencies from lock file

Package operations: 0 installs, 1 update, 0 removals

  • Updating mylib (0.1.1 -> 0.2.0 /home/dpompeu/dev/experiments/poetry-experiment/mylib)

Installing the current project: myapp (0.1.0)
$ poetry run python myapp.py 
Hello World from git tag # <----- no changes!
$ cat .venv/lib/python3.8/site-packages/mylib/mylib.py 
print("Hello World from git tag") # <---- no changes!

Removing the virtual env and re-installing:

$ rm -rf .venv/
$ poetry lock; poetry install
Creating virtualenv myapp in /home/dpompeu/dev/experiments/poetry-experiment/myapp/.venv
Updating dependencies
Resolving dependencies... (0.1s)
Installing dependencies from lock file

Package operations: 1 install, 0 updates, 0 removals

  • Installing mylib (0.2.0 /home/dpompeu/dev/experiments/poetry-experiment/mylib)

Installing the current project: myapp (0.1.0)
$ poetry run python myapp.py 
Hello world from local dev # <----- has changed!

Strangely, if we just shift from remote git to local (not editable) it works, but is not editable:

$ echo 'print("Hello world from local")' > ../mylib/mylib/mylib.py
$ vim ../mylib/pyproject.toml # bump version (not sure if needed)
$ vim pyproject.toml # mylib = {path = "../mylib/", develop = true }
$ poetry lock; poetry install
Updating dependencies
Resolving dependencies... (0.1s)

Writing lock file
Installing dependencies from lock file

Package operations: 0 installs, 1 update, 0 removals

  • Updating mylib (0.1.1 -> 0.2.0 /home/dpompeu/dev/experiments/poetry-experiment/mylib)

Installing the current project: myapp (0.1.0)
$ poetry run python myapp.py
Hello world from local # <----- has changed without additional steps!
@dpompeu-xgeeks dpompeu-xgeeks added kind/bug Something isn't working as expected status/triage This issue needs to be triaged labels Jun 1, 2022
@dpompeu-xgeeks
Copy link
Author

There are more issues related to local development, such as #2725, but I haven't found one matching my exact use case.

@dpompeu-xgeeks
Copy link
Author

I was suggested a workaround: remove the virtual environment and re-install. This works! I will definitely use it.

But still find it prone to errors:

  • Poetry's output indicates success, so those unaware of this issue this will face this pain every time
  • Even those who know about this can forget it on the 10th or 100th run

@abn
Copy link
Member

abn commented Jun 1, 2022

If you are still experiencing the issue with the latest code, I'd recommend you do the following.

  1. Create a minimal project that fails.
  2. Execute and post full output of poetry@git --no-cache install -vvv (or update as the case maybe). (preferrably in a gist, a collapsed block, or a pastebin). Ideally with the project.

Note: poetry@git assumes you installed poetry as mentioned below.

Install Poetry from VCS

pipx install --force --suffix=@git 'poetry @ git+https://github.com/python-poetry/poetry.git'

@dpompeu-xgeeks
Copy link
Author

Thanks for your support @abn, this worked as intended!

I'm still wondering if it's a result of the --no-cache, or from the bump from version 1.1 to 1.2. I'll need to explore that further, and will update the issue.

If it's still useful, I'll leave two gists below:

And the output from running the application:

# right after installing
$ poetry@git run python myapp.py 
Hello World from git tag

# change to local file and modify it
$ echo 'print("Hello world from local dev")' > ../my-lib/mylib/mylib.py
$ poetry@git run python myapp.py
Hello world from local dev # <--- working as intended!

# modify again
$ echo 'print("Hello world from local dev 2")' > ../mylib/mylib/mylib.py 
$ poetry@git run python myapp.py 
Hello world from local dev 2 # <--- working as intended!

@dpompeu-xgeeks
Copy link
Author

I see that --no-cache is is not available in poetry 1.1.

So I omitted that parameter in poetry 1.2 and things work as expected too!

$ poetryx install
Creating virtualenv myapp in /home/duarte/dev/experiments/xpoetry/myapp/.venv
Installing dependencies from lock file

Package operations: 1 install, 0 updates, 0 removals

  • Installing mylib (0.1.1 cad773c)

Installing the current project: myapp (0.1.0)
$ poetryx run python myapp.py 
Hello World from git tag # <--- original print, as intended

$ vim pyproject.toml 
$ cat pyproject.toml | grep mylib
mylib = {path = "../mylib", develop=true} 
$ vim pyproject.toml 
$ poetryx install
Installing dependencies from lock file
Warning: poetry.lock is not consistent with pyproject.toml. You may be getting improper dependencies. Run `poetry lock [--no-update]` to fix it.

Package operations: 0 installs, 1 update, 0 removals

  • Updating mylib (0.1.1 cad773c -> 0.1.1 /home/duarte/dev/experiments/xpoetry/mylib)

Installing the current project: myapp (0.1.0)
$ echo 'print("Hello world from local dev")' > ../mylib/mylib/mylib.py     
$ poetryx run python myapp.py 
Hello world from local dev # <--- changed as intended!

$ echo 'print("Hello world from local dev 2")' > ../mylib/mylib/mylib.py 
$ poetryx run python myapp.py  # <--- changed as intended!
Hello world from local dev 2

@dpompeu-xgeeks dpompeu-xgeeks mentioned this issue Jun 2, 2022
14 tasks
@dpompeu-xgeeks
Copy link
Author

I just installed 1.2.0 and it fixes this issue, so I'll close it.

@mkniewallner mkniewallner removed the status/triage This issue needs to be triaged label Sep 18, 2022
Copy link

github-actions bot commented Mar 1, 2024

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 1, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
kind/bug Something isn't working as expected
Projects
None yet
Development

No branches or pull requests

3 participants