How to Publish a Python Package to PyPI (pip)

Поділитися
Вставка
  • Опубліковано 19 чер 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

КОМЕНТАРІ • 64

  • @2dapoint424
    @2dapoint424 26 днів тому +2

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

  • @shivuveerkumar
    @shivuveerkumar 3 місяці тому +6

    Bro seriously one of the best video on UA-cam

  • @aadilzikre
    @aadilzikre 24 дні тому +3

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

    • @pixegami
      @pixegami  23 дні тому

      Awesome, glad to hear that!

  • @muhammadqaisarali
    @muhammadqaisarali 6 місяців тому +7

    Thanks man, it was straight forward

  • @pythonantole9892
    @pythonantole9892 8 місяців тому +6

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

    • @danielvega646
      @danielvega646 7 місяців тому +2

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

    • @pixegami
      @pixegami  7 місяців тому +1

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

    • @pixegami
      @pixegami  7 місяців тому +1

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

  • @rafaelfonseca7942
    @rafaelfonseca7942 4 місяці тому +4

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

    • @pixegami
      @pixegami  4 місяці тому +1

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

  • @DamoOne
    @DamoOne 5 місяців тому +5

    Really well explained, thanks!

    • @pixegami
      @pixegami  4 місяці тому +1

      Glad it was helpful!

  • @tarangsuri8932
    @tarangsuri8932 День тому

    Great tutorial, Thanks!

  • @bgd_surf
    @bgd_surf 6 місяців тому +3

    awesome!!

  • @EvanRickettsUk
    @EvanRickettsUk Місяць тому +1

    This was great, thank you!

    • @pixegami
      @pixegami  Місяць тому

      Glad you enjoyed it!

  • @marsbars1105
    @marsbars1105 Місяць тому +1

    This is such a great video! Thankyou very much!

    • @pixegami
      @pixegami  Місяць тому

      Glad it was helpful!

  • @Happyendrew
    @Happyendrew 26 днів тому

    Thanks a lot!

  • @xsamueljr
    @xsamueljr 8 місяців тому +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?

  • @pablomunsey
    @pablomunsey 2 місяці тому +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  2 місяці тому

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

  • @luishenriquelopesteodoro1921
    @luishenriquelopesteodoro1921 3 місяці тому +3

    Excellent

  • @mrpizzakingman4604
    @mrpizzakingman4604 4 місяці тому +3

    just what i need :D

    • @pixegami
      @pixegami  4 місяці тому +1

      Glad to hear that :)

  • @slipthetrap
    @slipthetrap 3 місяці тому

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

  • @prajganesh
    @prajganesh 8 місяців тому +4

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

    • @pixegami
      @pixegami  7 місяців тому +1

      Thanks! I use Photoshop for the thumbnails.

  • @paradoxial7665
    @paradoxial7665 Місяць тому

    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??

  • @richardalphonse2680
    @richardalphonse2680 4 місяці тому +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  4 місяці тому

      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.

  • @_aade
    @_aade 4 місяці тому +3

    Will there be a problem if I delete previous versions?

    • @pixegami
      @pixegami  4 місяці тому +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 4 місяці тому +3

    Is there a way to change the version number automatically?

    • @pixegami
      @pixegami  4 місяці тому +2

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

  • @pranav_arya
    @pranav_arya Місяць тому +2

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

    • @pixegami
      @pixegami  28 днів тому +1

      It's GitHub Co-Pilot.

    • @pranav_arya
      @pranav_arya 27 днів тому +1

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

  • @Tcrrxzz
    @Tcrrxzz 6 місяців тому +1

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

  • @HashtagTiluda
    @HashtagTiluda 2 місяці тому +1

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

    • @pixegami
      @pixegami  Місяць тому +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 Місяць тому

      @@pixegami thank you!

  • @cristiandiaz3551
    @cristiandiaz3551 2 місяці тому +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  2 місяці тому +1

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

  • @gokulyc
    @gokulyc 8 місяців тому +1

    can you make using hatch package manager

  • @shubhamshastri7409
    @shubhamshastri7409 4 місяці тому +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  4 місяці тому +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.

  • @_aade
    @_aade 4 місяці тому +3

    Why do we have to use twine?

    • @pixegami
      @pixegami  4 місяці тому +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 4 місяці тому +1

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

  • @anirbansom6682
    @anirbansom6682 5 днів тому

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

    • @pixegami
      @pixegami  4 дні тому

      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

  • @DioneAl-Farisi
    @DioneAl-Farisi 2 дні тому

    I can't install twine

  • @AbtinDar
    @AbtinDar 2 місяці тому

    String library is not installed

  • @prashantmeti7986
    @prashantmeti7986 Місяць тому +1

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

    • @pixegami
      @pixegami  Місяць тому

      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 Місяць тому

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

    • @pixegami
      @pixegami  Місяць тому

      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 Місяць тому

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

  • @ishanoshada
    @ishanoshada 7 місяців тому +1

    How to totp verification do???

    • @pixegami
      @pixegami  6 місяців тому +1

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

    • @ishanoshada
      @ishanoshada 6 місяців тому

      @@pixegami pypi verification