Movatterモバイル変換


[0]ホーム

URL:


Skip to content
DEV Community
Log in Create account

DEV Community

Cover image for Python Checklist: Publishing a package to PyPi
Prahlad Yeri
Prahlad Yeri

Posted on • Edited on • Originally published atgithub.com

     

Python Checklist: Publishing a package to PyPi

(Originally published onhttps://github.com/prahladyeri/CuratedLists/)

Checklist: Publishing a package to PyPi

  1. Register an account onPyPi if you don't have one.
  2. Installsetuptools andtwine usingpip if they aren't already. Create asetup.py in your source folder as follows (check outsetuptools docs for more detailed setup options):

    # replace:# <your_package> with your actual package name.# <you> with your name.# <your_email> with your public email address.# <your_github_repo_url> with your github project's url.from setuptools import setup, find_packagess = setup(    name="<your_package>",    version="1.0.0",    license="MIT",    description="Foo App",    url='<your_github_repo_url>",    packages=find_packages(),    install_requires=[],    python_requires = ">= 3.4",    author="<you>",    author_email="<your_email>",    )
  3. Optional: Bump up the version number (and git commit) if this isn't your first release:

    git add . && git commit -m "chore: released 1.0.1" && git push
  4. Runpython setup.py sdist from your source folder to generate a source distribution.

  5. Optional: Sign the newly generated package with yourgpg signature:

    gpg -a --detach-sign dist/<your-package>-1.0.0.tar.gz
  6. Upload your package usingtwine:

    twine upload dist/<your-package>-1.0.0.tar.gz -u <your-pypi-username> -p <your-pypi-password>

    If you've signed the package, then you may also add the signed .asc file as the argument like this:

    twine upload dist/<your-package>-1.0.0.tar.gz dist/<your-package>-1.0.0.tar.gz.asc -u <your-pypi-username> -p <your-pypi-password>
  7. Visithttps://pypi.org/project/your_package to verify that your package has been uploaded.

  8. Runpip install <your_package> to verify the package installation using pip package manager.

  9. Optional: Tag the commit with the new version number:

    git tag "1.0.1"git push --tags

Top comments(5)

Subscribe
pic
Create template

Templates let you quickly answer FAQs or store snippets for re-use.

Dismiss
CollapseExpand
 
juancarlospaco profile image
Juan Carlos
.10x frAgile FullStuck Midend Devlooper, Python, Nim, Arch, OpenSource, EN|ES, Argentina, UTC-3, Atheist, WFH Nim Team Leader
• Edited on• Edited

No no, yoursetup.py should be empty,use CFG.

CollapseExpand
 
xowap profile image
Rémy 🤖
I spent my adolescence in Dreamweaver, my student years in Vim and my adult life in PyCharm.
  • Location
    Madrid
  • Education
    Telecommunications Engineer
  • Work
    CTO at WITH Madrid
  • Joined

How would you test against the staging pypi repo before?

CollapseExpand
 
prahladyeri profile image
Prahlad Yeri
Just another humble techie.
  • Email
  • Location
    India
  • Education
    MCA, MA (Econ)
  • Pronouns
    He/Him
  • Work
    Programmer at Freelance
  • Joined
• Edited on• Edited

Thetwine project is considering to add a--dry-run mode or a staging server but I don't think that has materialized yet.

CollapseExpand
 
themayurkumbhar profile image
MAYUR KUMBHAR
  • Location
    India
  • Joined

Is it possible to do it on local without uploading to pypi?

CollapseExpand
 
prahladyeri profile image
Prahlad Yeri
Just another humble techie.
  • Email
  • Location
    India
  • Education
    MCA, MA (Econ)
  • Pronouns
    He/Him
  • Work
    Programmer at Freelance
  • Joined

Sure, just skip everything from point number 5. Instead, just install your locally generated package (*.tar.gz) using pip!

pip install <your-package>-1.0.0.tar.gz
Enter fullscreen modeExit fullscreen mode

You can even publish this package as a binary setup file on github or just email it to your friends to keep it local.

Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment'spermalink.

For further actions, you may consider blocking this person and/orreporting abuse

Just another humble techie.
  • Location
    India
  • Education
    MCA, MA (Econ)
  • Pronouns
    He/Him
  • Work
    Programmer at Freelance
  • Joined

More fromPrahlad Yeri

DEV Community

We're a place where coders share, stay up-to-date and grow their careers.

Log in Create account

[8]ページ先頭

©2009-2025 Movatter.jp