Record the process of making pypi package for the first time

Preparation

1. Create a project folder

mkdir dada_openapi_python
cd dada_openapi_python

2. Create package folder

A folder of dada open API client is being created in it. The name of this folder is intentionally different from that of the upper directory to avoid misunderstanding. This folder is actually the package name

mkdir dada_openapi_client
cd dada_openapi_client

3. Write package code

According to the respective business scenarios, here is a list of the
dada_client

Make PyPI package

Now that the project logic has been completed, the package of PyPI is started

1. Create the setup.py file

In the dada OpenAPI Python folder, create the configuration file setup.py, fill in the configuration, and paste my configuration below

#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time    : 2020/1/6 15:41
# @Author  : Weiqiang.long
# @Site    : 
# @File    : setup.py
# @Software: PyCharm
# @Description:

import setuptools

with open("README.md", "r", encoding="utf-8") as fh:
    long_description = fh.read()

setuptools.setup(
    name = "dada_openapi_client",
    version = "1.0.3",
    author = "Weiqiang.long",
    description = "Dada signature data encapsulation",
    long_description = long_description,
    long_description_content_type="text/markdown",
    url = "https://github.com/longweiqiang/dada_openapi_python",
    packages = setuptools.find_packages(),
    classifiers=[
        "Programming Language :: Python :: 3",
        "License :: OSI Approved :: MIT License",
        "Operating System :: OS Independent",
    ]

)

For the specific meaning of each field in the above configuration, please refer to Official website documents 2.8 of

Pack

Run this command in the dada OpenAPI Python folder

python setup.py sdist bdist_wheel

upload

python -m twine upload dist/*
  • Successfully uploaded as follows:
Uploading distributions to https://upload.pypi.org/legacy/
Uploading dada_openapi_client-1.0.3-py3-none-any.whl
100%|████████████████████████████████████████████████████
███████████████| 7.88k/7.88k [00:00<00:00, 10.6kB/s]
Uploading dada_openapi_client-1.0.3.tar.gz
100%|████████████████████████████████████████████████████
███████████████| 6.23k/6.23k [00:01<00:00, 4.43kB/s]

Possible problems

Upload failed (403): Invalid or non-existent authentication information.

Wrong user authentication information, you need to create a user authentication file ~ /. pypirc

Create user authentication file ~ /. pypirc

Create a new blank file named. pypirc in your own user directory. The content is as follows:

[distutils]index-servers=pypi

[pypi]repository = https://upload.pypi.org/legacy/
username = XXX
password = XXX

Upload failed (403): You are not allowed to edit 'xxx' package information

You need to register your package before you can start uploading

Server response (401): Incomplete registration; check your email

Your PyPI account hasn't completed the email verification yet. You need to register your email to find a verification email to complete the verification and then try the failed step again.

Server response (400): Invalid classifier "Topic :: Software Development :: Utilities"

The classifier information in your setup.py file is incorrect. Please press Official website The correct classification of writing classifier

error: No dist file created in earlier command

You started to upload the command before you packed it

Upload failed (400): File already exists

The file already exists. You should update the version number every time.

Reference documents:

https://packaging.python.org/tutorials/packaging-projects/
https://segmentfault.com/a/1190000008663126
http://xiaoh.me/2015/12/11/python-egg/

Tags: Python Pycharm encoding github

Posted on Tue, 07 Jan 2020 02:48:00 -0800 by jikishlove