28

I have built an application with python. How can I detect minimum version of Python that my application needs?

Like Django , in that website it tells you the minimum version of python that it required (example: 2.6.6 and later).

It means I wanna tell to user what minimum version of python he should install on his system

6
  • You mean at runtime so the script can tell the user to use a newer version, or so you know what version of Python to use by looking at the code?
    – Martijn Pieters
    Apr 15, 2014 at 9:32
  • @MartijnPieters I wanna tell to user what version of python he should install on his system
    – mortymacs
    Apr 15, 2014 at 9:33
  • That's a question of experience and reading the docs; what features does your script use, and when where these added to the language.
    – Martijn Pieters
    Apr 15, 2014 at 9:35
  • Look at the various What's New documents and see when a feature or module you rely on was added.
    – Martijn Pieters
    Apr 15, 2014 at 9:35
  • 3
    Do you have a test suite? Run it with older versions and see if it passes. There is no automated method of testing for feature use.
    – Martijn Pieters
    Apr 15, 2014 at 9:37

2 Answers 2

37

I know this is an old post, but I've recently started a project called Vermin that tries to detect the minimum required Python versions needed to run code. It will do what you request, @Mortezaipo.

0
2

There isn't really an automated way to check what features your code is using and correlate that to specific Python versions. If your code relies on fixed bugs or additional keywords to existing methods, the version detection gets harder still.

Generally speaking, you set the minimal version based on experience and knowledge of what features you are using; you can check the What's New documentation.

If you have a comprehensive test suite, you could just run that on older Python versions; if all your tests pass you support that older version.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.