gemmi icon indicating copy to clipboard operation
gemmi copied to clipboard

Add support for PEP 519 (file system path protocol)

Open Anthchirp opened this issue 4 years ago • 3 comments

Gemmi currently cannot deal with python path protocol objects (PEP 519, PEP 428):

$ python -c "import gemmi,pathlib; gemmi.cif.read_file(pathlib.Path('z'))"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
TypeError: read_file(): incompatible function arguments. The following argument types are supported:
    1. (filename: str) -> gemmi.cif.Document

Invoked with: PosixPath('z')

(Presumably this is the relevant section in the PEP)

Anthchirp avatar Apr 19 '21 07:04 Anthchirp

I googled how it works in combination with pybind11, but I haven't found anything. So I think I'll wait until the path protocol is supported in pybind11, or until I come across a recipe how to handle path protocol objects.

wojdyr avatar Apr 19 '21 09:04 wojdyr

Is it that what you are searching for? https://github.com/pybind/pybind11/pull/2730/commits/53da968ee6774a11273955cfb1821c91b72d35fe It is in version 2.7.0

dkratzert avatar Oct 25 '21 18:10 dkratzert

yes, actually I've seen it recently, but I left it for later. It can be used as an example how to support the path protocol.

wojdyr avatar Oct 25 '21 18:10 wojdyr