开发者

Is there a way to enforce usage of a certain version of the python runtime

I would like to execute a python script via maven (say maven-antrun-plug开发者_Go百科in) only if the python runtime version is 3.2. How do I enforce this restriction via maven?


How would maven execute this script? Call it directly, or call python <script>? Note that there may be several versions of Python installed on a single machine simultaneously.

In any case, to know what your system understands by "python", you can always run:

python --version 

and parse the output.

Or some variation on this to provide the facts your script needs.

python -c 'import sys;print sys.version_info'


Put in a hard exit as follow:

import sys
assert sys.version_info >= (3, 7, 9), f"Minimum python version supported is 3.7.9. Current version is: {sys.version}"

If fails, it will exit with AssertionError: Minimum python version supported is 3.7.9. Current version is: 3.7.8 (default, Dec 19 2020, 14:37:46)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜