{"id":21940233,"url":"https://github.com/aneeshdurg/multiversionpython","last_synced_at":"2025-03-22T15:13:48.461Z","repository":{"id":220233368,"uuid":"750910330","full_name":"aneeshdurg/multiversionpython","owner":"aneeshdurg","description":"PoC of multiversioning in python","archived":false,"fork":false,"pushed_at":"2024-02-01T00:12:57.000Z","size":7,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-01-27T14:53:59.773Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/aneeshdurg.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2024-01-31T15:08:35.000Z","updated_at":"2024-02-01T12:14:26.000Z","dependencies_parsed_at":"2024-02-01T01:34:57.247Z","dependency_job_id":null,"html_url":"https://github.com/aneeshdurg/multiversionpython","commit_stats":null,"previous_names":["aneeshdurg/multiversionpython"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aneeshdurg%2Fmultiversionpython","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aneeshdurg%2Fmultiversionpython/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aneeshdurg%2Fmultiversionpython/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aneeshdurg%2Fmultiversionpython/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aneeshdurg","download_url":"https://codeload.github.com/aneeshdurg/multiversionpython/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244973775,"owners_count":20541025,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-29T02:29:53.408Z","updated_at":"2025-03-22T15:13:48.435Z","avatar_url":"https://github.com/aneeshdurg.png","language":"Python","readme":"# multiversionpython\nThe goal of this project is to enable having conflicting dependencies in python\nby allowing multiple versions of the same library to be concurrently installed.\nThis is achieved by isolating every dependancy into it's own venv, and hooking\nevery `import` call to redirect them to importing within the appropriate env.\n\nFor example, consider the following dependency graph:\n```\n           my_app\n             |\n    +--------+--------+\n    |                 |\n    v                 v \n  dep_a             dep_b\n    |                 |\n    v                 v\npandas==2.2.0     pandas==2.0.3\n```\n\nNormally, this is not resolvable, and either `dep_a` or `dep_b` needs to be\npatched or upgraded. Sometimes, such patching/upgrading is non-trivial, or\notherwise not desirable. This project demonstrates that using tools that are\nalready included with python, we can extend python's module management to allow\nsuch dependency graphs.\n\nThe source code for intercepting imports and redirecting them to appropriate\nvenvs is in `importshim/`. A demo that shows how the example above might work is\nin `demo/`.\n\nThis project is currently a proof of concept. With some work, maybe it could be\nintegrated into existing python tools and made more stable.\n\nA more detailed explanation of what is happening is below:\n\n+ tooling generates venvs + additional runtime importing facilities\n  + each venv contains one dependency and it's sub-deps in isolation\n  + importer will allow application to import libraries from each dependent venv\n    by means of generated config file.\n  + importer will allow libraries to only import from within their isolated\n    environment by inspecting stack frames to determine the origin of `import`\n    calls.\n\nThe directory structure for a project might look like:\n```\n.\n├── SOURCE_FILES...\n├── pyproject.toml\n├── app \u003c-- This is the environment we want to install/run \u003cSOURCE_FILES\u003e in\n│   ├── bin\n│   │   └── ...\n│   ├── include\n│   │   └── ...\n│   ├── lib\n│   │   └── python3.10\n│   │       └── site-packages\n│   │           └── importshim\n│   │               ├── import_map.json \u003c-- generated file\n│   │               └── __init__.py\n│   └── pyvenv.cfg\n└── py_modules  \u003c-- entire directory is generated by tooling\n    ├── pandas\n    │   ├── ...\n    │   ├── lib\n    │   │   └── python3.10\n    │   │       └── site-packages\n    │   │           └── ...\n    │   └── pyvenv.cfg\n    └── numpy\n        ├── ...\n        ├── lib\n        │   └── python3.10\n        │       └── site-packages\n        │           └── ...\n        └── pyvenv.cfg\n```\n\nhere `py_modules` contains the isolated environments for each \"top-level\"\ndependancy identified by `pyproject.toml`, `app` is the venv for the project,\ncontaining only the generated import machinery, and `SOURCE_FILES` is the actual\nproject source code.\n\n\nAt present, there is no sharing of common sub-dependencies across modules.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faneeshdurg%2Fmultiversionpython","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faneeshdurg%2Fmultiversionpython","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faneeshdurg%2Fmultiversionpython/lists"}