Тёмный

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

anthonywritescode
Подписаться 39 тыс.
Просмотров 49 тыс.
50% 1

today I go over a basic setup.py for packaging a python package. I then show a few tools you can use to migrate from classic setup.py to more easily rewritable setup.cfg!
- ./src layout: • python packaging: src ...
- setup-py-upgrade: github.com/asottile/setup-py-...
- setup-cfg-fmt: github.com/asottile/setup-cfg...
playlist: • anthony explains
==========
twitch: / anthonywritescode
dicsord: / discord
twitter: / codewithanthony
github: github.com/asottile
stream github: github.com/anthonywritescode
I won't ask for subscriptions / likes / comments in videos but it really helps the channel. If you have any suggestions or things you'd like to see please comment below!

Наука

Опубликовано:

 

24 июн 2020

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 57   
@alexkennedy5324
@alexkennedy5324 2 года назад
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.
@anthonywritescode
@anthonywritescode 2 года назад
glad it helped!
@calmdo-able9925
@calmdo-able9925 2 года назад
Legendary, as basic as this is, it was something I was looking for. Top lad
@WatchNev
@WatchNev 10 месяцев назад
This was extremely more helpful than dealing with StackOverflow jerks. Thank you for this.
@tombra4ril
@tombra4ril 2 года назад
Thanks man this was very cool and informative.
@ericng8807
@ericng8807 2 года назад
Great tutorial! It helped me setup this program called babi
@jbrnds
@jbrnds 3 года назад
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')`: ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-beDG6Ibo2zQ.html
@scillabiffolia4377
@scillabiffolia4377 3 года назад
what is the blue icon ad on you have in your browser. how about the one next to it?
@anthonywritescode
@anthonywritescode 3 года назад
that's probably bitwarden (password manager) and tampermonkey (user scripting engine)
@guntbert9709
@guntbert9709 4 года назад
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 года назад
I cover that in this video: ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-sv46294LoP8.html -- it doesn't make any difference in this particular example though
@guntbert9709
@guntbert9709 4 года назад
@@anthonywritescode got it :-))
@PritishMishra
@PritishMishra 3 года назад
Good !!
@ulfgj
@ulfgj 3 года назад
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 года назад
hah! at one point I learned one-handed touch typing -- could get almost ~60 wpm (left hand only)
@jspreddy
@jspreddy 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 3 года назад
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
@anand967
@anand967 3 года назад
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 года назад
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
@jfk1337
@jfk1337 Год назад
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 Год назад
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
@BullishBuddy
@BullishBuddy Год назад
life saver!
@meeexy116
@meeexy116 Год назад
how do you include stub (.pyi) files in the package with setuptools
@anthonywritescode
@anthonywritescode Год назад
check out these: - ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-bfyIrX4_yL8.html - ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-n4GJ8rp6DpE.html
@chepecarlo
@chepecarlo 2 года назад
Gracias me ayudó mucho gracias
@anthonywritescode
@anthonywritescode 2 года назад
¡de nada!
@brainmri
@brainmri 2 года назад
A short tutorial on pyscaffold package will be helpful. Could you do one please? Thanks.
@anthonywritescode
@anthonywritescode 2 года назад
I've never used it personally -- I usually just use `cp` to make my new projects
@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 Год назад
Python "package" - giggity
@vandykfernandes8356
@vandykfernandes8356 8 месяцев назад
Hi. Nice tutorial, how do we handle custom commands via cmdclass in setup.cfg?
@anthonywritescode
@anthonywritescode 8 месяцев назад
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 8 месяцев назад
@@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 8 месяцев назад
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 8 месяцев назад
Following is the warning I see, SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.
@vandykfernandes8356
@vandykfernandes8356 8 месяцев назад
@@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?
@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 года назад
they're using setuptools-scm which I do not recommend -- I talk about semantic versioning here: ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-vRSw2f34RRU.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
@Flyingnobull
@Flyingnobull 2 года назад
Thanks!
@Flyingnobull
@Flyingnobull 2 года назад
Wouldn't able to fix the issue without seeing the commas you added at setup.py script. - Thanks!
@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
@prafullakh
@prafullakh 2 года назад
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 года назад
sure! check out this video where I explain what's going on here: ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-evYOlT1T7Mo.html
@prafullakh
@prafullakh 2 года назад
@@anthonywritescode Thank you very much. This really helped.
@PaulFidika
@PaulFidika Месяц назад
Who is this guy?
@anthonywritescode
@anthonywritescode Месяц назад
who me?
Далее
Demystefying Setuptools Entry Points
38:27
Просмотров 9 тыс.
Best father #shorts by Secret Vlog
00:18
Просмотров 13 млн
899$ vs 360$ which one will you choose ? #iphone #poco
0:18