-
-
Notifications
You must be signed in to change notification settings - Fork 48
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
breaking api change in 1.1.0 for importlib_resources.path(package, folder_name) #85
Comments
In GitLab by @jaraco on Mar 2, 2020, 18:08 Ugh. That's really unfortunate. Underlying this issue here is that prior to the introduction of So now we need to decide what's the best path from here. I'm not sure restoring compatibility with the old lenient behavior is necessarily the best approach. I'll need to do more investigation. |
In GitLab by @jaraco on Mar 2, 2020, 18:36 I'm tempted to recommend that users who relied on this behavior should do:
It's ugly, but
It does possibly require rewrite and doesn't fix issues with previous versions of the code against newer versions of importlib_resources. Is that a case that needs to be supported? edit: the recommendation won't work because .path() is a context manager |
In GitLab by @RonnyPfannschmidt on Mar 3, 2020, 02:47 thanks for providing context, i can totally go with "worked due to a unfortunate bug, was never intended to work in 1.x" as the code itself was added using the for the time being we pinned |
In GitLab by @jaraco on Mar 3, 2020, 05:14 mentioned in merge request !92 |
In GitLab by @jaraco on Mar 3, 2020, 05:31 In !92, I've drafted a change that would restore the prior expectation (suitable for a bugfix release) and in !93 drafted a subsequent change that would officially exclude that support in a backward-incompatible change. If you or other find that it's more than a minor inconvenience to adapt to the new API, I'll consider cutting a release to temporarily restore the expectation. |
In GitLab by @RonnyPfannschmidt on Mar 3, 2020, 06:08 thanks for dealing that out on such a short notice i already ported to the new api's, in my own case, it was possible to sort out by porting one of the dependencies to use the other and then following up with the api port on that one but people in the wild may face something similar without the ability to do such a workaround i suggest waiting for more input on this issue before cutting a release |
In GitLab by @maxking on Mar 9, 2020, 02:44 We are having the same issue with Mailman project :) I did manage to create a fix for the new API pretty easily, but since the new API does not exist in Standard Library, compatibility across Python versions becomes really hard. Looks like many linux distros (Debian/Ubuntu/Gentoo that I know of) do not want to package I am not sure what the release policy for this library is, but we won't be able to use the new API until it is a part of the standard library too and since this is a new API and not bugfix, I am assuming that would be only in 3.9? So, I guess my request is that could you keep the backwards compatibility in |
In GitLab by @jaraco on Mar 9, 2020, 03:42 I would advise Debian, etc to supply the backport for Python 3.8 and earlier now that it provides new functionality that won’t be backported to Python. In fact, they should probably not try to associate the two products and just supply them independently. As for supplying the compatibility longer, my intention was to restore compatibility long enough for the 1.x releases to be compatible, but to remove the functionality immediately in a 2.x release. That will only be valuable if your project can pin to Perhaps projects that require this compatibility should simply use:
|
In GitLab by @jaraco on Mar 18, 2020, 19:43 Interestingly, in bpo-39980, a user reported the inverse of this issue, indicating that it was unexpected that the implementation provided the interface on which the OP was relying. Given that users have been able to find workarounds and that other workarounds exist, I'd rather move forward with the head as it's implemented and I'll withdraw the associated MRs. Feel free to comment or open a new issue if there's a more demanding use-case to restore this functionality. |
In GitLab by @jaraco on Mar 18, 2020, 19:43 closed |
Related: https://bugs.python.org/issue44162 |
importlib.resources.path specifies that directories are not resources and throws an error. Incorporated fix from Jaraco in python/importlib_resources#85 sys.getcheckinterval is deprecated as of 3.2, use sys.getswitchinterval instead per https://docs.python.org/3.8/library/sys.html#sys.getcheckinterval Added 3.9 to Tox and Github Workflows to ensure testing was accomplished.
The function importlib.resoures.path worked for directories only by accident. Resources should never be directories. See: https://bugs.python.org/issue44162 This has now been fixed using `importlib.resources.files` as suggested in: python/importlib_resources#85
The function importlib.resoures.path worked for directories only by accident. Resources should never be directories. See: https://bugs.python.org/issue44162 This has now been fixed using `importlib.resources.files` as suggested in: python/importlib_resources#85
Hi, @jaraco, how can this be used to pass the entire folder to a separate program that requires a filesystem path to the I see how this can be used to iterate over files inside the directory within Python, but I can't do that here. |
FTR, I've archived the abandoned branches:
|
In GitLab by @RonnyPfannschmidt on Mar 2, 2020, 03:38
in a project we used
with importlib_resources.path(package, "data") as data_path:
to get a folder path (as back then traversal had not been supported)
with the update to
1.1.0
we see aIsADirectoryError: [Errno 21] Is a directory: '/builds/*******/*****/.venv/lib64/python3.7/site-packages/***/data'
The text was updated successfully, but these errors were encountered: