poetry: Don't publish if version already exists

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

Feature Request

Let’s say a package maintainer publishes version 1.5.0 of package foo. Later on, the maintainer decides to publish new changes but forgets to bump the package version. Now, mayhem and chaos ensue whilst the fabric of reality disintegrates from the epicenter of PyPI.

Ok, so maybe the fabric of reality wont disintegrate, but overwriting an existing package in a remote repo certainly isn’t desirable is most circumstances. Would it be possible to add a check/flag to poetry publish such that it errors if a version of a package already exists in a remote repo? Here are some possible API ideas:

Idea 1:

# Assume foo-1.5.0 already exists in the remote repo
poetry publish  # this will error if foo-1.5.0 is published 
poetry publish --force  # this will overwrite the existing foo-1.5.0

Idea 2:

# Assume foo-1.5.0 already exists in the remote repo
poetry publish  # this will overwrite the existing foo-1.5.0
poetry publish --check-existing  # this will error if foo-1.5.0 is published 

Idea 3:

# This lists all the existing versions of the package in the remote repo.
# Clients can then consume the output however they wish to determine if a version already exists.
# The `version` command admittedly may not be the best place for this new functionality, but it's just an example.
poetry version --list-remote

Idea 3 may be useful for reasons other than version checking.

Let me know if any of these ideas sound feasible and worthwhile. I’m happy to submit a PR.

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 3
  • Comments: 16 (3 by maintainers)

Most upvoted comments

It would still be nice to have a flag allowing to not fail if the version already exists. I have a use case where my CI run at each commit, even the “publish” step, and i was hoping that poetry would skip publish if version was not incremented from what is on PyPI.

Can this issue be reopened? Or should i open a new one?

Another use of flag such as --check-existing could be in CI pipelines. It could be used just as a automation step to remind about bumping the version before publishing.

If it were my place to decide, I would not change anything

Agreed. The status-quo appears to be that it’s on the onus of the repo to control overwrites. I’m fine if we close this issue, but other may have a different opinion.

It has already been done: #2812. You can try with poetry >= 1.2.0b2