The method of publishing modules to PyPI has changed a lot before I saw it for a while, so I will write it down as a memorandum.
it's here.
So far, GitHub is the only document that can be called a document.
setup.cfg
When I used to touch PyPI, I used to write various settings in setup.py
to describe the module settings, but now I put the module information in a file called setup.cfg
. It seems that I started writing.
setup.cfg
[metadata]
name = tksugar
version = attr: tksugar.__version__
author = TakamiChie
author_email = [mail]
license = MIT
description = A module that generates a structured Tk window frame from a text file.
keywords =
url = https://github.com/TakamiChie/TkSugar
long_description = file: README.md
long_description_content_type = text/markdown
classifiers =
Programming Language :: Python :: 3.7
Programming Language :: Python :: 3.8
[options]
packages = find:
install_requires =
pyyaml
For the time being, I'm curious about this matter.
version
In advance, add the following constants to the __init__.py
of the module to be uploaded.
__init__.py
__version__ = "0.1.0"
In my case, __init __. Py
was placed in root \ tksugar \ __ init __. Py
, so I'm okay with the above description, but I want to create a file called __VERSION__.py
and define it there. Note that the above will change depending on whether you want to use root / src / project / __ init__.py
.
long_description It is a long explanation that is literally long to read. README.md is read and displayed as it is. This text will appear on the right side of the PyPI.org site.
In case of Markdown format, be sure to describe it as a set with long_description_content_type
. It will stop with an error.
classifiers This is a classification on the PyPI site. It looks like an ini file, but you can write one per line. Please check the PyPI site for the contents of the classification.
install_requires
The writing method is the same as classifiers. The above statement is equivalent to pyyaml =" * "
in Pipfile
.
.pypirc
. For Windows 10 Save to the C: \ Users \ [UserName]
folderpip install twine wheel
(I might have been doing other things because I was struggling a lot)python setup.py sdist bdist_wheel
twine upload --repository testpypi dist / *
twine upload --repository pypi dist / *
It is easy to write the following code in Pipfile
(The content of Reference 6 is not Windows, so modify it appropriately / pipenv run
seems to work at the command prompt instead of PowerShell, so it is appropriate Adjustment)
Pipfile
[scripts]
clear = "pwsh -c Remove-Item -Recurse -Force *.egg-info, build, dist"
build = "python setup.py sdist bdist_wheel"
deploytest = "twine upload --repository testpypi dist/*"
deploy = "twine upload --repository pypi dist/*"
This kind of operation method changes quite often, so when you google, take measures such as setting the period designation to "within one month". If the article is more than half a year old, the content may have changed somewhere (although the previous article may be helpful for the content of the description).
Recommended Posts