[PYTHON] Note that the method of publishing modules to PyPI has changed in various ways.

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.

What did you publish?

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.

upload

  1. Follow the reference article 6 and create .pypirc. For Windows 10 Save to the C: \ Users \ [UserName] folder
  2. pip install twine wheel (I might have been doing other things because I was struggling a lot)
  3. python setup.py sdist bdist_wheel
  4. twine upload --repository testpypi dist / *
  5. If there is no problem, 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/*"

important point

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).

image.png

References

  1. Summary of python setup \ .py -Qiita
  2. [[Tech way from one step] 21st "Write setup \ .py and make it installable with pip" -Sansan Builders Blog](https://buildersbox.corp-sansan.com/entry/ 2019/07/11/110000)
  3. Manage the contents of Python setup \ .py with setup \ .cfg -astropenguin
  4. PyPI registration procedure for those who want to make a PyPI debut -Qiita
  5. \ _ \ _ version \ _ \ _ traps and best practices -Qiita
  6. Settings when uploading Python packages to PyPI locally -Qiita

Recommended Posts

Note that the method of publishing modules to PyPI has changed in various ways.
Note that the latest link of ius has changed
Note that the latest link of ius has changed
Note that the method of publishing modules to PyPI has changed in various ways.
Note that the Pandas loc specifications have changed
Code that sets the default value in case of AttributeError
Various ways to read the last line of a csv file in Python
Various ways to calculate the similarity between data in python
Various ways to create an array of numbers from 1 to 10 in Python.
[python] A note that started to understand the behavior of matplotlib.pyplot
The usage of TensorBoard has changed slightly
Various comments to write in the program
A solution to the problem that the Python version in Conda cannot be changed
Try to display the Fibonacci sequence in various languages in the name of algorithm practice
How to find the coefficient of the trendline that passes through the vertices in Python
3 ways to parse time strings in python [Note]
Note that the Pandas loc specifications have changed
To dynamically replace the next method in python
[Note] About the role of underscore "_" in Python
Easy way to check the source of Python modules
Numerical representation of days of the week in various languages
Various ways to extract columns in a NumPy array
How to get the number of digits in Python
Try to solve Sudoku in various ways (SAT, CSP)
Modules that may go through the shell in Python
To do the equivalent of Ruby's ObjectSpace._id2ref in Python
Python Note: The mystery of assigning a variable to a variable
Make a note of what you want to do in the future with Raspberry Pi
[Python] Programming to find the number of a in a character string that repeats a specified number of times.
[Note] A shell script that checks the CPU usage of a specific process in a while loop.