python-magic icon indicating copy to clipboard operation
python-magic copied to clipboard

Default magic_file to 'magic'

Open julian-r opened this issue 7 years ago • 7 comments

For windows it would be quite good, because then if the cwd contains the dll and the mgc file everything works out of the box :)

julian-r avatar Aug 14 '17 13:08 julian-r

How about a environment variable?

ahupp avatar May 05 '20 22:05 ahupp

Actually on second thought, I'd rather leave it up to the application to pass this through. Or do you have a situation where you don't own the code calling python-magic?

ahupp avatar May 06 '20 02:05 ahupp

Its actually quite simple: there is this binary package, which is compatible with the python build for windows: https://github.com/julian-r/file-windows/. The only problem is, that this python-magic modules does not find the the dll or the mgc file. If we could adjust this, i don't need to maintain (or in this case not maintain) a extra package (https://pypi.org/project/python-magic-bin/0.4.14/). I could take care about the dll and the visual studio build in the future. I could also take an evening to build egg's for windows, but i would try to not do this in an extra project. :)

julian-r avatar May 16 '20 20:05 julian-r

Okay, just did some investigation to my old memories:

  • This fork is able to build a mac and a windows binary egg. https://github.com/julian-r/python-magic My offer: I will help you maintaining the package, will take care about win and mac platforms. For unixes binary packages are not needed anyways. This will make the package for users on those platforms much more friendly and everyone with a build pipline can install a hassle free egg package :)

Hope that sounds interesting for you.

julian-r avatar May 16 '20 20:05 julian-r

I would love this feature! We are currently deploying to linux but partly developing using windows. For windows we have to use the python-magic-bin package. For linux python-magic. With this feature we could just have one package that works cross-platform.

Orangensaft avatar Jun 29 '20 20:06 Orangensaft

@julian-r I love that you provide the binaries, but my preference is to not include them in the standard package. Any existing users (by definition) already provide their own binaries, and would in general want to use the system-provided binary. Same goes for the magic file; switching to a non-system file would be a big surprise.

But I think the goal of making this more seamless is a good one. There's a general problem I have here of figuring out how to find the shared lib on various platforms, just look a the mess in magic.py to see all the special cases.

This feels like an issue of configuration to me; you have a single codebase and want to run it in different ways (e.g pointing at a new shared lib / magic file).

So I'll re-suggest the environment variable idea:

PYTHON_MAGIC_SHARED_LIB=something.dll PYTHON_MAGIC_DB=something.mgc

What do you think?

ahupp avatar Oct 14 '20 18:10 ahupp

@julian-r's Windows binaries being available on PyPI are really useful, and I would love them to be maintained somehow

davidfraser avatar Feb 23 '21 11:02 davidfraser

Merging into https://github.com/ahupp/python-magic/issues/293

ahupp avatar Aug 25 '23 18:08 ahupp