diff --git a/docs/source/api.rst b/docs/source/api.rst index 5385accc7..90a00bbef 100644 --- a/docs/source/api.rst +++ b/docs/source/api.rst @@ -237,6 +237,7 @@ documentation carefully before using any particular package. - `p9fs`_ for 9P (Plan 9 Filesystem Protocol) servers - `PyAthena`_ for S3 access to Amazon Athena, with protocol "s3://" or "s3a://" - `PyDrive2`_ for Google Drive access +- `fsspec-proxy`_ for "pyscript:" URLs via a proxy server - `s3fs`_ for Amazon S3 and other compatible stores, with protocol "s3://" - `sshfs`_ for access to SSH servers, with protocol "ssh://" or "sftp://" - `swiftspec`_ for OpenStack SWIFT, with protocol "swift://" @@ -254,6 +255,7 @@ documentation carefully before using any particular package. .. _dropbox: https://github.com/fsspec/dropboxdrivefs .. _dvc: https://github.com/iterative/dvc .. _fsspec-encrypted: https://github.com/thevgergroup/fsspec-encrypted +.. _fsspec-proxy: https://github.com/fsspec/fsspec-proxy .. _gcsfs: https://gcsfs.readthedocs.io/en/latest/ .. _gdrive: https://github.com/fsspec/gdrivefs .. _git: https://github.com/iterative/scmrepo diff --git a/fsspec/__init__.py b/fsspec/__init__.py index d7af775f7..452c78a05 100644 --- a/fsspec/__init__.py +++ b/fsspec/__init__.py @@ -1,5 +1,3 @@ -from importlib.metadata import entry_points - from . import caching from ._version import __version__ # noqa: F401 from .callbacks import Callback @@ -38,6 +36,10 @@ def process_entries(): + try: + from importlib.metadata import entry_points + except ImportError: + return if entry_points is not None: try: eps = entry_points() diff --git a/fsspec/implementations/asyn_wrapper.py b/fsspec/implementations/asyn_wrapper.py index ee009f3bb..f7e885b24 100644 --- a/fsspec/implementations/asyn_wrapper.py +++ b/fsspec/implementations/asyn_wrapper.py @@ -2,6 +2,7 @@ import functools import inspect +import fsspec from fsspec.asyn import AsyncFileSystem, running_async @@ -42,14 +43,24 @@ class AsyncFileSystemWrapper(AsyncFileSystem): The synchronous filesystem instance to wrap. """ - protocol = "async_wrapper" + protocol = "asyncwrapper", "async_wrapper" cachable = False - def __init__(self, fs, *args, asynchronous=None, **kwargs): + def __init__( + self, + fs=None, + asynchronous=None, + target_protocol=None, + target_options=None, + **kwargs, + ): if asynchronous is None: asynchronous = running_async() - super().__init__(*args, asynchronous=asynchronous, **kwargs) - self.sync_fs = fs + super().__init__(asynchronous=asynchronous, **kwargs) + if fs is not None: + self.sync_fs = fs + else: + self.sync_fs = fsspec.filesystem(target_protocol, **target_options) self.protocol = self.sync_fs.protocol self._wrap_all_sync_methods() diff --git a/fsspec/registry.py b/fsspec/registry.py index 3db04c5ab..da28382e7 100644 --- a/fsspec/registry.py +++ b/fsspec/registry.py @@ -72,13 +72,13 @@ def register_implementation(name, cls, clobber=False, errtxt=None): "class": "fsspec.implementations.arrow.HadoopFileSystem", "err": "pyarrow and local java libraries required for HDFS", }, - "async_wrapper": { - "class": "fsspec.asyn_wrapper.AsyncWrapperFileSystem", - }, "asynclocal": { "class": "morefs.asyn_local.AsyncLocalFileSystem", "err": "Install 'morefs[asynclocalfs]' to use AsyncLocalFileSystem", }, + "asyncwrapper": { + "class": "fsspec.implementations.asyn_wrapper.AsyncFileSystemWrapper", + }, "az": { "class": "adlfs.AzureBlobFileSystem", "err": "Install adlfs to access Azure Datalake Gen2 and Azure Blob Storage", @@ -180,6 +180,10 @@ def register_implementation(name, cls, clobber=False, errtxt=None): "class": "ossfs.OSSFileSystem", "err": "Install ossfs to access Alibaba Object Storage System", }, + "pyscript": { + "class": "pyscript_fsspec_client.client.PyscriptFileSystem", + "err": "Install requests (cpython) or run in pyscript", + }, "reference": {"class": "fsspec.implementations.reference.ReferenceFileSystem"}, "root": { "class": "fsspec_xrootd.XRootDFileSystem",