-
-
Notifications
You must be signed in to change notification settings - Fork 344
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Switch packaging to PDM/Hatch/Poetry #2790
Comments
FWIW, one should differentiate between the management tool and the build backend. For instance it is perfectly feasible to use PDM to manage the lockfile etc and
and works for any project using PEP 621. In that sense it is also possible to switch between build backends easily (ie use setuptools instead of hatchling). In reality though one usually ends up with one build backend since one often uses one or two plugins to read the version from SCM etc… I like |
I vote for Poetry purely because a) I know it b) there's no actual benefit to being standards compliant other than pointing at your pyproject and going "look, standards compliant!". |
I disagree on That said I don't have any real problem with either approach. If the argument ends up to choose poetry because a PR request exists for it I can offer to write a "competing" one for PDM. This way we could compare it to #2595 and see what ends up nicer -- in the end I would see moving the source code into |
I've had great experiences using PDM. And when I've needed the extra packaging flexibility that Hatch offers, I've also happily used PDM and Hatch together -- Hatch for the build-backend, and PDM for managing the dependencies and lock file. I described this workflow here |
FYI don't forget that we also have an open PR for hatchling. If a little out of date... And |
Well, in that sense // I have answered the same via email but github was down a few minutes ago, so dunno, maybe this message appears a second time. |
Ah, found it #2449 |
Thanks, I hadn't appreciated the distinction... though trying to read up on it I'm still somewhat confused. I do think there's something to gain from going with a somewhat common setup, be that PDM+hatchling or something else, to make it easier for [short-term] contributors to understand and/or improve/fix bugs in the setup.
what's the effects in practice of doing I'm personally starting to lean in the direction of PDM, as that seems powerful enough to support all our needs without having to resort to fancy stuff, and is widespread and well-documented. |
To try to illustrate the difference between a management tool and a build backend, let me focus on a specific kind of "management tool": build frontends. Here's a few build frontends:
All of these will build a wheel, with maybe a bit more going on behind the scenes but... Now, what's a build backend? This can be:
Both these are obviously non-exhaustive, but the big difference is a build backend is something specific by PEP ??? (forgot the number :( ) and gets called by the build frontend through a specified API (this is why In my personal opinion, I don't like using a "frontend" that I have to install globally or use consistently: I don't want to deal with that and it adds some level of ambiguity IMO. Don't let that stop us from using one if it's the best choice, just wanted to offer my opinion :P |
Oh agreed, but I guess it is important to define what one wants to achieve. For instance PDM (and I think poetry as well) support custom scripts so you can say
As far as I can tell no, the moment you generate a requirements.txt from all those tools you are limiting yourself to one version of python / operating system and generally loose all the "optional" stuff that is required for windows or older python versions (I am not a user of pip-tools so I might be wrong there…).
Flit is not build backend,
Oh yeah, there are ups and downs to everything. The good thing is noone forces you to use a specialized "frontend" as long as you are fine using
This alone already provides multiple options like running in a venv or not which leads to more potential issues. What is unique here for |
A recent entry in this space is Pyprojectx (disclosure: never used it, just heard about it). It looks like it fills the need that some dev tools need their own environment with a separate dependency tree, while remaining reproducible. Therefore you can have:
|
There is also a new article about some experiences with Hatch: https://andrich.me/2023/08/switching-to-hatch/ |
So kind of like
We do have about a million PR's open messing with pretty much every single part of this project, but I think you can go ahead with this and we can start tinkering with it to see how it works out and how much of the test scripts/CI/etc it affects. |
Does |
not afaik, I think I found that same issue researching #2681 (comment) |
The intention of this is better isolation. `trio` is no longer accidentally on the (python) path and as such requires an explicit installation for usage, this helps uncover issues in packaging data etc early on (see https://packaging.python.org/en/latest/discussions/src-layout-vs-flat-layout/). This serves as the basis for switching to another build system as well; refs python-trio#2790.
The intention of this is better isolation. `trio` is no longer accidentally on the (python) path and as such requires an explicit installation for usage, this helps uncover issues in packaging data etc early on (see https://packaging.python.org/en/latest/discussions/src-layout-vs-flat-layout/). This serves as the basis for switching to another build system as well; refs python-trio#2790.
The intention of this is better isolation. `trio` is no longer accidentally on the (python) path and as such requires an explicit installation for usage, this helps uncover issues in packaging data etc early on (see https://packaging.python.org/en/latest/discussions/src-layout-vs-flat-layout/). This serves as the basis for switching to another build system as well; refs python-trio#2790.
The intention of this is better isolation. `trio` is no longer accidentally on the (python) path and as such requires an explicit installation for usage, this helps uncover issues in packaging data etc early on (see https://packaging.python.org/en/latest/discussions/src-layout-vs-flat-layout/). This serves as the basis for switching to another build system as well; refs python-trio#2790.
The intention of this is better isolation. `trio` is no longer accidentally on the (python) path and as such requires an explicit installation for usage, this helps uncover issues in packaging data etc early on (see https://packaging.python.org/en/latest/discussions/src-layout-vs-flat-layout/). This serves as the basis for switching to another build system as well; refs python-trio#2790.
The intention of this is better isolation. `trio` is no longer accidentally on the (python) path and as such requires an explicit installation for usage, this helps uncover issues in packaging data etc early on (see https://packaging.python.org/en/latest/discussions/src-layout-vs-flat-layout/). This serves as the basis for switching to another build system as well; refs python-trio#2790.
The intention of this is better isolation. `trio` is no longer accidentally on the (python) path and as such requires an explicit installation for usage, this helps uncover issues in packaging data etc early on (see https://packaging.python.org/en/latest/discussions/src-layout-vs-flat-layout/). This serves as the basis for switching to another build system as well; refs python-trio#2790.
The intention of this is better isolation. `trio` is no longer accidentally on the (python) path and as such requires an explicit installation for usage, this helps uncover issues in packaging data etc early on (see https://packaging.python.org/en/latest/discussions/src-layout-vs-flat-layout/). This serves as the basis for switching to another build system as well; refs python-trio#2790.
The intention of this is better isolation. `trio` is no longer accidentally on the (python) path and as such requires an explicit installation for usage, this helps uncover issues in packaging data etc early on (see https://packaging.python.org/en/latest/discussions/src-layout-vs-flat-layout/). This serves as the basis for switching to another build system as well; refs python-trio#2790.
The intention of this is better isolation. `trio` is no longer accidentally on the (python) path and as such requires an explicit installation for usage, this helps uncover issues in packaging data etc early on (see https://packaging.python.org/en/latest/discussions/src-layout-vs-flat-layout/). This serves as the basis for switching to another build system as well; refs python-trio#2790.
My biggest gripes are the requirements files in particular, from the OP:
so if switching tooling doesn't get rid of
I feel like this shouldn't be necessary - but possibly depends on the tool we switch to. If it's a tool that also manages virtualenvs it might be needed globally, but otherwise you should be able to 1. create a virtualenv, 2. install the packaging tool in it, 3. install the package. And IIRC you shouldn't need to do step 2 explicitly either. |
What I was imagining in the other issue is that we could just ping pre-commit's bot to regenerate *requirements.txt whenever necessary, so it never has to be touched locally. It would not directly solve the different python versions thing so maybe it would only be a stopgap solution at most. |
I think getting rid of But I agree with the python version thing -- that's my main problem with |
Yes, it's hard. Though I now prefer what I described in a comment there — jazzband/pip-tools#826 (comment) — a matrix of lockfiles. Sure, it's not ideal from the number of files perspective, but it's quite straightforward to understand otherwise. And with tooling (like I have for tox there) that selects proper lockfiles for the env, it's not that bad, and the CI stability is just fantastic! Generating deptrees is hard, especially for things that cannot physically be built on the platform where you run the resolver. I think, it's possible if the entire tree has wheels published for all the platform in the matrix, but as soon as there's no matching wheel and the resolver is forced to build from sdist, that starts influencing the output of the depresolver dynamically. There's no way around it, regardless of what env management tool you choose. And I've found that having a matrix of pip-native constraints is easier, than it seems. In other news, I've just merged a PR in pip-tools the other day, that allows pinning the build deps. Normally, people concentrate on the runtime dependencies, overlooking that there are things that aren't pinned during the build. Hopefully, that'll be addressed soon. I'm sure, this project needs tox for env management + lockfiles per each supported env, not some fancy CLIs that attempt to manage more than they should on devs' systems. As for the backends, I've heard that hatchling is nice (for pure-Python projects, of course), but setuptools provides everything necessary, so there's no real benefit in replacing it. |
* Move to src-layout. The intention of this is better isolation. `trio` is no longer accidentally on the (python) path and as such requires an explicit installation for usage, this helps uncover issues in packaging data etc early on (see https://packaging.python.org/en/latest/discussions/src-layout-vs-flat-layout/). This serves as the basis for switching to another build system as well; refs #2790. --------- Co-authored-by: CoolCat467 <[email protected]> Co-authored-by: jakkdl <[email protected]>
@altendky I just posted an explainer about the things I think people misunderstand regarding the constraint files, in case you're curious: jazzband/pip-tools#1326 (comment). |
Maintainer of Hatch/Hatchling here! Let me know if I can be of assistance in reviews or a PoC. FYI if you want to use more than the backend (I saw concerns about lock files) then there is actually a nice plugin that does locking https://github.com/juftin/hatch-pip-compile |
That looks cool! I wonder if there's something similar for tox so I wouldn't have to write my own thing. |
Ah I see, is this org sort of locked into tox? edit: hmm, I don't see tox |
No, but I am. |
This was merged #2860 I would be curious in hearing feedback as to why the original approach of Hatchling was not pursued. Any feedback I get gets incorporated to make it easier for everyone! My goal is for Hatchling to be the best and easiest choice for every use case (right now extension modules is the only hang up). I now maintain a comparison page which was lacking before, perhaps documentation was a factor https://hatch.pypa.io/latest/why/#build-backend |
I don't think it's anything specific against hatchling, moreso that the other pr which was just closed was in limbo. But we're still considering hatchling, I think? Main point against it right now is that it doesn't have something better than pip-compile as a lock file... (But we haven't chosen poetry yet at least IMO cause that dictates a lot like CLI tool and Python-requires stuff) |
There's some discussion in #2681, and some more in Gitter, but let's make a dedicated issue for this.
Alternatives:
*-requirements.txt
locally, as is currently required to pass CI whenever changing something in*-requirements.in
, requires having a matching python version and possibly other requirements on your environment.Does not support lockfiles, but there are different ways to get around the above problem
quoting @apollo13
quoting @agronholm
The text was updated successfully, but these errors were encountered: