'Disable publishing to PyPi with poetry
I am a setting up Poetry in combination with Tox to automate builds and testing. The project I am working on however is private and I want to avoid anyone working on it accidentally publishing it to PyPi. I have initialized a project using poetry init and my assumption is that the resulting setup does not result in a viable package that can be published without any further setup to begin with. Is this correct?
How could I further configure poetry so that even if someone accidentally runs poetry publish in the future the package will not actually be published.
Solution 1:[1]
As I know poetry does not support such straightforward option yet. But the workaround is possible:
[tool.poetry]
exclude = ["**"]
In TOML format: * denotes a single level wildcard, and ** denotes all files in the given directory hierarchy.
exclude = ["**"] option prevents project files from getting into the package when poetry build is executed. It will show:
[ModuleOrPackageNotFound]
No file/folder found for package package_name
But nevertheless, poetry will create a tar.gz file and include three files in it: pyproject.toml, setup.py, and PKG-INFO. And it can be published
Solution 2:[2]
Another option seems to be adding "Private :: Do not Upload" to classifiers in pyproject.toml.
[tool.poetry]
classifiers = ["Private :: Do not Upload"]
https://github.com/python-poetry/poetry/issues/3692#issuecomment-789346308
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | |
| Solution 2 | user9538 |
