linkedin / pygradle

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

"Unable to find or execute python" python details set version=3 only works for python3.7 #345

Open wssrcok opened 4 years ago

wssrcok commented 4 years ago

in an Ubuntu18.04 container, I keep getting this error:

* What went wrong:
A problem occurred evaluating root project 'example-project'.
> Unable to find or execute python

I tried install python3.5, 3.6 and 3.8. but only python3.7 works. I know the work around would be setting systemPythonInterpreter = file("/usr/bin/python3"). But it's not portable: works on ubuntu but doesn't work on my mac (which has different path: /usr/local/bin/python3)

I'd be appreciate if someone can look at the issue and point out why is it the case. I'm not familiar with kotlin so I got very impatient when I look at the code base..

I have reproduced this issue in example-project with this Dockerfile and build.gradle (the original build.gradle had many errors) Dockerfile:

FROM ubuntu:18.04

RUN apt update && apt install python3-distutils python3 vim git openjdk-8-jdk gradle -y

RUN git clone https://github.com/linkedin/pygradle.git

COPY build.gradle /pygradle/examples/example-project/

CMD ["bash"]

build.gradle

buildscript {
    repositories {
            mavenLocal()
            maven {
              url "https://plugins.gradle.org/m2/"
            }
            mavenCentral()
            jcenter()
    }
    dependencies{
        classpath "gradle.plugin.com.linkedin.pygradle:pygradle-plugin:0.9.11"
    }
}

apply plugin: "com.linkedin.python-sdist"
apply plugin: com.linkedin.gradle.python.plugin.WheelFirstPlugin

python {
        details {
                pythonVersion = '3'
        }
        forceVersion('pypi', 'flake8', '3.2.1')
        forceVersion('pypi', 'six', '1.13.0')
        forceVersion('pypi', 'pbr','1.10.0')
}

dependencies {
    python 'pypi:requests:2.9.1'
    test 'pypi:mock:2.0.0'
}

repositories {
   pyGradlePyPi()
}
asubbotin-snaplogic commented 3 years ago

You may try to set the location of the interpreter (the example is on Kotlin):

extensions.configure<com.linkedin.gradle.python.PythonExtension>("python") {
    details.setSystemPythonInterpreter("/usr/local/bin/python3")
    details.setPythonVersion("3.9")
}