python packaging: basic setup.py and declarative metadata (intermediate) anthony explains

แชร์
ฝัง
  • เผยแพร่เมื่อ 15 ก.ย. 2024

ความคิดเห็น • 58

  • @alexkennedy5324
    @alexkennedy5324 3 ปีที่แล้ว +24

    This man's brain is running at a frequency that I can't even fathom. Really cool, informative video. Exactly what I'm looking for.

  • @calmdo-able9925
    @calmdo-able9925 2 ปีที่แล้ว +3

    Legendary, as basic as this is, it was something I was looking for. Top lad

  • @WatchNev
    @WatchNev ปีที่แล้ว +1

    This was extremely more helpful than dealing with StackOverflow jerks. Thank you for this.

  • @MrOxford
    @MrOxford 15 วันที่ผ่านมา +1

    @anythonywritescode I liked this video and thought that you did a great job explaining how to do the setup file. I look forward to watching more of your content and learning how to package software correctly.

  • @jspreddy
    @jspreddy 4 ปีที่แล้ว +3

    I am new to python and am trying to get up to speed on it. I understand that we could re-write a setup.cfg file easier than setup.py file, but why would we need to programmatically re-write this data in the first place? Maybe a few example cases when we would need to change this data would be helpful.

    • @anthonywritescode
      @anthonywritescode  4 ปีที่แล้ว +2

      github.com/asottile/setup-cfg-fmt has a few good examples, basically if you want to format or normalize or automatically improve the setup metadata it'd be impossible with setup.py

  • @tombra4ril
    @tombra4ril 3 ปีที่แล้ว +2

    Thanks man this was very cool and informative.

  • @ericng8807
    @ericng8807 2 ปีที่แล้ว +1

    Great tutorial! It helped me setup this program called babi

  • @jbrnds
    @jbrnds 3 ปีที่แล้ว +1

    How would you deal with automating the version in the setup.cfg when building the package if you’d have the version defined somewhere in an / __version__.py or similar.

    • @anthonywritescode
      @anthonywritescode  3 ปีที่แล้ว

      imo don't bother, you _rarely_ need it at runtime and if you do you can retrieve it using `importlib.metadata.version('pkgname')`: th-cam.com/video/beDG6Ibo2zQ/w-d-xo.html

  • @scillabiffolia4377
    @scillabiffolia4377 3 ปีที่แล้ว +1

    what is the blue icon ad on you have in your browser. how about the one next to it?

    • @anthonywritescode
      @anthonywritescode  3 ปีที่แล้ว +1

      that's probably bitwarden (password manager) and tampermonkey (user scripting engine)

  • @anand967
    @anand967 3 ปีที่แล้ว +1

    If we want to declare two setup package in setup.cfg how can we do it. As it will have two "name,version,etc.

    • @anthonywritescode
      @anthonywritescode  3 ปีที่แล้ว

      in that case you'd probably have two setup.py files (containing the `name` / `version`) that share the `setup.cfg`? seems a little bit of a weird setup though :thinking:

  • @ajinkyarathod5180
    @ajinkyarathod5180 3 ปีที่แล้ว +2

    First I saw the video for 2 minutes, then I realized I also need to watch other things other than the keyboard. So I came to comment this and will continue the video again

  • @ulfgj
    @ulfgj 3 ปีที่แล้ว +7

    at first, i though he was gonna make one project with the left hand and another with the right hand at the same time.... bummer.

    • @anthonywritescode
      @anthonywritescode  3 ปีที่แล้ว +1

      hah! at one point I learned one-handed touch typing -- could get almost ~60 wpm (left hand only)

  • @guntbert9709
    @guntbert9709 4 ปีที่แล้ว +2

    Thx again - these "small" examples/tips are right what I need :thumbsup: !
    What is the reason for using `exit(main))` instead of just `main()` in main.py?

    • @anthonywritescode
      @anthonywritescode  4 ปีที่แล้ว +1

      I cover that in this video: th-cam.com/video/sv46294LoP8/w-d-xo.html -- it doesn't make any difference in this particular example though

    • @guntbert9709
      @guntbert9709 4 ปีที่แล้ว

      @@anthonywritescode got it :-))

  • @jfk1337
    @jfk1337 2 ปีที่แล้ว

    Do you know about poetry and what do you think about such tools?
    And for the find packages in setup.cfg you can specify where to look, so you could do a src directory where you put your package( s) , no meed to exclude any new or other folders like docs etc.

    • @anthonywritescode
      @anthonywritescode  2 ปีที่แล้ว

      yes, I know about poetry and the 3-4 similar tools. imo they slow down development more than helping it and poetry in particular has some very harmful opinions about versioning that make library development an absolute pain

  • @manoharkulat5614
    @manoharkulat5614 2 ปีที่แล้ว

    hi atually I passed -e . in requirements.txt but I am getting ERROR: File "setup.py" no found.Directory cannot be installed in editable mode.

    • @anthonywritescode
      @anthonywritescode  2 ปีที่แล้ว

      well, did you read what the error message says?

  • @geekchiq5431
    @geekchiq5431 ปีที่แล้ว +1

    Python "package" - giggity

  • @meeexy116
    @meeexy116 ปีที่แล้ว

    how do you include stub (.pyi) files in the package with setuptools

    • @anthonywritescode
      @anthonywritescode  ปีที่แล้ว +1

      check out these:
      - th-cam.com/video/bfyIrX4_yL8/w-d-xo.html
      - th-cam.com/video/n4GJ8rp6DpE/w-d-xo.html

  • @RuslanKovtun
    @RuslanKovtun ปีที่แล้ว

    Link to "pyproject.toml explained" is missing (:

    • @anthonywritescode
      @anthonywritescode  ปีที่แล้ว

      yeah, I don't use it and don't recommend it

    • @lonterel4704
      @lonterel4704 ปีที่แล้ว

      @@anthonywritescode why dont you like static project metadata in pyproject.toml? Even using setuptools, which is already supporting PEP621. Just curious

  • @chepecarlo
    @chepecarlo 3 ปีที่แล้ว +1

    Gracias me ayudó mucho gracias

  • @vandykfernandes8356
    @vandykfernandes8356 10 หลายเดือนก่อน

    Hi. Nice tutorial, how do we handle custom commands via cmdclass in setup.cfg?

    • @anthonywritescode
      @anthonywritescode  10 หลายเดือนก่อน

      it doesn't support it -- for any non simple things you need to write them in setup py. it's a nice forcing function though

    • @vandykfernandes8356
      @vandykfernandes8356 10 หลายเดือนก่อน

      @@anthonywritescode Okay, but am not understanding how it would work in python 3.12? Python now raises deprecation warnings for setuptools and calling setup.py installs. If I write it in setup.py won't it be an issue in future? Or is there a way to call commands in setup.py with pip install?

    • @anthonywritescode
      @anthonywritescode  10 หลายเดือนก่อน

      setuptools is not deprecated, nor is setup.py -- the communication on this is terrible from pypa and it's leading to all sorts of misunderstandings. the things that are deprecated are distutils and calling setup.py directly. pip will do the right thing though

    • @vandykfernandes8356
      @vandykfernandes8356 10 หลายเดือนก่อน

      Following is the warning I see, SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.

    • @vandykfernandes8356
      @vandykfernandes8356 10 หลายเดือนก่อน

      @@anthonywritescode Got it, maybe I explained myself poorly, if calling setup.py directly is deprecated and if I have custom cmds in my setup.py how do I call it without setup.py. Right now what we do is `python setup.py mycustomcommand` how should it be called when setup.py won't be allowed to be called directly?

  • @brainmri
    @brainmri 3 ปีที่แล้ว +1

    A short tutorial on pyscaffold package will be helpful. Could you do one please? Thanks.

    • @anthonywritescode
      @anthonywritescode  3 ปีที่แล้ว

      I've never used it personally -- I usually just use `cp` to make my new projects

  • @prafullakh
    @prafullakh 2 ปีที่แล้ว +1

    Please help me understand the following Python behavior:
    def foo():
    x = 1024
    my_list = [1024]
    def helper():
    x = 2048
    my_list[0] = 2048
    return
    helper()
    print(x) # Stuck at 1024 😞
    print(my_list[0]) # Changed to 2048 🙂
    return
    foo()
    Thanks!

    • @anthonywritescode
      @anthonywritescode  2 ปีที่แล้ว +1

      sure! check out this video where I explain what's going on here: th-cam.com/video/evYOlT1T7Mo/w-d-xo.html

    • @prafullakh
      @prafullakh 2 ปีที่แล้ว

      @@anthonywritescode Thank you very much. This really helped.

  • @talalkalai8748
    @talalkalai8748 2 ปีที่แล้ว

    Can u make a video explaining pkg versions in setup, specifically __version__.py file. Ive noticed both pytest/requests using it , but couldnt figure out the right way. (have a pr on the line here...)

    • @anthonywritescode
      @anthonywritescode  2 ปีที่แล้ว +1

      they're using setuptools-scm which I do not recommend -- I talk about semantic versioning here: th-cam.com/video/vRSw2f34RRU/w-d-xo.html and I just write the version directly in setup.cfg as I show in this video

    • @talalkalai8748
      @talalkalai8748 2 ปีที่แล้ว

      ​@@anthonywritescode would you recommend shifting to pyproject.toml?

    • @anthonywritescode
      @anthonywritescode  2 ปีที่แล้ว

      I'm not using it

  • @PritishMishra
    @PritishMishra 3 ปีที่แล้ว +1

    Good !!

  • @BullishBuddy
    @BullishBuddy ปีที่แล้ว

    life saver!

  • @Flyingnobull
    @Flyingnobull 2 ปีที่แล้ว

    Thanks!

    • @Flyingnobull
      @Flyingnobull 2 ปีที่แล้ว +1

      Wouldn't able to fix the issue without seeing the commas you added at setup.py script. - Thanks!

  • @PaulFidika
    @PaulFidika 3 หลายเดือนก่อน

    Who is this guy?