[Distutils] [proposal] module dependency specification and overriding for packages

Nick Coghlan ncoghlan at gmail.com
Sat Sep 10 06:37:02 EDT 2016


On 9 September 2016 at 16:46, Ronny Pfannschmidt
<opensource at ronnypfannschmidt.de> wrote:
> Hi,
>
> while trying to vendor packages that depend on six, i noticed a problematic
> implication
>
> it is impossible to do this without patching those modules, as such adding a
> fragile maintenance burden.

It's already possible to do this without patching by writing an
"install aliases" function that looks something like:

    import sys
    import myapp._vendor.six

    def install_module_aliases():
        sys.modules["six"] = myapp._vendor.six

Run that early in your app startup (before you import anything else),
and "import six" will get your vendored version from the module cache
rather than looking for the normal one.

For app level bundling, though, it's really better to find a way to
deploy a full venv if possible, rather than vendoring things (for
library level work, aim to avoid vendoring in general and use
dependency version specifiers instead).

Cheers,
Nick.

-- 
Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia


More information about the Distutils-SIG mailing list