xvik / gradle-use-python-plugin

Use python modules in gradle build

Home Page:https://xvik.github.io/gradle-use-python-plugin/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Cannot figure out how to run a particular (older) version of Python

lazarillo opened this issue · comments

The issue, I'm sure, is my own lack of understanding, or maybe a lack of documentation.

But I cannot figure out how to:

  1. Check if a particular version of Python is available.
  2. Install that version if it is not available.
  3. Use that newly installed version.

I am trying to specifically install a significantly older version of Python 3 than my provider (GCP) puts on its build machines by default, because I want to make sure that the package I am building and uploading is sufficiently backward compatible.

Can someone explain how I can do this, with an example? I have the following, but this is only setting the minimum value, and checkPython does not help me to install a new version.

import ru.vyarus.gradle.plugin.python.task.PythonTask
import ru.vyarus.gradle.plugin.python.PythonExtension.Scope.VIRTUALENV_OR_USER

plugins {
    id("ru.vyarus.use-python") version "3.0.0"
}

var pythonVersion = "3.8.17"

python {
    minPythonVersion = pythonVersion
    minPipVersion = '23.2.1'
    pip("protobuf:4.24.0")
    pip("pdm:2.8.2")
}

Also, I am doing this because I need to build a python package and then publish it to our private (Python) repository. If there is already a pre-built task to do this, I can use that task, too, but for now I already have everything working, except for setting the Python path.

Plugin does not install python, it just use already installed python version. Min (python and pip) version properties exists just to fail-fast your build and prevent running with too low python (pip) version. Just a check.

It was an intentional limitation because it's not easy to do automatic python installation in all possible situations (mostly, due to often limited rights).

To install python you could use some other plugin (like jetbrains envs plugin, maybe there are other plugins) or use something else (for example, rely on your CI abilities).

If you have docker installed on your build server, then you can simply use docker image with required python version: plugin would run python tasks inside docker and so there would be no need to install python locally.