interfax / interfax-python

Fax send and receive in Python with the InterFAX REST API
https://www.interfax.net/en/dev/python
MIT License
12 stars 13 forks source link

Is Libmagic required? #2

Closed cbetta closed 8 years ago

cbetta commented 8 years ago

@danielknell this pip library relies on libmagic it seems. I'm trying to decide if this is wise? What is this for? Can we work without it? Is it easy to install on every OS (including windows)?

If we do need it we should look at making this dependency clear in the docs.

danielknell commented 8 years ago

libmagic is the mimemagic binding, its required for guessing mime types, the ruby gem also depends on the same library.

cbetta commented 8 years ago

@danielknell the ruby gem relies on the mimemagic gem but it does not rely on any other dependencies (including libmagic).

Could you have a look and see if there's any viable option that does not use libmagic? And if not, can we add a note to the docs pointing out this dependency?

UPIF-Marketing commented 8 years ago

@danielknell @cbetta Guys,

It might be overkill to use a third-party MIME detection library for the general case. Can we assume that the developer knows the media type he's providing?

Also, for those devs who don't know what their media type is (e.g. with those cryptic ones like application/vnd.openxmlformats-officedocument.presentationml.presentation), we have a handy extension-to-media-type conversion tool at https://rest.interfax.net/outbound/help/mediatype.

And for those who don't even know their file extensions, e.g. if they're receiving a buffer, we might point them to a third-party library.

@eyalnevo

cbetta commented 8 years ago

@danielknell @if-adam I am trying to find the right balance between:

  1. Ease of install (minimal dependencies)
  2. Ease of use (not having to specify mime type explicitly)
  3. Reliability (it always picking the right mime type for each file)

I'd be happy to consider any option, I just want to make sure @danielknell has considered all.

danielknell commented 8 years ago

filename based mime lookup seems fragile enough to be a non starter, and mime types tend to be poorly understood from what i have seen amongst more junior developers, so making it implicit has a bunch of benefits, but the library needs to be installed manually on windows though (its there by default on *nix and in homebrew for mac), which is also something to balance...

https://github.com/ahupp/python-magic there are some straightforward instructions to get it working on the projects homepage.

iin time should a pure python alternative emerge it would be worth using that, as it stands the options seem to be:

if no changes are made then the docs probably need an extra paragraph in the installation field to inform people of the dependency.

cbetta commented 8 years ago

@danielknell agreed that just using filenames is a no-go. So the only 2 options are:

  1. Use a pure python alternative
  2. Use libmagic

I'd like to make sure we searched for a library for options 1 (I assume you did now and it's not there). Therefore happy to go with option 2.

Please go ahead and add the extra install instructions and notes.

danielknell commented 7 years ago

experimented with puremagic, a pure python alternative to libmagic, results were disappointing...

cbetta commented 7 years ago

Ah that's sad to hear.