linkedin / pygradle

Using Gradle to build Python projects
https://github.com/linkedin/pygradle
Apache License 2.0
588 stars 147 forks source link

how to tell the plugin to use python3 instead of python2 #315

Closed petrabrunner closed 5 years ago

petrabrunner commented 5 years ago

Hi. I dont know if there is a way to do this, and have not found a way to circumvent this any other way (yet), so I thought I'd create an issue.

I noticed the plugin seems to use the python version which reacts to the "python" command to create a virtualenvironment. meaning: If there are 2 different python versions installed on a system (in my case it is a ci machine which cannot be changed because both versions are needed) and I expect it to use python3 it will not use it because the "python" command starts the 27 version.

... is there a way to tell the plugin to use python37 to create a virtual environment?

my gradle script looks like this atm:

plugins {
    id "com.linkedin.python-sdist" version "0.9.11"
}

repositories {
    pyGradlePyPi()
}

tasks.flake8.enabled = false
tasks.buildDocs.enabled = false
tasks.pytest.enabled = false
tasks.packageSdist.enabled = false
tasks.installSetupRequirements.enabled = false
tasks.installTestRequirements.enabled = false
tasks.installBuildRequirements.enabled = false
tasks.installProject.enabled = false

as a side note: I have already tried this: https://devops.stackexchange.com/questions/3150/is-it-possible-to-set-a-minimum-python-version-in-pygradle this always resulted in a gradle error. (will post if requested)

petrabrunner commented 5 years ago

for anyone else wondering:

this is how it finally worked for me:

plugins {
    id 'com.linkedin.python' version "0.9.11"
}

repositories {
    pyGradlePyPi()
}

tasks.flake8.enabled = false
tasks.buildDocs.enabled = false
tasks.pytest.enabled = false
tasks.installSetupRequirements.enabled = false
tasks.installTestRequirements.enabled = false
tasks.installBuildRequirements.enabled = false
tasks.installProject.enabled = false

python {
    details {
        systemPythonInterpreter = file("/usr/bin/python3")
    }
}