mtkennerly / poetry-dynamic-versioning

Plugin for Poetry to enable dynamic versioning based on VCS tags
MIT License
606 stars 35 forks source link

Version changed to something like "0.0.1-post.120+c5d6581" every time project is opened in PyCharm #71

Closed danhje closed 2 years ago

danhje commented 2 years ago

Starting a few weeks ago, simply opening any project with dynamic versioning in PyCharm causes the version number to changed in pyproject.toml and init.py, and enable is set to false in the config, and the changes never get reverted. This started before PyCharm added poetry-support. Any idea what is causing this?

mtkennerly commented 2 years ago

I don't use PyCharm, but I just did a fresh install of it, and I wasn't able to reproduce this issue. I opened a project in PyCharm, then entered the Poetry executable location when prompted, but I didn't see a change in the files.

Here's my environment:

Could you share your environment? Do you have any additional PyCharm plugins that might affect this?

danhje commented 2 years ago

How do I get the version of poetry-dynamic-versioning?

A few colleges have the same issue, and they have pretty much an identical environment.

I've noticed that it doesn't always happen. I'll see if I can spot any patterns, and report back.

mtkennerly commented 2 years ago

You can check the plugin version in the output from pip list.

mtkennerly commented 2 years ago

I can partially reproduce this in a Linux VM.

When I initially imported the project, I saw the changes appear, and they were reverted when I closed PyCharm. Each time I reopened PyCharm after that, I saw the changes appear twice, for about half a second each time, and then they were automatically reverted while PyCharm was still running. This behavior would make sense if PyCharm is running the Poetry CLI, for example.

However, I didn't see the changes get stuck like you mentioned. I'm not sure why that's behaving differently; my best guess would be if PyCharm were running/importing Poetry and then killing a process abruptly so that the plugin couldn't clean up after itself. I also don't know why it would behave differently on Windows; that's hard to say without knowledge of PyCharm's internals.

mtkennerly commented 2 years ago

Did some more testing (Linux, PyCharm Community 2022.1.1, Poetry 1.1.13, poetry-dynamic-versioning 0.17.0). When I open poetry-dynamic-versioning/tests/project in PyCharm, there's a lot of back and forth:

$ tail -n 25 -F pyproject.toml | grep 'version ='
version = "0.0.999"
tail: pyproject.toml: file truncated
version = "0.17.0"
tail: pyproject.toml: file truncated
version = "0.0.999"
tail: pyproject.toml: file truncated
version = "0.17.0"
tail: pyproject.toml: file truncated
version = "0.17.0"
tail: pyproject.toml: file truncated
version = "0.0.999"
tail: pyproject.toml: file truncated
version = "0.17.0"
tail: pyproject.toml: file truncated
version = "0.0.999"

The exact sequence is different sometimes, but I still haven't seen it leave the dynamic version in the file.

If someone can help to define some minimum steps to reproduce the behavior and confirm that it's still an issue, then I can investigate further, but for now, I'm going to close this.

For my testing, I've used the following Vagrantfile:

Vagrant.configure("2") do |config|
  config.vm.box = "ubuntu/focal64"
  config.vm.network "public_network"
  config.vm.provider "virtualbox" do |vb|
    vb.gui = true
    vb.memory = 4096
  end

  config.vm.provision "shell", inline: <<-SHELL
    sudo apt-get update
    sudo apt-get install -y ubuntu-desktop python3-pip
  SHELL
end

I have this box locally:

$ vagrant box list
ubuntu/focal64 (virtualbox, 20211026.0.0)

In the VM, I ran:

startx
pip3 install poetry
pip3 install poetry-dynamic-versioning
git clone https://github.com/mtkennerly/poetry-dynamic-versioning.git
cd poetry-dynamic-versioning/tests/project
python3 -m poetry config virtualenvs.in-project true
python3 -m poetry install

And then I opened ~/poetry-dynamic-versioning/tests/project in PyCharm.

caniko commented 10 months ago

I also have this issue.

danhje commented 10 months ago

I haven't had any similar problems for months, and I work with multiple projects that use poetry-dynamic-versioning in PyCharm daily. No idea what fixed it, unfortunately.

caniko commented 10 months ago

OK, it happened when I did poetry update @mtkennerly. Please re-open.

mtkennerly commented 9 months ago

@caniko I just tried testing this again, and I still see it revert the changes when it's done, even if I run poetry update while pyproject.toml is open in PyCharm :/

By any chance, do you have file substitutions configured for pyproject.toml? There was a bug fixed in v1.1.1 regarding that.