-
-
Notifications
You must be signed in to change notification settings - Fork 174
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
Feat entrypoints #56
Feat entrypoints #56
Conversation
This sounds cool! |
Hi @althonos I'm not entirely familiar with the magic that is going on here. The previous opener mechanism had the benefit that it was quite transparent . But it does sound like letting setuptools do the work is a good idea, and the lazy loading is nice. So 👍 for the PR. Would you mind updating the docs you wrote? Will |
I edited the |
Sorry for the delay. I think I grok entry points now. Is it good to merge? |
Wonderful. Sorry I didn't answer earlier. I'll submit a PR to update the
documentation with my FS extensions once you create a new release and I
make sure everything works fine.
|
Did you get the email I sent you earlier? I sent you some ideas re namespace packages and openers... |
Hi ! This PR attempts to switch the
fs.opener
micro-API to thesetuptools
entry points mecanism.Rationale
By the words of Kenneth Reitz, 180° turns are encouraged. While I was actively developing fs.sshfs and fs.proxy lately, I learned a lot about
setuptools
and Python packages distribution in general (since instead of using a plainsetup.py
as I used to, I decided to switch to a purely declarative setup using thesetup.cfg
file). In particular, that:setup.py
pkg_resources
is bundled withsetuptools
, and since your requirements includesetuptools
, we can safely rely on it instead of pkgutil which is not as powerful.Proposed edits
Unfortunately, for #1, it's useless in our case since native namespace packages cannot have an
__init__.py
, meaning their namespace cannot be overloaded (goodbye,fs.open_fs
) !For #2, I replaced
pkgutil
namespace definitions withpkg_resources
one. Not a lot changed though, but since thepkg_resources
is more recent, I put more faith in it.But for #3, there were actual things to enhance: openers. I edited the
Registry
to load openers dynamically usingpkg_resources
to load entry points of thefs.opener
group. This triggers two major changes with extensions:fs
orfs.opener
namespaceFS
andOpener
and still only be imported when theopen_fs
requires it to).Attaching an opener class to an protocol is now done declaratively in the
setup.py
file:or even in a
setup.cfg
file:and then entry points are loaded at runtime:
Perks
fs.opener
module, which in turns mean libraries do not require to enter thefs
namespace at all to declare an opener !fs.open_fs
was able to load filesystem submodules only when needed to, but thefs.opener
package was exhaustively imported, causing some overhead. With this declarative style, onlyfs.opener.{base, errors, registry}
are imported, and even the opener declaration is imported on-the-go !egg
files (although, who uses eggs ?)Drawbacks
fs.opener
.