How to Publish a Python Package to PyPI (pip)

SdĂ­let
VloĆŸit
  • čas pƙidĂĄn 24. 07. 2024
  • Learn how to publish your own custom Python package to PyPI.
    This tutorial covers setting up the project, configuring the setup.py file, building and testing the package, adding CLI functionality, publishing to PyPI, and installing using pip. Watch this video if you want to share your code and make it easily installable for others.
    📚 Chapters
    00:00 Introduction
    00:34 Project Setup
    02:06 Configure and Build Package
    04:14 Local Testing
    05:53 Adding a CLI Entry Point
    07:36 Publish to PyPI
    10:01 Wrapping Up
    #pixegami #python

Komentáƙe • 73

  • @shivuveerkumar
    @shivuveerkumar Pƙed 4 měsĂ­ci +10

    Bro seriously one of the best video on CZcams

  • @2dapoint424
    @2dapoint424 Pƙed 2 měsĂ­ci +2

    The best video!! Short and concise!! Thank you sharing this!

  • @aadilzikre
    @aadilzikre Pƙed měsĂ­cem +4

    Thank you for the Guidance. I was able to create the package without much googling!!

    • @pixegami
      @pixegami  Pƙed měsĂ­cem

      Awesome, glad to hear that!

  • @muhammadqaisarali
    @muhammadqaisarali Pƙed 7 měsĂ­ci +7

    Thanks man, it was straight forward

  • @typehint
    @typehint Pƙed 12 dny

    This is an absolutely fantastic tutorial. Thanks for this!

  • @rafaelfonseca7942
    @rafaelfonseca7942 Pƙed 5 měsĂ­ci +4

    Helpful video... came in handy for me here! Thanks!

    • @pixegami
      @pixegami  Pƙed 5 měsĂ­ci +1

      Thank you! I'm glad to hear that :)

  • @DamoOne
    @DamoOne Pƙed 6 měsĂ­ci +5

    Really well explained, thanks!

    • @pixegami
      @pixegami  Pƙed 6 měsĂ­ci +1

      Glad it was helpful!

  • @pythonantole9892
    @pythonantole9892 Pƙed 9 měsĂ­ci +6

    I'm surprised at how easy this is. I'm motivated to bundle some of my scripts into packages.

    • @danielvega646
      @danielvega646 Pƙed 9 měsĂ­ci +2

      actually npm is way better and straightforward. This part of creating a token on pypi was a whole issue for me

    • @pixegami
      @pixegami  Pƙed 8 měsĂ­ci +1

      Sometimes I do wish Python's package management/environment was as integrated as Node :)

    • @pixegami
      @pixegami  Pƙed 8 měsĂ­ci +1

      Yup! This can be useful if you if you need to re-use scripts or to share them with your team.

  • @xsamueljr
    @xsamueljr Pƙed 9 měsĂ­ci +1

    If my package is in a github repository, and I want to use `pip install git+[some link].git`, do I need to commit and push the wheel files?

  • @tarangsuri8932
    @tarangsuri8932 Pƙed měsĂ­cem

    Great tutorial, Thanks!

  • @TaerimYoon
    @TaerimYoon Pƙed 10 dny

    Best video! Thank you!

  • @EvanRickettsUk
    @EvanRickettsUk Pƙed 2 měsĂ­ci +1

    This was great, thank you!

    • @pixegami
      @pixegami  Pƙed 2 měsĂ­ci

      Glad you enjoyed it!

  • @marsbars1105
    @marsbars1105 Pƙed 2 měsĂ­ci +1

    This is such a great video! Thankyou very much!

    • @pixegami
      @pixegami  Pƙed 2 měsĂ­ci

      Glad it was helpful!

  • @bgd_surf
    @bgd_surf Pƙed 8 měsĂ­ci +3

    awesome!!

  • @paloha
    @paloha Pƙed 19 dny

    Very well made video. Thanks

  • @Valer_100
    @Valer_100 Pƙed 17 dny

    Really useful tutorial! It was very easy to understand.

  • @luishenriquelopesteodoro1921
    @luishenriquelopesteodoro1921 Pƙed 5 měsĂ­ci +3

    Excellent

  • @mrpizzakingman4604
    @mrpizzakingman4604 Pƙed 5 měsĂ­ci +3

    just what i need :D

    • @pixegami
      @pixegami  Pƙed 5 měsĂ­ci +1

      Glad to hear that :)

  • @Happyendrew
    @Happyendrew Pƙed 2 měsĂ­ci

    Thanks a lot!

  • @pablomunsey
    @pablomunsey Pƙed 3 měsĂ­ci +3

    Concise and to the point. I keep revisiting it as I progress.
    Would like to see a compatible one usng a pyproject.toml.

    • @pixegami
      @pixegami  Pƙed 3 měsĂ­ci

      Thank you, glad it's helpful! I need to take a look at using the toml format, I haven't used it before.

  • @slipthetrap
    @slipthetrap Pƙed 4 měsĂ­ci

    Is this all that is needed to also do: pipx install pixegami-hello ... for example? Thanks for the videos.

  • @paradoxial7665
    @paradoxial7665 Pƙed 2 měsĂ­ci

    So I installed my library and when I import it to a file to test, everything works fine when I run the code, however Pylance says the module doesn't exist but when the code is ran, it works just fine? I wonder why??

  • @_aade
    @_aade Pƙed 5 měsĂ­ci +3

    Is there a way to change the version number automatically?

    • @pixegami
      @pixegami  Pƙed 5 měsĂ­ci +2

      Yeah, I'd recommend implementing this as something like a Git hook maybe for minor/patch version number.

  • @sg8nj
    @sg8nj Pƙed 8 dny

    Great work

  • @_aade
    @_aade Pƙed 5 měsĂ­ci +3

    Will there be a problem if I delete previous versions?

    • @pixegami
      @pixegami  Pƙed 5 měsĂ­ci +2

      Generally, I don't think you're meant to delete previous versions, but I'm sure it'll be fine if you have to do it (I haven't tried it out myself though).

  • @_aade
    @_aade Pƙed 5 měsĂ­ci +3

    Why do we have to use twine?

    • @pixegami
      @pixegami  Pƙed 5 měsĂ­ci +2

      I don't think we have to use it, but it was just the easiest/recommended way I found online of how to actually upload the local content to the remote repository.

    • @_aade
      @_aade Pƙed 5 měsĂ­ci +1

      Thank you, my friend, I am grateful to you for answering all three of my questions :)@@pixegami

  • @gokulyc
    @gokulyc Pƙed 9 měsĂ­ci +1

    can you make using hatch package manager

  • @Tcrrxzz
    @Tcrrxzz Pƙed 7 měsĂ­ci +1

    But the entry_points isn't a setup parameter? please explain it!! thanks

  • @prajganesh
    @prajganesh Pƙed 9 měsĂ­ci +4

    Great one. side topic. Can you tell us which tool you use to create the youtube thumbnail? thanks.

    • @pixegami
      @pixegami  Pƙed 8 měsĂ­ci +1

      Thanks! I use Photoshop for the thumbnails.

  • @pranav_arya
    @pranav_arya Pƙed 2 měsĂ­ci +2

    which plugin or app you are using for VS Code terminal autocomplete suggestions?

    • @pixegami
      @pixegami  Pƙed 2 měsĂ­ci +1

      It's GitHub Co-Pilot.

    • @pranav_arya
      @pranav_arya Pƙed 2 měsĂ­ci +1

      ​@@pixegami Thanks for responding. Are you using the fish terminal?

  • @richardalphonse2680
    @richardalphonse2680 Pƙed 5 měsĂ­ci +1

    Well Explained , thanks I Have doubt in terms of loading json data within folder structure and reading it wihthin a function
    how it can excuted can you help me with this

    • @pixegami
      @pixegami  Pƙed 5 měsĂ­ci

      First, you need to configure your setuptools to include data files like JSON: docs.python.org/3.8/distutils/setupscript.html#installing-additional-files
      Then it'll be packaged along with your Python scripts, and you can just call/use it from there.

  • @shubhamshastri7409
    @shubhamshastri7409 Pƙed 5 měsĂ­ci +1

    i am able to do this but what if i want my package to be uploaded privately , one only with auth can able to install it with pip

    • @pixegami
      @pixegami  Pƙed 5 měsĂ­ci +1

      I think you can upload to your own private repository for that. You'll probably have to look up how to set up your own private PyPI server.

  • @cristiandiaz3551
    @cristiandiaz3551 Pƙed 4 měsĂ­ci +1

    hey men, im do the same but my project have some dependencies, it work localy but but i try to install form pypi it dont install the dependacies, can you help me ?

    • @pixegami
      @pixegami  Pƙed 3 měsĂ­ci +1

      Have you tried adding them to `install_requires`? See here: python-packaging.readthedocs.io/en/latest/dependencies.html

  • @lookingoffswitch4344
    @lookingoffswitch4344 Pƙed 22 dny

    Should "pip install setuptools wheel twice" be done in my project's virtual environment or should these libraries be installed into my global Python environment? TIA!

  • @HashtagTiluda
    @HashtagTiluda Pƙed 3 měsĂ­ci +1

    A quick question, what if I want to pass a string to the hello function?

    • @pixegami
      @pixegami  Pƙed 3 měsĂ­ci +1

      If you wanna use it as a library, then it's just a normal function (so you can add an argument to it, and use it after you import it).
      If you wanna use it like a CLI (from the terminal), you can do it using a library like argparse: docs.python.org/3/library/argparse.html#module-argparse

    • @HashtagTiluda
      @HashtagTiluda Pƙed 3 měsĂ­ci

      @@pixegami thank you!

  • @niklyons9674
    @niklyons9674 Pƙed 9 dny

    This is awesome information. I have a script I'm looking do download on a Windows system and a Linux system. Are you able to run this packages on a CronJob for Linux and task scheduler for Windows Machines?

  • @anirbansom6682
    @anirbansom6682 Pƙed měsĂ­cem

    How to create a CLI Command which will accept arguments ? Like, pixegami-hello --file_name /file/path/

    • @pixegami
      @pixegami  Pƙed měsĂ­cem

      This is how you wire up scripts to command: python-packaging.readthedocs.io/en/latest/command-line-scripts.html
      If you want to parse arguments, use this built-in library: docs.python.org/3/library/argparse.html

  • @prashantmeti7986
    @prashantmeti7986 Pƙed 2 měsĂ­ci +1

    I didn't get how and where to export the token and api key please tell me

    • @pixegami
      @pixegami  Pƙed 2 měsĂ­ci +1

      It's just environment variables, so if you're not familair with them, search "how do I set environments in Linux/Mac/Windows?" (or whichever OS you are using) on Google. Good luck!

  • @TechnicalLodhiOfficial
    @TechnicalLodhiOfficial Pƙed 3 měsĂ­ci

    Bro I can't understand how setup environment variable ( 8:14 ) Can you please clarify that?

    • @pixegami
      @pixegami  Pƙed 2 měsĂ­ci

      There's lots of ways to set an environment variable. It's basically a variable that is set at the OS level, and shared with all processes in that terminal/application context.
      I'd recommend to Google "how do I set up environment variables on Linux/Mac/Windows? (or whichever OS you are on)" and follow those instructions.

    • @TechnicalLodhiOfficial
      @TechnicalLodhiOfficial Pƙed 2 měsĂ­ci

      @@pixegami I googled it and found out the results Thanks!

  • @ishanoshada
    @ishanoshada Pƙed 8 měsĂ­ci +1

    How to totp verification do???

    • @pixegami
      @pixegami  Pƙed 8 měsĂ­ci +1

      Hmm, is this part of the package publishing workflow, or is this for something different?

    • @ishanoshada
      @ishanoshada Pƙed 8 měsĂ­ci

      @@pixegami pypi verification

  • @AbtinDar
    @AbtinDar Pƙed 4 měsĂ­ci

    String library is not installed

  • @DioneAl-Farisi
    @DioneAl-Farisi Pƙed měsĂ­cem

    I can't install twine

  • @thetaomegatheta
    @thetaomegatheta Pƙed 4 dny

    5:00 Nope. Does not work. Neither the python CLI, nor other projects can see anything in the package after installation.
    Furthermore, `__init__.py` even claims that the imports are unused.
    When trying to import anything from the package after the installation, it throws ModuleNotFoundError: No module named 'my-library'.

  • @seesmof
    @seesmof Pƙed 29 dny

    Hallelujah thank YOU Jesus Christ our Holy Lord GOD Almighty ✝❣
    GOD bless you, great video, very straightforward, may Jesus Christ our Holy Lord GOD Almighty bless you and keep you, may GOD make His face shine upon you and be gracious to you, may King Jesus Christ our Lord lift up His face to you and give you peace in JESUS HOLY Name we pray LORD GOD, AMEN
    be saved from hell: repent of your sins and put your faith alone in Jesus Christ our Lord ✝💞