8

On a production server, I am forced to use python3.2. Sadly several of my dependencies require >=python3.4. Is there a way to find out what the latest version of a package is that can be used with a specific python version?

For instance, with python3.2, what version of numpy should be used?

(This is only an example, answers would ideally not focus on the example, but on the actual question).

Avinash
  • 2,093
  • 4
  • 28
  • 41
Private
  • 2,626
  • 1
  • 22
  • 39
  • 1
    There rarely is a *good* technical reason for such an old Python version. You should really consider upgrading or a side by side installation. If that is not possible at all use Docker. – Klaus D. Mar 07 '17 at 11:10
  • 1
    @KlausD. agreed, but I am using a managed service, I have no say in the python version. – Private Mar 07 '17 at 12:59

3 Answers3

5

Perhaps you could use environment markers to solve the problem?

These are strings that can be used in requirements.txt and setup.py files (under the install_requires argument) and look like:

numpy>=1.7,<2; python_version > '3.4'
numpy>=1.7,<1.12; python_version < '3.4'

They can help you match packages to Python versions with some flexibility.

Richard
  • 56,349
  • 34
  • 180
  • 251
2

This should work with pip>=22.2 (tested with Python 3.10.8 + pip 22.2.2) and give you the latest version of a package compatible with a given Python version:

python -m pip install numpy --dry-run --python-version 3.2 --no-deps --target foo

Output:

Collecting numpy
  Downloading numpy-1.12.1.zip (4.8 MB)
     ---------------------------------------- 4.8/4.8 MB 3.6 MB/s eta 0:00:00
  Preparing metadata (setup.py) ... done
Would install numpy-1.12.1

Extracted from this answer.

Flo
  • 59
  • 5
-1

You can go to individual package and check requirement. Like for Numpy you can check on github which tells Python version 2.7 or >= 3.4 required.

Avinash
  • 2,093
  • 4
  • 28
  • 41
  • That does not answer my question, it means I have to go through all the source code of all the packages to find the point in time when the requirements matched mine, and then select that specific release. Not a feasible option. – Private Mar 07 '17 at 11:59