aboutcode-org / typecode

7 stars 9 forks source link

failover to python-magic detection if vendored library not present #17

Closed tardyp closed 3 years ago

tardyp commented 3 years ago

This allows scancode to work on platforms not supported by typecode-libmagic e.g. M1 Macs or windows WSL

100% tests pass with this change on my M1 Mac

pombredanne commented 3 years ago

Something that's a head scratcher to me is: where is the magic DB obtained from when not provided by a plugin?

tardyp commented 3 years ago

as per doc:

 The magic_load() function must be used to load the colon separated
 list of database files passed in as filename, or NULL for the
 default database file before any magic queries can performed.

 The default database file is named by the MAGIC environment
 variable.  If that variable is not set, the default database file
 name is /usr/local/share/misc/magic.  magic_load() adds “.mgc” to
 the database filename as appropriate.

I added the version api which might help in case of a later bug report

tardyp commented 3 years ago

@pombredanne shall we merge this? I think you may need to re run flaky azure pipelines.

pombredanne commented 3 years ago

Merged in #20