SetUp untuk upload package di pypi

setup.py

import pathlib
import setuptools

setuptools.setup(
    name="latestearthquake",
    version="0.0.1",
        author="",
    author_email="",
    description="This package will get the latest earthquake from BMKG",
    long_description=pathlib.Path("README.md").read_text(),
    long_description_content_type="text/markdown",
    url="https://github.com/teolloDEV/Indonesia-last-earthquake",
    license = "The Unlicense",
    project_urls={
        "Website": "",
    },
    classifiers=[
        "Programming Language :: Python :: 3",
        "License :: OSI Approved :: GNU General Public License v3 (GPLv3)",
        "Operating System :: OS Independent",
        "Development Status :: 5 - Production/Stable",
    ],
    # package_dir={"": "src"},
    # packages=setuptools.find_packages(where="src"),
    packages=setuptools.find_packages(),
    install_requires=[
        '',

    ],
    python_requires=">=3.8",


)

Generating Distribution Archive


python3 -m pip install --upgrade build

python3 -m build
dist/
├── example_package_YOUR_USERNAME_HERE-0.0.1-py3-none-any.whl
└── example_package_YOUR_USERNAME_HERE-0.0.1.tar.gz

Gunakan token API


  • SetUp nano ~/.pypirc

[pypi]

username = __token__
password = [token API Key]

Uploading the distribution archives


python3 -m pip install --upgrade twine

python3 -m twine upload --repository pypi dist/*

Update


  • Build Paket : python setup.py sdist bdist_wheel
  • Upload : twine upload dist/*

Automation

Linux

  • deploy.sh

Berikan izin eksekusi pada deploy.sh jika belum memiliki izin

chmod +x deploy.sh

#!/bin/bash

rm -rf dist

python3 -m build

python3 -m twine upload --repository pypi dist/*

  • run

./deploy.sh

Windows

deploy.bat

@echo off

rmdir dist /S /Q

python3 -m build
python3 -m twine upload --repository pypi dist*/

  • run
deploy.bat