-
-
Notifications
You must be signed in to change notification settings - Fork 35
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
Installing from prawcore sdist fails without requests in build environment #164
Comments
What would this look like? I'm hesitant to do the other two options because we have tooling that increments |
It would be by a large margin the most involved of the proposed changes; I almost didn't include it at all, other than to point out that solving the bigger issue of the Of course, this as mentioned this is likely a far too involved solution just to solve this problem, as opposed to the much more general one of eager-loading your various submodules in the
Could you not simply replace
As you say seems very unlikely that users would be importing it from We can actually quantify this, though, using e.g. grep.app which searches all of GitHub, which finds:
So, as far as public code on GitHub goes Nevertheless, we could resolve even this small chance by importing
That's true, though there are non-trivial tooling and ecosystem benefits to declaring it as static metadata, and I assume you could just tweak your version bump script to update the version there too—though I understand the desire to single-source it, of course. Overall, Option 1 seems by far the least net disruptive. I could submit a PR for this, if you'd prefer. Thanks! |
Makes sense to me.
If you'd like, please do! |
Thanks! Opened as PR #165 |
Thanks for circling back and closing this out! I opened praw-dev/praw#2004 to cover this in PRAW itself (and we in turn might want to reconsider Approach 2 here, if that's what's desired over there and in |
Describe the Bug
Due to the use of Flit's fallback automatic metadata version extraction needing to dynamically import the package
__init__.py
instead of reading it statically (see pypa/flit#386 ) , since the actual__version__
is imported fromconst.py
, this requiresrequests
be installed in the build environment when building or installing from an sdist (or the source tree).This happens merely by chance to currently be a transitive backend dependency of
flit_core
and thus building in isolated mode works. However, this shouldn't be relied upon, as if eitherflit_core
orprawcore
's dependencies were to ever change, this would break isolated builds too. Andrequests
isn't an exposed non-backend dependency offlit-core
, so it doesn't actually get installed otherwise.This means Requests must be manually installed (not just the explicitly pyproject,toml-specified build dependencies) if building/installing
prawcore
in any other context thanpip
's isolated mode, e.g. without the--no-build-isolation
flag, via the legacy non-PEP 517 builder, or via other tools or most downstream ecosystems that use other build isolation mechanisms. In particular, this was an issue on conda-forge/prawcore-feedstock#14 where I was packaging the newprawcore
2.4.0 version for Conda-Forge—you can see the full Azure build log.Of course, this can be worked around for now by manually installing
requests
into the build environment, but that's certainly not an ideal solution as it adds an extra build dependency (and its dependencies in turn), requires extra work by everyone installing from source (without build isolation), makes builds take longer, and is fragile and not easily maintainable/scalable long term for other runtime dependencies.Desired Result
Prawcore is able to be built and installed without installing requests, or relying on it happening to be a transitive build backend dependency of
flit_core
and present "by accident".There are several ways to achieve this, all potentially reasonable options:
__version__
to be in__init__.py
directly, so Flit can find it by static inspection without triggering an importversion
as static metadata in thepyproject.toml
instead of relying on dynamic backend-specific detection__init__.py
to be as minimal as possible and avoid inefficiently importing your entire package (or only do so lazily), as generally recommended.Code to reproduce the bug
The
Reddit()
initialization in my code example does not include the following parameters to prevent credential leakage:client_secret
,password
, orrefresh_token
.Relevant Logs
This code has previously worked as intended.
Yes
Operating System/Environment
Any, tested Linux, Windows
Python Version
Any; tested 3.10, 3.12
prawcore Version
2.4.0 (newely introduced due to switch to Flit)
Anything else?
Just for reference, this was the build environment on Azure:
And this was the relevant portion of the build log:
The text was updated successfully, but these errors were encountered: