How to Publish a Python Package to PyPI (pip)

Поделиться
HTML-код
  • Опубликовано: 25 июн 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 Месяц назад +2

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

  • @shivuveerkumar
    @shivuveerkumar 3 месяца назад +6

    Bro seriously one of the best video on RUclips

  • @aadilzikre
    @aadilzikre Месяц назад +3

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

    • @pixegami
      @pixegami  29 дней назад

      Awesome, glad to hear that!

  • @muhammadqaisarali
    @muhammadqaisarali 6 месяцев назад +7

    Thanks man, it was straight forward

  • @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  5 месяцев назад +1

      Glad it was helpful!

  • @tarangsuri8932
    @tarangsuri8932 6 дней назад

    Great tutorial, Thanks!

  • @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 8 месяцев назад +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.

  • @bgd_surf
    @bgd_surf 7 месяцев назад +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!

  • @mrpizzakingman4604
    @mrpizzakingman4604 4 месяца назад +3

    just what i need :D

    • @pixegami
      @pixegami  4 месяца назад +1

      Glad to hear that :)

  • @luishenriquelopesteodoro1921
    @luishenriquelopesteodoro1921 4 месяца назад +3

    Excellent

  • @Happyendrew
    @Happyendrew Месяц назад

    Thanks a lot!

  • @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.

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

  • @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.

  • @_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  Месяц назад +1

      It's GitHub Co-Pilot.

    • @pranav_arya
      @pranav_arya Месяц назад +1

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

  • @_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

  • @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.

  • @HashtagTiluda
    @HashtagTiluda 2 месяца назад +1

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

    • @pixegami
      @pixegami  2 месяца назад +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 2 месяца назад

      @@pixegami thank you!

  • @Tcrrxzz
    @Tcrrxzz 6 месяцев назад +1

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

  • @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.

  • @cristiandiaz3551
    @cristiandiaz3551 3 месяца назад +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

  • @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!

  • @anirbansom6682
    @anirbansom6682 10 дней назад

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

    • @pixegami
      @pixegami  10 дней назад

      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

  • @AbtinDar
    @AbtinDar 3 месяца назад

    String library is not installed

  • @TechnicalLodhiOfficial
    @TechnicalLodhiOfficial 2 месяца назад

    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  7 месяцев назад +1

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

    • @ishanoshada
      @ishanoshada 7 месяцев назад

      @@pixegami pypi verification

  • @DioneAl-Farisi
    @DioneAl-Farisi 7 дней назад

    I can't install twine