Setup a Python project with PDM

  Рет қаралды 6,531

Orchard Dweller

Orchard Dweller

Күн бұрын

Пікірлер: 14
@AndreiDamian
@AndreiDamian Жыл бұрын
Thanks for the video. Why do you recommend creating the src directory?
@orcharddweller
@orcharddweller Жыл бұрын
I’m glad you enjoyed it! In Python you can import modules from the directory you are in, so without src you will not import from the installed version of your project, but rather from the files itself. In most cases that is fine, but it can lead to tiny confusing bugs sometimes. Here’s some more info: packaging.python.org/en/latest/discussions/src-layout-vs-flat-layout/
@Hellbending
@Hellbending 10 ай бұрын
Been using PDM for quite some time as I found poetries docs initially somewhat difficult to read and understand and I was new to python. (or even why you might use it, and then I started using Linux more frequently and understood lol) Perhaps I missed a convention with python file, naming conventions, but can you go into more detail or link me an article around the section about using a __main__.py as a file? I’m already in the habit of doing an ‘if name == __main__: block in main.py, but I’m not entirely sure what you’re doing here with the __main__.py file and all of that ❤
@orcharddweller
@orcharddweller 10 ай бұрын
__main__.py is the file you want to use when you need an entrypoint to your program. It's so that you can run it with python -m module_name instead of python -m module_name.main here's the docs: docs.python.org/3/library/__main__.html
@Hellbending
@Hellbending 10 ай бұрын
@@orcharddweller having a quick skim through the docs. It seems like this is more specific to packaging things onto pypy or for the building of pulling packages down, that along the right lines? I’ve always just done python(the interpreter) and then main.py and then at the bottom of main.py I’ll have an “if name main” block and then just call main with any runtime specific things for the JIT. TIL - it’s not just a convention haha cheers bro
@orcharddweller
@orcharddweller 10 ай бұрын
There's a million ways to run your stuff in python (which imho is a bad thing). Its fine to just run a script file, but then you have to make sure that your dependencies are properly installed, and you might end up with some very subtle bugs with your imports unless you're really careful. Running scripts as modules means you have to adhere to python packaging rules. And that's a good thing, because you can expect all the things you build to just work, and you have some rules to follow that will most likely work with all the toolings that you potentially use.
@salimnassor4619
@salimnassor4619 Жыл бұрын
So i always get "No apps associated with package"
@orcharddweller
@orcharddweller Жыл бұрын
When trying to install your package with pipx right? Did you remember to add the [project.scripts] like in 11:53? (for poetry it's [tool.poetry.scripts] instead) it should look like that: [project.scripts] your-new-command-name = "your.module.path:your_main_function_name"
@JacobAsmuth-jw8uc
@JacobAsmuth-jw8uc 10 ай бұрын
Hello. My module is not found when I run pdm run -m mymodule. Am I missing something in the pyproject.toml?
@orcharddweller
@orcharddweller 10 ай бұрын
Did you run pdm install? You need to run it at least once for the editable install to work.
@JacobAsmuth-jw8uc
@JacobAsmuth-jw8uc 10 ай бұрын
@@orcharddwellerWorked, thank you! I was just running pdm build
@TotalImmort7l
@TotalImmort7l 10 ай бұрын
Have you tried using pdm run python -m mymodule? Let me know if that helps
@yash1152
@yash1152 7 ай бұрын
1:32 aah yes, i definitely think that "non-python external libraries" should have been in their own category. the absence of this point makes this video kinda pointless for me...
@FranzAllanSee
@FranzAllanSee 5 ай бұрын
Try rye. Been playing with it recently 😁
How to Use Poetry in Python to avoid Dependency Hell
20:21
Earthly
Рет қаралды 18 М.
ТЮРЕМЩИК В БОКСЕ! #shorts
00:58
HARD_MMA
Рет қаралды 2,7 МЛН
Do you love Blackpink?🖤🩷
00:23
Karina
Рет қаралды 22 МЛН
Farmer narrowly escapes tiger attack
00:20
CTV News
Рет қаралды 12 МЛН
How to Publish a Python Package to PyPI (pip)
11:38
pixegami
Рет қаралды 22 М.
why I will never use python-poetry
9:09
anthonywritescode
Рет қаралды 63 М.
Some tricks with UV and a new Python project: uvtrick!
11:45
How to Create and Use Virtual Environments in Python With Poetry
14:43
15 Python Libraries You Should Know About
14:54
ArjanCodes
Рет қаралды 403 М.
Tmux From Scratch To BEAST MODE
12:44
DevOps Toolbox
Рет қаралды 127 М.
Is UV the FUTURE of Python PACKAGING? 🐍📦
17:52
Hynek Schlawack
Рет қаралды 10 М.
ТЮРЕМЩИК В БОКСЕ! #shorts
00:58
HARD_MMA
Рет қаралды 2,7 МЛН