Search code examples
pythondependenciesbackwards-compatibilitypython-packagingdeveloper-tools

As a python package maintainer, how can I determine lowest working requirements


While it is possible to simply use pip freeze to get the current environment, it is not suitable to require an environment as bleeding edge as what I am used too. Moreover, some developer tooling are only available on recent version of packages (think type annotations), but not needed for users. My target users may want to use my package on slowly upgrading machines, and I want to get my requirements as low as possible. For example, I cannot require better than Python 3.6 (and even then I think some users may be unable to use the package). Similarly, I want to avoid requiring the last Numpy or Matplotlib versions.

Is there a (semi-)automatic way of determining the oldest compatible version of each dependency?

Alternatively, I can manually try to build a conda environment with old packages, but I would have to try pretty randomly. Unfortunately, I inherited a medium-sized codebase (~10KLoC) with no automated test yet (I plan on making some, but it takes some time, and it sadly cannot be my priority). The requirements were not properly defined either so that I don't know what it has been run with two years ago.


Solution

  • Because semantic versionning is not always honored (and because it may be difficult from a developper standpoint to determine what is a minor or major change exactly for each possible user), and because only a human can parse release notes to understand what has changed, there is no simple solution.

    My technical approach would be to create a virtual environment with a known working combination of Python and libraries versions. From there, downgrade one version by one version, one lib at a time, verifying that it still works fine (may be difficult if it is manual and/or long to check).

    My social solution would be to timebox the technical approach to take no more than a few hours. Then settle for what you have reached. Indicate in the README that lib requirements may be overblown and that help is welcome.

    Without fast automated tests in which you are confident, there is no way to automate the exploration of the N-space (each library is a dimension) to find a some minimums.