{"id":15885928,"url":"https://github.com/pmeier/pytorch-pip-shim","last_synced_at":"2026-05-18T04:01:54.728Z","repository":{"id":55950268,"uuid":"308974207","full_name":"pmeier/pytorch-pip-shim","owner":"pmeier","description":"Patch pip to play ball with PyTorch","archived":false,"fork":false,"pushed_at":"2020-12-04T20:13:52.000Z","size":35,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-08T08:06:09.862Z","etag":null,"topics":["installation","patch","pip","pytorch","shim","utility"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pmeier.png","metadata":{"files":{"readme":"README.rst","changelog":null,"contributing":"CONTRIBUTING.rst","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-10-31T21:22:50.000Z","updated_at":"2022-02-28T16:31:31.000Z","dependencies_parsed_at":"2022-08-15T10:10:28.298Z","dependency_job_id":null,"html_url":"https://github.com/pmeier/pytorch-pip-shim","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pmeier%2Fpytorch-pip-shim","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pmeier%2Fpytorch-pip-shim/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pmeier%2Fpytorch-pip-shim/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pmeier%2Fpytorch-pip-shim/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pmeier","download_url":"https://codeload.github.com/pmeier/pytorch-pip-shim/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246847053,"owners_count":20843438,"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":["installation","patch","pip","pytorch","shim","utility"],"created_at":"2024-10-06T05:20:42.592Z","updated_at":"2025-10-20T02:34:56.363Z","avatar_url":"https://github.com/pmeier.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"``pytorch-pip-shim``\n====================\n\n.. start-badges\n\n.. list-table::\n    :stub-columns: 1\n\n    * - package\n      - |license| |status|\n    * - code\n      - |isort| |black| |mypy| |lint|\n    * - tests\n      - |tests| |coverage|\n\n.. end-badges\n\n- `What is it?`_\n- `Why do I need it?`_\n- `How do I install it?`_\n- `How do I use it?`_\n- `How do I uninstall it?`_\n- `How do I configure it?`_\n- `How does it work?`_\n\nDisclaimer\n==========\n\nNeither this project (``pytorch-pip-shim``) nor its author\n(`Philip Meier \u003chttps://github.com/pmeier\u003e`_) are affiliated with\n`PyTorch \u003chttps://pytorch.org\u003e`_ in any way. PyTorch and any related\nmarks are\n`trademarks of Facebook, Inc \u003chttps://pytorch.org/assets/brand-guidelines/PyTorch-Brand-Guidelines.pdf\u003e`_.\n\nWhat is it?\n===========\n\n``pytorch-pip-shim`` is a small background utility that eases the installation process\nwith ``pip`` for PyTorch and third-party packages that depend on its distributions.\nAfter the shim is inserted, you can install PyTorch with ``pip`` like you do with any\nother package.\n\nWhy do I need it?\n=================\n\nPyTorch is fully ``pip install`` able, but PyPI, the default ``pip`` search index, has\nsome limitations:\n\n1. PyPI regularly only allows binaries up to a size of\n   `approximately 60 MB \u003chttps://github.com/pypa/packaging-problems/issues/86\u003e`_. You\n   can `request a file size limit increase \u003chttps://pypi.org/help/#file-size-limit\u003e`_\n   (and the PyTorch team probably did that), but it is still not enough: the Windows\n   binaries cannot be installed through `PyPI \u003chttps://pypi.org/project/torch/#files\u003e`_\n   due to their size.\n2. PyTorch uses local version specifiers to indicate for which computation backend the\n   binary was compiled, for example ``torch==1.6.0+cpu``. Unfortunately, local\n   specifiers are not allowed on PyPI. Thus, only the binaries compiled with the latest\n   CUDA version are uploaded. If you do not have a CUDA capable GPU, downloading this\n   is only a waste of bandwidth and disk capacity. If on the other hand simply don't\n   have the latest CUDA driver installed, you can't use any of the GPU features.\n\nTo overcome this, PyTorch alos hosts *all* binaries\n`themselves \u003chttps://download.pytorch.org/whl/torch_stable.html\u003e`_. To access them, you\nstill can use ``pip install``, but have to use some\n`additional options \u003chttps://pytorch.org/get-started/locally/\u003e`_:\n\n.. code-block:: sh\n\n  $ pip install torch==1.6.0+cpu -f https://download.pytorch.org/whl/torch_stable.html\n\nWhile this is certainly an improvement, it also has it downside: in addition to the\ncomputation backend, the version has to be specified exactly. Without knowing what the\nlatest release is, it is impossible to install it as simple as ``pip install torch``\nnormally would.\n\nAt this point you might justifiably as: why don't you just use ``conda`` as PyTorch\nrecommends?\n\n.. code-block:: sh\n\n  $ conda install pytorch cpuonly -c pytorch\n\nThis should cover all cases, right? Well, almost. The above command is enough if you\njust need PyTorch. Imagine the case of a package that depends on PyTorch, but\ncannot be installed with ``conda`` since it is hosted on PyPI? You can't use the ``-f``\noption since the package in question is not hosted by PyTorch. Thus, you now have to\nmanually track down (and resolve in the case of multiple packages) the PyTorch\ndistributions, install them in a first step and only install the actual package (and\nall other dependencies) afterwards.\n\nIf just want to use ``pip install`` like you always did before without worrying about\nany of the stuff above, ``pytorch-pip-shim`` was made for you.\n\nHow do I install it?\n====================\n\nInstalling ``pytorch-pip-shim`` is as easy as\n\n.. code-block:: sh\n\n  $ pip install pytorch-pip-shim\n\nSince it depends on ``pip`` and it might be upgraded during installation,\n`Windows users \u003chttps://pip.pypa.io/en/stable/installing/#upgrading-pip\u003e`_ should\ninstall it with\n\n.. code-block:: sh\n\n  $ python -m pip install pytorch-pip-shim\n\nHow do I use it?\n================\n\nAfter ``pytorch-pip-shim`` is installed there is only a single step to insert the shim:\n\n.. code-block:: sh\n\n  $ pytorch-pip-shim insert\n\nAfter that you can use ``pip`` as you did before and ``pytorch-pip-shim`` handles the\ncomputation backend auto-detection for you in the background.\n\nIf you want to remove the shim you can do so with\n\n.. code-block:: sh\n\n  $ pytorch-pip-shim remove\n\nYou can check its status with\n\n.. code-block:: sh\n\n  $ pytorch-pip-shim status\n\nHow do I uninstall it?\n======================\n\nUninstalling is as easy as\n\n.. code-block:: sh\n\n  $ pip uninstall pytorch-pip-shim\n\nBy doing so, ``pytorch-pip-shim`` automatically removes the shim if inserted.\n\nHow do I configure it?\n======================\n\nOnce inserted, you don't need to configure anything. If you don't want the computation\nbackend auto-detected but rather want to set it manually ``pytorch-pip-shim`` adds two\nCLI options to ``pip install``:\n\n- ``--computation-backend \u003ccomputation_backend\u003e``\n- ``--cpu``\n\nHow does it work?\n=================\n\nThe authors of ``pip`` **do not condone** the use of ``pip`` internals as they might\nbreak without warning. As a results of this, ``pip`` has no capability for plugins to\nhook into specific tasks. Thus, the only way to patch ``pip`` s functionality is to\nadapt its source in-place. Although this is really bad practice, it is unavoidable for\nthe goal of this package.\n\n``pystiche-pip-shim`` inserts a shim into the ``pip`` main file, which decorates the\nmain function. Everytime you call ``pip install``, some aspects of the installation\nprocess are patched:\n\n- While searching for a download link for a PyTorch distribution, ``pytorch-pip-shim``\n  replaces the default search index. This is equivalent to calling ``pip install`` with\n  the ``-f`` option only for PyTorch distributions.\n- While evaluating possible PyTorch installation candidates, ``pytorch-pip-shim`` culls\n  binaries not compatible with the available hardware.\n\n.. |license|\n  image:: https://img.shields.io/badge/License-BSD%203--Clause-blue.svg\n    :target: https://opensource.org/licenses/BSD-3-Clause\n    :alt: License\n\n.. |status|\n  image:: https://www.repostatus.org/badges/latest/wip.svg\n    :alt: Project Status: WIP\n    :target: https://www.repostatus.org/#wip\n\n.. |isort|\n  image:: https://img.shields.io/badge/%20imports-isort-%231674b1?style=flat\u0026labelColor=ef8336\n    :target: https://timothycrosley.github.io/isort/\n    :alt: isort\n\n.. |black|\n  image:: https://img.shields.io/badge/code%20style-black-000000.svg\n    :target: https://github.com/psf/black\n    :alt: black\n   \n.. |mypy|\n  image:: http://www.mypy-lang.org/static/mypy_badge.svg\n    :target: http://mypy-lang.org/\n    :alt: mypy\n\n.. |lint|\n  image:: https://github.com/pmeier/pytorch-pip-shim/workflows/lint/badge.svg\n    :target: https://github.com/pmeier/pytorch-pip-shim/actions?query=workflow%3Alint+branch%3Amaster\n    :alt: Lint status via GitHub Actions\n\n.. |tests|\n  image:: https://github.com/pmeier/pytorch-pip-shim/workflows/tests/badge.svg\n    :target: https://github.com/pmeier/pytorch-pip-shim/actions?query=workflow%3Atests+branch%3Amaster\n    :alt: Test status via GitHub Actions\n\n.. |coverage|\n  image:: https://codecov.io/gh/pmeier/pytorch-pip-shim/branch/master/graph/badge.svg\n    :target: https://codecov.io/gh/pmeier/pytorch-pip-shim\n    :alt: Test coverage via codecov.io\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpmeier%2Fpytorch-pip-shim","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpmeier%2Fpytorch-pip-shim","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpmeier%2Fpytorch-pip-shim/lists"}