Oldest Supported NumPy

2023.12.21 · active · verified Thu Apr 09

Oldest-supported-numpy is a meta-package that dynamically provides the oldest compatible NumPy version for a given Python interpreter and platform. It ensures that if a platform only gained support for NumPy wheels at a more recent version, that specific version is provided. The current version is 2023.12.21, and its release cadence is irregular, typically updated when new NumPy versions or platform support changes warrant it.

Warnings

Install

Quickstart

This quickstart demonstrates how to install `oldest-supported-numpy` and then verifies which NumPy version was installed by importing it and checking `np.__version__`. It then shows a basic NumPy operation.

import subprocess
import sys

# Install oldest-supported-numpy, which in turn installs a specific numpy version
# This example assumes pip is installed and available
# In a real environment, you'd typically do 'pip install oldest-supported-numpy' once.
# For this quickstart, we ensure numpy is uninstalled first to demonstrate the effect.

try:
    # Uninstall numpy if present to ensure oldest-supported-numpy picks it up
    subprocess.run([sys.executable, '-m', 'pip', 'uninstall', '-y', 'numpy'], check=True, capture_output=True)
except subprocess.CalledProcessError as e:
    # This is expected if numpy isn't installed initially
    pass # print(f"Uninstall failed (expected if not present): {e.stderr.decode().strip()}")

# Install oldest-supported-numpy, which will pull in a specific numpy version
subprocess.run([sys.executable, '-m', 'pip', 'install', 'oldest-supported-numpy'], check=True, capture_output=True)

# Now, import numpy and check its version
import numpy as np

print(f"NumPy version installed by oldest-supported-numpy: {np.__version__}")

# Basic NumPy usage
a = np.array([1, 2, 3])
b = np.array([4, 5, 6])
c = a + b
print(f"Example NumPy array operation: {c}")

view raw JSON →