Skip to main content

# numpy-router

A lightweight runtime NumPy version router.

It allows Python applications to use different NumPy versions without reinstalling or modifying the environment.

The router intercepts the first real use of numpy and loads the appropriate version from a local cache.

It works with embedded Python distributions, machine‑learning frameworks, and environments where NumPy cannot be freely installed or upgraded.

---

## Features

- Lazy bootstrap: NumPy loads only when actually used.

- Version selection:

- requirements.txt next to the main script

- package dist-info metadata

- user‑forced version via environment variable

- fallback heuristic

- Router bypass switch.

- Cache inspection API.

- Compatible with native NumPy installations.

---

## Installation

pip install numpy-router

Then place the provided numpy\_router.pth file into your Python site-packages directory.

---

## Environment Variables

### NUMPY\_ROUTER\_VERSION=X.Y.Z

Force a specific NumPy version.

### NUMPY\_ROUTER\_OFF=1

Disable the router entirely and use native NumPy.

### NUMPY\_ROUTER\_CACHE=PATH

Override the cache directory.

---

## Cache Inspection

---


python

import numpy\_router

print(numpy\_router.cache())

---

## How It Works

---

┌──────────────────────────┐

│ Python starts │

│ site-packages loads .pth │

└───────────────┬──────────┘

│

▼

shim module installed

as sys.modules["numpy"]

│

▼

numpy_router wraps shim

with a lightweight proxy

│

▼

first attribute access on numpy

(e.g., np.ndarray, np.array)

│

▼

bootstrap runs

- resolve version

- download if needed

- extract to cache

- load real NumPy

- replace shim with real module

│

▼

all further imports use

real NumPy

Metadata

Release files for numpy-router 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for numpy-router 0.1.1
File Size Uploaded Provenance Actions
numpy_router-0.1.1.tar.gz 4.6 kB Without provenance Details for numpy_router-0.1.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for numpy-router 0.1.1
File Interpreter ABI Platform Actions
numpy_router-0.1.1-py3-none-any.whl Python 3 none any Details for numpy_router-0.1.1-py3-none-any.whl

Total release size: 9.9 kB

Release files / numpy_router-0.1.1.tar.gz

Download URL numpy_router-0.1.1.tar.gz
Size 4.6 kB
Tags Source
SHA-256 checksum
How to use checksums
491010d86f87a03521c5a42fdb981952bc3f97f99a2faf70086a8aed72a29b3c
BLAKE2b-256 checksum
How to use checksums
b69c7bc3e89887b0e6a9147bc1ca0caf1cdcb58718b4d0064fb9ccef73a9e971
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.10

Release files / numpy_router-0.1.1-py3-none-any.whl

Download URL numpy_router-0.1.1-py3-none-any.whl
Size 5.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ab83917ebf995112d6e5b564e0163da831841574eb3a44a26f6155eb98f3f465
BLAKE2b-256 checksum
How to use checksums
8bb33df121946f9f1427c85767cdd87cbc5a75eb54bee80790ac91201e486424
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.10

Security for numpy-router 0.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page