PyPI push memo

A Python package hosting hub that can be installed with pip install. The reading is pie pie.

Version setting

Both pypi.org and test.pypi.org cannot be overwritten by uploading the same name (version) (index is independent). If you want to update / fix, upgrade the version.

0.1.0-alpha < 0.1.0-alpha1 < 0.1.0-beta < 0.1.0-beta1 < 0.1.0 < 0.1.1

Directory structure (example)

File example

__init__.py

from .YOUR_SCRIPT import *

Usage example after install

import PACKAGE_NAME as PKG

PKG.some_function() # defined in YOUR_SCRIPT.py

Create setup.py

setup.py

from setuptools import setup

setup(
    name='PACKAGE_NAME',
    version='0.1.0-alpha', # == 0.1.0-alpha0 == 0.1.0a0
    license='MIT',

    packages=[ 'YOUR_PACKAGE_NAME', ],

    install_requires=[
        # Example
        'Pillow',
        'opencv-python',
        'numpy',
    ],

    author='YOUR_NAME',
    author_email='YOUR_EMAIL',

    url='YOUR_WEBSITE_OR_REPOSITORY_URL',

    description='SHORT_DESCRIPTION',

    classifiers=[
        'Development Status :: 3 - Alpha',
        'License :: OSI Approved :: MIT License',
        'Programming Language :: Python',
        'Programming Language :: Python :: 3',
        'Programming Language :: Python :: 3.6',
        'Programming Language :: Python :: 3.7',
    ],
)

--For the classifiers section, copy and paste the applicable one from Classifiers · PyPI.

Pre-setup

pip3 install wheel twine

--wheel: wheel packaging --tine: PyPI tool

Packaging

python3 setup.py sdist
python3 setup.py sdist bdist_wheel

Experimental upload (installation test)

You can use https://test.pypi.org/ for experimental uploads, which behaves like pypi.org. The account is independent from pypi.org, [this article](https://qiita.com/shinichi-takii/items/e90dcf7550ef13b047b5#pypi%E3%82%A2%E3%82%AB%E3%82 % A6% E3% 83% B3% E3% 83% 88% E7% 99% BB% E9% 8C% B2) It seems that you should not make a mistake if you change the account name as recommended.

As mentioned above, once uploaded, the same PyPI repository cannot be overwritten (with the same version), so be careful about the version setting.

#For specific sdist only
twine upload --repository testpypi dist/YOUR_PACKAGE.tar.gz

#All files under dist
twine upload --repository testpypi dist/*

Production upload

#For specific sdist only
twine upload --repository pypi dist/YOUR_PACKAGE.tar.gz

#All files under dist
twine upload --repository pypi dist/*

Install from git repository

You can install it from GitHub, GitLab repositories, or local git repositories without pushing to PyPI. The directory structure is the same as when pushing to PyPI.

pip3 install git+https://github.com/USERNAME/REPOSITORY
pip3 install git+ssh://github.com/USERNAME/REPOSITORY
pip3 install git+file:///home/USER/REPOSITORY

It seems that you can also specify the branch and commit hash (see the official documentation above for details).

reference

-PyPI package publishing procedure --Qiita

Recommended Posts

PyPI push memo
gzip memo
Raspberry-pi memo
Pandas memo
HackerRank memo
Python memo
python memo
graphene memo
Flask memo
pyenv memo
Matplotlib memo
pytest memo
sed memo
Python memo
Install Memo
PyPI registration
BeautifulSoup4 memo
networkx memo
python memo
tomcat memo
command memo
Generator memo.
psycopg2 memo
Python memo
SSH memo
Command memo
Memo: rtl8812
pandas memo
Shell memo
Python memo
Pycharm memo
Python memo
A memo created in a package and registered in PyPI