[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#877849: [tryton-debian] Namespace conflict for python-magic



Adam Hupp wrote...

> I've pushed an update here:
>
> https://github.com/ahupp/python-magic/tree/libmagic-compat
>
> It includes a copy of libmagic's bindings, wrapped in deprecation
> warnings.  So apps should work regardless of which they depend on.
> Could you take a look and see if this works for your case?

There are two glitches, you got mails in private about these.
Doing a first round of tests showed regressions so far.

Hence, here is a preliminary packaging of python-magic for Debian:

  https://www.in-ulm.de/~cbiedl/debian/python-magic/python-magic_0.4.15-1~exp1.dsc

Debianites, please give it a try.

About the deprecation warning: I figured out right now (at least for
Debian) it would mostly scare users. Once Christos acknowledges your
work (hopefully) and deprecates the [file] python-magic implementation,
it's about time to alert authors of programs that use python-magic but
no earlier.

Therefore I created a switch that mutes that warning unless a
PYTHONMAGIC_WARN_DEPRECATED environment variable is set, patch below.
Using this switch, users can already test whether a particular
application needs an adjustment for the [pypi] API.

At least in Debian, I expect this transition to take two years anyway.

Cheers,

    Christoph
Subject: Make the deprecation warning switchable
Author: Christoph Biedl <debian.axhn@manchmal.in-ulm.de>
Date: 2018-01-08
Forwarded: soon

--- a/magic/__init__.py
+++ b/magic/__init__.py
@@ -19,6 +19,7 @@
 
 import sys
 import glob
+import os
 import os.path
 import ctypes
 import ctypes.util
@@ -325,9 +326,10 @@
 
     def deprecation_wrapper(compat, fn, alternate):
         def _(*args, **kwargs):
-            warnings.warn(
-                "Using compatability mode with libmagic's python binding",
-                DeprecationWarning)
+            if "PYTHONMAGIC_WARN_DEPRECATED" in os.environ:
+                warnings.warn(
+                    "Using compatibility mode with libmagic's python binding",
+                    DeprecationWarning)
 
             return compat[fn](*args, **kwargs)
         return _

Attachment: signature.asc
Description: Digital signature


Reply to: