Add entry_points to setuptools in package being install

192 Views Asked by At

I have a python package fsspec. This library provides a way to register external filesystem (backend integration). One way to register the required filesystem is to add it to the entry_points in setuptools.

To accomplish the task, we can manually add the entry_points in the setup.py and then install the package. But what I am looking for is a way to programmatically make the entry pre/post installation of the fsspec package.

1

There are 1 best solutions below

2
On

I don't believe there is a simple way to update the metadata that normally gets written into your system during a package install. Digging through the code of setuptools or importlib.metadata might tell you how. It may be, that the Distribution object exposed by metadata can be edited in memory. The point of the approach is, that fsspec does not need to import anything (aside from importlib.metadata itself) to know what extra implementations are available.

However, you might get far enough by using fsspec.register_implementation, which is be done dynamically at runtime. The only downside is, that your package will need to be imported and the function called before you try to access the protocol it provides.