39

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 want to tell what minimum version of python the user should install to be able to run the script.

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? Commented Apr 15, 2014 at 9:32
  • @MartijnPieters I wanna tell to user what version of python he should install on his system Commented 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. Commented 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. Commented 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. Commented Apr 15, 2014 at 9:37

2 Answers 2

45

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.

Sign up to request clarification or add additional context in comments.

Comments

1

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.

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.