korrents

korrents · video

My 2025 uv-based Python Project Layout for Production Apps

Hynek Schlawack · 24m · youtube.com ↗

19 korrents from this recording

Hynek Schlawack did not write this page.

Every claim below is a statement made in this recording, quoted word for word and linked to the second it was said, so you can hear it rather than take our word for it. The wording comes from the transcript published alongside the recording; the sentence above each quote is our reading of the claim, not their wording.

  1. 0:07 · watch on youtube.com↗

    the good news is that over the run of 2024, Python's packaging and project tooling got infinitely better and faster.
  2. 1 min later
  3. 0:38 · watch on youtube.com↗

    Because local workflows can be ergonomic and robust now. Yes, really, with Python. And shipping Python applications using Docker containers really fast with safe, reproducible builds is a solved problem in 2025.
  4. 2 min later
  5. 2:54 · watch on youtube.com↗

    What I won't talk ever about is using Docker locally for development because it's such a terrible development experience compared to what's possible with local tooling nowadays.
  6. 1 min later
  7. 3:34 · watch on youtube.com↗

    It appeared pretty much exactly a year ago in February of 2024 and for many people it already has lived up to the ambition. In some ways it has even surpassed its role models.
  8. 1 min later
  9. 4:11 · watch on youtube.com↗

    As for Astral's ambition, if you already ship Python applications in Docker containers and got your way doing that without some special Conda features it is the only tool you need.
  10. 1 min later
  11. 4:46 · watch on youtube.com↗

    Personally I find pseudo-objective or unbiased content where people talk in theoretical terms about things they've never used themselves in anger rather unhelpful and I prefer contextualized earned opinions.
  12. 1 min later
  13. 6:09 · watch on youtube.com↗

    There is no shame in going adhoc. The current implementation of PyPI which is called warehouse uses that layout. But I'm gonna be a model Python citizen and show you how to do it properly because it tightens the envelope of possible states and shapes that my project can be in which simplifies import logic greatly.
  14. 1 min later
  15. 6:57 · watch on youtube.com↗

    But I honestly think that the prevalence of adhoc design in the Python ecosystem is just that Python's packaging tooling used to be a trash fire around 2010 – the formative years – and people did anything necessary to avoid interacting with it
  16. 7:10 · watch on youtube.com↗

    and are just doing whatever they're always done or whatever they see around the internet. I don't know I think in the age of UV it's time to reconsider.
  17. 1 min later
  18. 7:46 · watch on youtube.com↗

    to make sure that when I run tests against the package the tests imports only pick up code that is part of the package and guaranteed to be installed and not imported accidentally because they're laying around. This catches a whole category of packaging and installation bugs
  19. 1 min later
  20. 8:16 · watch on youtube.com↗

    I name my pytest fixture functions with an underscore and set their name explicitly to avoid the confusing error of forgetting to declare dependency in a test and accidentally using the function object as the fixture.
  21. 8:38 · watch on youtube.com↗

    Simple but it happens to give us 100% test coverage which happens to be the only correct test coverage.
  22. 8:59 · watch on youtube.com↗

    Boundaries between systems are extremely important to contain complexity. Entry points allow you to interact with such a system across boundaries in a controlled way. The narrower and better defined an entry point the easier it is to reason about the interactions with the system and the better the containment of the complexity.
  23. 1 min later
  24. 10:08 · watch on youtube.com↗

    I'm not a fan of like randomly groping into packages. I like to have clear standardized entry points into my applications whose only job is to bridge between the dirty real world and my pristine application.
  25. 10:35 · watch on youtube.com↗

    And this is the only module where you have my blessing to add it to coverage's `omit` list. And to mitigate the risk this introduces I keep them as simple as possible with no loops or if statements
  26. 3 min later
  27. 13:59 · watch on youtube.com↗

    since this is an application that is eventually shipped to a server we don't care about package versions and we can set it to zero and never touch it again.
  28. 3 min later
  29. 16:57 · watch on youtube.com↗

    Therefore this is great for package maintainers that are annoyed that it looks like our packages depend on pytest or sphinx because their development extras leak into PyPI.
  30. 3 min later
  31. 19:27 · watch on youtube.com↗

    complaining on open source projects about changes breaking your production is very bad karma and shows that you don't have your dependencies under control?
  32. 1 min later
  33. 20:37 · watch on youtube.com↗

    And unless you've explicitly told uv to do things in non-standard ways, there's almost no room for error from your side. It's essentially foolproof, which is my favorite kind of proof.