my python project setup (+ all tools) (intermediate) anthony explains

Поделиться
HTML-код
  • Опубликовано: 4 окт 2024
  • today I go over all the tools I use to set up my projects, as well as the differences between 1-file libraries, multi-file libraries, and applications!
    python packaging src layout (which I don't use): • python packaging: src ...
    declarative metadata / setup.cfg: • python packaging: basi...
    playlist: • anthony explains
    ==========
    twitch: / anthonywritescode
    dicsord: / discord
    twitter: / codewithanthony
    github: github.com/aso...
    stream github: github.com/ant...
    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!
  • НаукаНаука

Комментарии • 49

  • @JohnZakaria
    @JohnZakaria 2 года назад +54

    Anthony is a living python legend.
    Wrote his own "black"
    Works on pytest, precommit.
    Still humble to teach us his ways. ♥️
    Meanwhile my helloworld project never took off 😂

    • @jamesmunroe6558
      @jamesmunroe6558 Год назад

      Preach, friend! What a library of knowledge this one developer is!

  • @nexovec
    @nexovec 2 года назад +14

    "Hey, I wrote eveything except for the language itself, use my stuff, it's free..." legend.

  • @adityakumarseth8934
    @adityakumarseth8934 Год назад +5

    Man, I just feel like will I ever be even half the developer you are. You have such a vast knowledge base in python, CI, git and everything.

  • @justasurvivingsparkle
    @justasurvivingsparkle 2 года назад +13

    Damn, you developed all those amazing libraries? I can't thank you enough for pre-commit, so useful.
    This video was extremely educational and full of very valuable information, thank you!

  • @brodie659
    @brodie659 2 года назад +2

    I stumbled on your channel a few weeks ago and you have amazing content. I really appreciate you sharing your setup!

  • @Bryft
    @Bryft 2 года назад +2

    Great video! I've looked at your config files before, and it all now makes more sense ;-]

  • @esparafucio
    @esparafucio Год назад

    I'm still a beginner so some parts flew over my head but this is inspiring stuff. A goal to work towards and use as a reference.

  • @hasanulislam3112
    @hasanulislam3112 2 года назад +1

    Lovely! Pretty helpful content. Learns a lot.

  • @leiverandres
    @leiverandres Год назад

    You are great! Always high value content

  • @CushTuse
    @CushTuse 2 года назад +3

    a big +1 to single quotes. black's reasoning around double quotes is some of the dumbest I've read

  • @giovannipcarvalho
    @giovannipcarvalho 2 года назад +2

    I understood that you want to know when a dependency of your library becomes incompatible, but how do you track the last working (dependency) versions before said breakage?
    Also how does it affect your users at install time if the dependencies are not pinned?
    Sorry if I might have misunderstood this part.
    Thanks for the great video!

    • @anthonywritescode
      @anthonywritescode  2 года назад +1

      there's no need to track it, you can simply bisect the versions when a breakage occurs (and for the ~60ish libraries I maintain this has really only happened a handful of times in the last decade so it's not really worth any extra hassle). it doesn't really affect users if you don't pin, only if you do (where users will be often unable to install due to pip's conflict resolution)

  • @Alecor_studio
    @Alecor_studio 2 года назад

    Would you do a video about best practices migrating from old code to new? Example python 2 to 3 :D library dependencies?

    • @anthonywritescode
      @anthonywritescode  2 года назад +1

      I have a whole playlist about 2-to-3, though it's kind of old: ruclips.net/p/PLWBKAf81pmOZOukFi2KyQJ7QMNDzcq2yT

  • @jake115577
    @jake115577 3 месяца назад

    You wrote pre-commit?? 😮

  • @moonman8567
    @moonman8567 Год назад +1

    For applications would you consider using a pyproject.toml as standard for putting all requirements into one place (and the file can be used to configure other aspects) to reduce requirements file bloat?

    • @anthonywritescode
      @anthonywritescode  Год назад

      no I would not -- did you watch the video? I showed my application setup as well

    • @subjekt5577
      @subjekt5577 Год назад

      Any reason you forego pyproject.toml completely? Or just historical inertia?

  • @hiyadmn9damy
    @hiyadmn9damy 2 года назад

    Very useful ,thans

  • @DavidDellsperger
    @DavidDellsperger 2 года назад +1

    But, what if I don't have tests because I write flawless code the first time?

  • @hunnydoh
    @hunnydoh 2 года назад +1

    Speaking of favoring single files why not get rid of tox.ini and just incorporate into setup.cfg?

    • @anthonywritescode
      @anthonywritescode  2 года назад

      they have different interpolation modes

    • @hunnydoh
      @hunnydoh 2 года назад

      would be curious to know what the behavioral differences are then between setup.cfg and tox.ini. Other than cosmetic [tox:tox] in setup.cfg vs [tox] in tox.ini for example.

    • @anthonywritescode
      @anthonywritescode  2 года назад +1

      well for starters tox uses curly braces and setuptools uses % substitution and there's a lot of situations where one breaks the other. it's some of the motivation for using an actual structured data format (toml / etc.)

  • @ArielVolovik
    @ArielVolovik 11 месяцев назад

    If you dont pin dependencies for libraries, doesnt that mean that when you later clone a repo, you cant run it, because you wont knoe what dependencies you need to pip install?

    • @anthonywritescode
      @anthonywritescode  11 месяцев назад +1

      pinning means ==, the dependencies are still listed

  • @matthiashomann6381
    @matthiashomann6381 8 месяцев назад

    For a single file library, isn't it possible to include `ty.typed` via the `[options.package_data]` section entry `astpretty = py.typed` ?

  • @teoconserv9954
    @teoconserv9954 2 года назад +1

    How do you version, tag, package and release?

  • @longstoryveryshort
    @longstoryveryshort 4 месяца назад

    any updates since this upload?

  • @b_0rk
    @b_0rk 2 года назад +1

    Hello sir kindly would you consider relicensing all of your projects under the B0RK V1000 license

    • @anthonywritescode
      @anthonywritescode  2 года назад

      is it a derivative of the WTFPL?

    • @b_0rk
      @b_0rk 2 года назад

      @@anthonywritescode no, it's a derivative of Yu-Gi-Oh

  • @jrib
    @jrib 2 года назад

    In a single-file project with just a single test file at the root level, how do you exclude that test file from mypy?

    • @anthonywritescode
      @anthonywritescode  2 года назад

      I don't do that, but it's not different from what I show in the video

    • @jrib
      @jrib 2 года назад

      ​@@anthonywritescode It is different in that your tests aren't typed. So you tell mypy to ignore the whole tests/ dir. Just wondering how to do that for single files. This doesn't work
      [mypy-test_file_name]
      disallow_untyped_defs = false

    • @anthonywritescode
      @anthonywritescode  2 года назад

      works fine for me, you must have a typo

  • @StanislavSchmidt1
    @StanislavSchmidt1 2 года назад

    How do you run the code in the application project without installing it? By modifying PYTHONPATH? Or is it always single files that can be run as scripts?

    • @anthonywritescode
      @anthonywritescode  2 года назад

      `PYTHONPATH` is always wrong, and scripts are almost always wrong -- use `python -m module.name`

    • @StanislavSchmidt1
      @StanislavSchmidt1 2 года назад

      @@anthonywritescode Gotcha, thanks! I'm still wondering how one would deal with multiple source files and imports. E.g. if I have app/x.py and app/y.py running python -m app.x works, but writing "import y" in x.py doesn't. How would one go about structuring this?

    • @anthonywritescode
      @anthonywritescode  2 года назад +3

      always use absolute imports to import `app/y.py` you'd use `app.y` as your import

    • @StanislavSchmidt1
      @StanislavSchmidt1 2 года назад

      @@anthonywritescode that does the job, thanks :)

  • @MrHaste12
    @MrHaste12 2 года назад

    Hey Anthony, why did you stop using vim?