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

Running poetry shell writes version information #30

Closed
max-sixty opened this issue Nov 16, 2020 · 11 comments
Closed

Running poetry shell writes version information #30

max-sixty opened this issue Nov 16, 2020 · 11 comments
Labels
bug Something isn't working
Milestone

Comments

@max-sixty
Copy link

max-sixty commented Nov 16, 2020

The library is working really well — thanks again.

One issue we've been having recently is when running poetry shell, the __version__ gets written and not reverted. So on a clean repo, running poetry shell generates this diff:

diff --git a/foo/__init__.py b/foo/__init__.py
index 3c2d2ec..cca5dcb 100644
--- a/foo/__init__.py
+++ b/foo/__init__.py
@@ -7,7 +7,7 @@

 # Placeholder as specified in
 # https://github.com/mtkennerly/poetry-dynamic-versioning#installation
-__version__ = "0.0.0"
+__version__ = "0.2.1.post23.dev0+a5da3b3"

 import logging

diff --git a/pyproject.toml b/pyproject.toml
index ed9fbca..5af214a 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -4,7 +4,7 @@ build-backend = "poetry.masonry.api"

 [tool.poetry]
 name = "foo"
-version = "0.2.0"
+version = "0.2.1.post23.dev0+a5da3b3"

Is there something I'm doing wrong?

@mtkennerly mtkennerly added the bug Something isn't working label Nov 16, 2020
@mtkennerly
Copy link
Owner

I'll check this out - it sounds like a defect. I'm guessing we need a special case for it like we have for poetry run.

@mtkennerly
Copy link
Owner

This is now fixed in v0.11.0 🎉

@max-sixty
Copy link
Author

Thanks @mtkennerly !

@max-sixty
Copy link
Author

Unfortunately I'm not sure it's fully fixed.

Unless I'm doing something wrong? Let me know if I can help with supplying a reproduction

$ pip show poetry-dynamic-versioning
Name: poetry-dynamic-versioning
Version: 0.11.0
Summary: Plugin for Poetry to enable dynamic versioning based on VCS tags
Home-page: https://github.com/mtkennerly/poetry-dynamic-versioning
Author: Matthew T. Kennerly
Author-email: mtkennerly@gmail.com
License: MIT
Location: /Users/maximilian/Library/Caches/pypoetry/virtualenvs/foo-cyukv0jK-py3.8/lib/python3.8/site-packages
Requires: dunamai, jinja2, tomlkit
Required-by:


$ git diff

foo/__init__.py
─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────

 7  ⋮ 7  │
 8  ⋮ 8  │# Placeholder as specified in
 9  ⋮ 9  │# https://github.com/mtkennerly/poetry-dynamic-versioning#installation
 10 ⋮    │__version__ = "0.0.0"
    ⋮ 10 │__version__ = "0.2.3.post8.dev0+98869df"
 11 ⋮ 11 │
 12 ⋮ 12 │import logging
 13 ⋮ 13 │

pyproject.toml
─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────

─────────────────────────────────────┐
build-backend = "poetry.masonry.api" │
─────────────────────────────────────┘
 4  ⋮ 4  │
 5  ⋮ 5  │[tool.poetry]
 6  ⋮ 6  │name = "foo"
 7  ⋮    │version = "0.2.0"
    ⋮ 7  │version = "0.2.3.post8.dev0+98869df"

@mtkennerly
Copy link
Owner

mtkennerly commented Nov 23, 2020

Hmm, could you please tell me your:

  • OS
  • Shell
  • Poetry version
  • Python version

I can't reproduce it with Windows 10, Git Bash, Poetry 1.0.10, and Python 3.7.0.

@max-sixty
Copy link
Author

For sure — I'm on

  • MacOS: 10.15.7 (19H15)
  • Shell: fish (have also tried with bash)
  • Poetry version 1.1.4
  • Python 3.9.0
$ poetry debug info

Poetry
Version: 1.1.4
Python:  3.9.0

Virtualenv
Python:         3.8.6
Implementation: CPython
Path:           /Users/maximilian/Library/Caches/pypoetry/virtualenvs/foo-cyukv0jK-py3.8
Valid:          True

System
Platform: darwin
OS:       posix
Python:   /usr/local/opt/python@3.8/bin/../Frameworks/Python.framework/Versions/3.8

@max-sixty
Copy link
Author

Ah, I have an idea — when running poetry shell and then exiting, it cleans up. Is that what you can repro?

But that's not really what we want — people are running poetry shell and then doing their work in that. So we actually want to clean up after finishing the poetry shell command, not upon exiting the shell. (or maybe not running the versioning command on poetry shell at all).

Does that make sense? Also possible I misunderstanding other constraints of the problem.

Thanks as ever for you patience @mtkennerly ...

@mtkennerly
Copy link
Owner

Thanks for the info :) For me, it cleans up even before exiting:

$ poetry shell
Spawning shell within C:\GitHub\mtkennerly\poetry-dynamic-versioning\tests\
project\.venv

$ git status
On branch master
Your branch is up to date with 'origin/master'.

nothing to commit, working tree clean

$ exit
exit

$ git status
On branch master
Your branch is up to date with 'origin/master'.

nothing to commit, working tree clean

I updated to Poetry 1.1.4, and it still works for me, so that's not the reason it's acting differently. I'll try adding some more variations to the test matrix (especially Mac and Python 3.9) to see if I can narrow down the issue.

@mtkennerly mtkennerly reopened this Dec 1, 2020
@max-sixty
Copy link
Author

OK, let me check whether there's something else going on with my system...

@max-sixty
Copy link
Author

OK so I think this was caused by a file somehow being left over in /Users/maximilian/Library/Python/3.7/lib/python/site-packages/zzz_poetry_dynamic_versioning.pth, which may have been an old version. I'm not sure how this was there (running pip list didn't pick up poetry_dynamic_versioning). I'm also not 100% sure this was the cause, as I tried a bunch of stuff.

But it now works! Thanks again for your help and patience

@mtkennerly
Copy link
Owner

Oh, weird. Well, I'm glad it's working now :D Definitely let me know if you run into any problems like that again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants