You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
RFC: use relative imports instead of absolute? #356
Currently msgpack uses absolute imports for its modules, e.g.:
if os.environ.get('MSGPACK_PUREPYTHON'):
from msgpack.fallback import Packer, unpackb, Unpacker
else:
try:
from msgpack._cmsgpack import Packer, unpackb, Unpacker
except ImportError:
from msgpack.fallback import Packer, unpackb, Unpacker
Recently I worked on bundling msgpack inside another project to work around an incompatible system-wide install of msgpack (Fedora 30, borgbackup requires msgpack 0.5.6 but F30 ships 0.6.1).
One thing which made bundling a lot easier was to use relative imports in msgpack:
if os.environ.get('MSGPACK_PUREPYTHON'):
from .fallback import Packer, unpackb, Unpacker
else:
try:
from ._cmsgpack import Packer, unpackb, Unpacker
except ImportError:
from .fallback import Packer, unpackb, Unpacker
That way I could copy msgpack's code to another location and it would not use the system-wide install.
I could create a PR if you would be interesting in merging this. Otherwise I'll carry some local patches for Fedora until we can drop the bundling.
Activity
methane commentedon May 10, 2019
I'm OK for it.
FelixSchwarz commentedon May 10, 2019
Ok, thanks. I added a pull request.