fs.dropboxfs icon indicating copy to clipboard operation
fs.dropboxfs copied to clipboard

Crash when trying to open URL

Open dargueta opened this issue 6 years ago • 15 comments

Due to a fix for a bug in setuptools, installation of the package goes fine but because this package's name is fs.dropboxfs and not fs-dropboxfs, pip interprets the package to be namespaced in fs (more on namespacing here). You won't encounter problems when installing this locally, but if you install from PyPI and try to open a Dropbox URL, you get this:

Traceback (most recent call last):
  ...
  File "/Users/tux/.pyenv/versions/2.7.15/envs/gds/lib/python2.7/site-packages/fs/opener/registry.py", line 228, in open_fs
    default_protocol=default_protocol,
  File "/Users/tux/.pyenv/versions/2.7.15/envs/gds/lib/python2.7/site-packages/fs/opener/registry.py", line 187, in open
    opener = self.get_opener(protocol)
  File "/Users/tux/.pyenv/versions/2.7.15/envs/gds/lib/python2.7/site-packages/fs/opener/registry.py", line 139, in get_opener
    "could not load entry point; {}".format(exception)
fs.opener.errors.EntryPointError: could not load entry point; No module named dropboxfs.opener

Platform:

  • OS: Mac OSX
  • Python: 2.7 and 3.7
  • Pip: 19.1.1
  • setuptools: 40.8.0 and 41.0.1

dargueta avatar Jul 31 '19 18:07 dargueta

Why not do the same as all the other pyfilesystem2 packages and put dropboxfs under an empty "fs" directory?

rkhwaja avatar Aug 12 '19 22:08 rkhwaja

Why not do the same as all the other pyfilesystem2 packages and put dropboxfs under an empty "fs" directory?

Like, completely empty? That doesn't work.

I tried following the setuptools docs, but it kept breaking. I've been tearing my hair out trying to figure out why it works locally and fails on Travis; turns out it's this issue that makes pip not play nicely with namespace packages when installing locally. I think I've fixed it now.

dargueta avatar Aug 12 '19 23:08 dargueta

I mean no files in it except for the dropboxfs directory - that's the way all the other pyfilesystem2 packages work.

rkhwaja avatar Aug 12 '19 23:08 rkhwaja

Which ones, exactly? I looked at fs.archive as an example and it didn't work. I don't even know how that one works.

dargueta avatar Aug 12 '19 23:08 dargueta

Actually, you're right, some of them do work the same way as this repo:

  • https://github.com/PyFilesystem/s3fs
  • https://github.com/PyFilesystem/webdavfs

Some work with an empty fs directory:

  • https://github.com/althonos/fs.archive
  • https://github.com/rkhwaja/fs.googledrivefs
  • https://github.com/rkhwaja/fs.onedrivefs
  • https://github.com/althonos/fs.smbfs
  • https://github.com/althonos/fs.sshfs

rkhwaja avatar Aug 12 '19 23:08 rkhwaja

Of the second list, some of those aren't installable (missing setup.py) and the others cheat by exhaustively listing submodules using packages in the setup.cfg file and only using relative imports. (I think that's how they get around the namespace issue.)

dargueta avatar Aug 13 '19 00:08 dargueta

Okay so now I'm getting a new kind of error:

>>> import os
>>> import fs
>>> fs_url = 'dropbox://dropbox.com?access_token=' + os.getenv('DEV_DROPBOX_TOKEN')
>>> dx = fs.open_fs(fs_url)

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'open_fs'

'module' object has no attribute 'open_fs'

I suspect this has something to do with the namespacing but I'm following setuptools' own documentation...

dargueta avatar Aug 13 '19 06:08 dargueta

@rkhwaja this was fixed in #8 but that hasn't been released on PyPI yet. You can probably close this ticket now.

dargueta avatar Jan 31 '20 19:01 dargueta

Of the second list, some of those aren't installable (missing setup.py) and the others cheat by exhaustively listing submodules using packages in the setup.cfg file and only using relative imports. (I think that's how they get around the namespace issue.)

On my projects, I use poetry to make a wheel and install them that way.

Also, it's not my project so I can't really close issues :)

rkhwaja avatar Jan 31 '20 19:01 rkhwaja

Oh duh I can close it because I filed it. 🤦‍♂

dargueta avatar Jan 31 '20 19:01 dargueta

@zopyx can we do a release to PyPI include the fix? Latest version up there doesn't have this.

dargueta avatar Jan 31 '20 19:01 dargueta

https://pypi.org/project/fs.dropboxfs/0.2.2.post2/

zopyx avatar Jan 31 '20 19:01 zopyx

Thanks!

dargueta avatar Jan 31 '20 19:01 dargueta

This still doesn't install properly. I installed the post2 version via poetry and it installs the dropboxfs directory, with dropboxfs.py under it, at the root of site-packages (it should install under the fs directory). I think this is why the opener doesn't work.

rkhwaja avatar Apr 26 '21 23:04 rkhwaja

it installs the dropboxfs directory, with dropboxfs.py under it, at the root of site-packages

I think this is fine, as it seems how s3fs is structured (take a look at the README example). I'm guessing something's still messed up with the entrypoint, possibly because the package name makes pip think it's a namespaced package but it actually isn't.

dargueta avatar May 08 '21 15:05 dargueta