Skip to content

requirements allow a SciPy too old to import the package #1107

Description

@thc1006

Describe the bug

requirements.txt allows SciPy versions that cannot import the package:

numpy>=1.17
scipy>=1.0

rocketpy/simulation/monte_carlo.py imports at module level:

from scipy.stats import bootstrap

Quoting the SciPy 1.7.0 release notes:

scipy.stats.bootstrap has been added to allow estimation of the confidence interval and standard error of a statistic.

So anything from SciPy 1.0 to 1.6 satisfies the declared floor and then fails on import rocketpy, because monte_carlo is reached from the package __init__. Not a degraded feature, an ImportError before anything runs.

The NumPy floor has a milder version of the same problem. pyproject.toml says requires-python = ">=3.10", and NumPy did not ship a full set of cp310 wheels until 1.21.3:

numpy 1.21.0   no cp310 wheels
numpy 1.21.2   cp310 for manylinux x86_64 and aarch64 only
numpy 1.21.3   adds macOS universal2, macOS arm64 and win_amd64

A resolver on 3.10 that lands below that builds NumPy from source, which is slow where it works and a wall of compiler errors where it does not.

To Reproduce

pip install "scipy==1.6.3" "numpy>=1.17"
python -c "import rocketpy"

import rocketpy does reach it: the package __init__ pulls in
rocketpy.simulation.monte_carlo, which I checked by listing sys.modules
afterwards. Removing the attribute from an installed SciPy gives the shape of
what an old one would produce:

ImportError: cannot import name 'bootstrap' from 'scipy.stats'

I have not installed SciPy 1.6 to see it for real, since it has no wheels for
the Python versions this package supports, which is rather the point.

Expected behavior

The floors describe what the code needs:

numpy>=1.21.3
scipy>=1.7.0

Both are old. SciPy 1.7.0 is from June 2021 and NumPy 1.21.3 from October 2021, and the package already requires Python 3.10, which is newer than either.

Additional context

Found while reviewing the requirements line in #1054. That pull request raises numpy>=1.13 to >=1.17, since SeedSequence is a 1.17 feature, and I have noted the wider floor question there rather than widening the change. The SciPy floor is untouched by it and predates it.

Worth saying that this is not urgent in practice: anyone installing today gets current versions, and CI pins nothing this low. It bites the person who pins deliberately, or resolves in an old environment, and what they get is an ImportError rather than a message about versions.

requests, pytz, simplekml and dill carry no floor at all, which is a separate question and probably fine.

Verified on develop at 235dc6e.

Signed-off-by: thc1006 84045975+thc1006@users.noreply.github.com

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions