Thanks for the video. Why do you recommend creating the src directory?
@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/
@Hellbending10 ай бұрын
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 ❤
@orcharddweller10 ай бұрын
__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
@Hellbending10 ай бұрын
@@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
@orcharddweller10 ай бұрын
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 Жыл бұрын
So i always get "No apps associated with package"
@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-jw8uc10 ай бұрын
Hello. My module is not found when I run pdm run -m mymodule. Am I missing something in the pyproject.toml?
@orcharddweller10 ай бұрын
Did you run pdm install? You need to run it at least once for the editable install to work.
@JacobAsmuth-jw8uc10 ай бұрын
@@orcharddwellerWorked, thank you! I was just running pdm build
@TotalImmort7l10 ай бұрын
Have you tried using pdm run python -m mymodule? Let me know if that helps
@yash11527 ай бұрын
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...