-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
chore(Python): Centralize Python dependencies in pyproject.toml #9535
Conversation
I can see the value in this, though I'm not really sure this is the way to go. Have to think on it a little bit. Don't forget that there is also a Thinking on it a bit more: I don't see why lint dependencies / docs dependencies should be in the pyproject.toml. These should not be visible for end users - and anything in pyproject.toml will become 'visible'. The dev dependencies (matplotlib etc.) should be available, and they already were. Maybe we should just abolish |
I know, that is why I put above:
PEP621 recommends development dependencies to be under a "dev" tag. https://peps.python.org/pep-0621/#recommend-that-tools-put-development-related-dependencies-into-a-dev-extra (EDIT: it was suggested in the discussions as a common workflow, see also Poetry, but it is not recommend for or against in this specific PEP). Note that we do not advertise the tags to end users, so I don't see a problem with it either? In an ideal situation, users can do
This is the problem, you can't do that without triggering |
Some tests fail due to connectorx, the message is to install |
Ok, I think this is now good for review, added docs dependencies, dried the code and fixed small bugs. There is a test error due to utf8 / csv parsing, I dont see how that could be due to this set of changes. |
@@ -3150,12 +3150,12 @@ def write_database( | |||
"'sqlalchemy' not found. Install polars with 'pip install polars[sqlalchemy]'." | |||
) from exc | |||
|
|||
engine = create_engine(connection_uri) | |||
engine_sa = create_engine(connection_uri) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mypy complians (rightly so) when SQL Alchemy is installed.
I've given it some thought, and I really dislike this custom tech. It's an additional hurdle for new contributors, and it's another thing to maintain and document (it's currently not documented anywhere). In general, I try to avoid custom tech like this unless there is really no way around it. In fact, often the first thing I do when I start working on a project is getting rid of stuff like this. What usually happens is the guy that built it is no longer around and no one really remembers what it was supposed to do. And then after spending hours on finding out what it does, it turns out the whole thing can be replaced using some handy feature that the guy didn't know about, or wasn't available at the time. However, it's a good find that there is a discrepancy between
To me, the first step to address this would be to simply fix the discrepancies (use the right versions everywhere) and document somewhere that these should align: a well-placed comment somewhere should do at first. Then you can try to get rid of the "dependencies" part of And then maybe there's a way to eliminate duplication in the other places as well - not sure if you've looked into this as well. So, in my view, the approach in this PR is not the way to go. But as always, I am willing to be convinced otherwise. |
Ok, seems I missed the |
Good find, that indeed looks like what we need! |
Only occurs if SQLAlchemy is installed.
Pip incorrectly uses the released Polars version, leading to outdated definitions.
We should probably keep linting and docs requirements separate. We don't want to have to compile and install Polars every time we run linting / build the docs. I wish we could use Poetry, it allows you to install dependency groups separately from the main package... I'd say focus on the development dependencies for now, that already solves all issues listed in the PR description. |
Ok, this approach has some drawbacks. First, Second, pip supports self references (i.e. see pypa/pip#10393). However, somewhere this breaks, Circling back to the original idea I had was to simply use I have some other ideas still, but it seems we are hitting the limits of what is being supported by pip unfortunately. |
Pyproject.toml + requirements-dev.txt + show_versions aligned. See pola-rs#9535.
Subset of pola-rs#9535, only moving package dependencies and leaving test+lint+docs alone.
In the category hacks that I considered but rejected, maybe useful for others: use the dry-run mode and parse the output to get the list of non-polars packages to install
|
I'm closing this, as the existing tooling is not sufficient for our use case per the above. The cleanest I can come up with is parse pyproject.toml to grab all our dependencies, which would solve the duplication of dependency specifications, at the expense of custom tooling. |
I have noticed several inconsistencies between
pyproject.toml
and the various requirements files:requirements.txt
, but not inpyproject.toml
EDIT: this was pydantic, not matplotlibpyproject.toml
. I.e., we know we should not use the latest version, but we don't tell our users who dopip install polars[all]
and hit the bug we have already identified.These, and possibly more, point out that having the same information in multiple places will inevitably lead to discrepancies over time.
I started with moving everything to
pyproject.toml
under the relevant tags. Then, I went into the rabbit hole ofpip install
+maturin
, coming to realise that we cannot install dependencies frompyproject.toml
using pip cli without avoiding the Polars build. The polars build uses the slowmaturin build
command. This seems a known limitation ofpip
, we cannot modify this behaviour. So I decided to write a bit of code to pull out the dependencies of pyproject.toml, resolve thepolars[ ]
tags, and pass topip install
.Pros:
Cons:
tomlli
dependency (for developers only!)Haven't done docs yet, open to thoughts to see if this is a good way forward.
Important to note that even as a developer, you continue to interact with
make
, so it is all behind the scenes.