GithubHelp home page GithubHelp logo

qiangf / multiversion Goto Github PK

View Code? Open in Web Editor NEW

This project forked from mitsuhiko/multiversion

0.0 3.0 0.0 91 KB

A hack that allows you to use different versions of the same library in the same Python process without clashes

License: Other

Python 100.00%

multiversion's Introduction

  multiversion
  ````````````

  What many (including myself) said could not be done is now working on
  any conforming Python 2.x interpreter.  How does it work?  Have a look
  at the example module.

  // Implementation
  
    The implementation works by rewriting import calls internally into an
    version encoded name.  That way we can still take advantage of the
    internal Python module caching.  The modules are found on the whole
    PYTHONPATH by looking for ``modulename-version``.  If such a folder
    exists it will add a fake module and provide whatever module is stored
    in there versioned.

    The rewriting is clever enough to track imports inside a module to
    itself and its submodules.

  // Limitations

    The boundary is the current file.  So you can't have two different
    versions of a library to be used by the same file.  But you can
    separate the code into two files, each of which depends on a different
    version of a specific library.

  // Why?

    Because I needed something for my EuroPython talk that involves all
    kinds of retarded hackery you really shouldn't be doing.

  // Does it work?

    Surprisingly well actually.

  // Example usage

    The following code will look for Jinja2 in a folder `jinja2-1.0`
    somewhere on the PYTHONPATH.  This folder will have to contain
    another folder called `jinja2` which is the actual package to
    be imported then.  Instead of a package it can also be a regular
    Python module.

      import multiversion
      multiversion.require_version('jinja2', '1.0')

      from jinja2 import Template
      ...

multiversion's People

Contributors

mitsuhiko avatar

Watchers

James Cloos avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.