Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python in gradle is using wrong python - it doesn't respect the PATH variable #3942

Closed
exalate-issue-sync bot opened this issue May 22, 2023 · 7 comments
Assignees

Comments

@exalate-issue-sync
Copy link

No description provided.

@exalate-issue-sync
Copy link
Author

Jakub Hava commented: [~accountid:557058:389d9607-5bd8-4611-8c6a-755fe9295223] my idea for the solution is to check PATH variable and pick the first python. This way we don't have to introduce new variable

@exalate-issue-sync
Copy link
Author

Michal Malohlava commented: Exec task should honor setting of PATH (inhering from parent env).

But in some cases people have binaries python, python2 and python3 and python is just a symlink/alias to python2, which causes problems as well...

@exalate-issue-sync
Copy link
Author

Michal Malohlava commented: Oki problem is in Gradle daemon.

If Gradle is invoked, by default, it creates a new daemon which is used to invoke any following builds. However, the daemon inherits environment of parent process at launch time. Hence, all our exec tasks inherits the same environment. At the end it means that if you change Python profile (via virtualenv or Conda), then it is not accepted. See following experiment:

{noformat}
➜ sparkling-water git:(mm/jira/sw-386) ✗ pkill java
➜ sparkling-water git:(mm/jira/sw-386) ✗ gw :sparkling-water-py:pyver
Found gradlew in /Users/michal/Devel/projects/h2o/repos/sparkling-water
Starting a Gradle Daemon (subsequent builds will be faster)
:sparkling-water-py:pyver
Python 2.7.12 :: Anaconda custom (x86_64)

BUILD SUCCESSFUL

Total time: 6.54 secs
➜ sparkling-water git:(mm/jira/sw-386) ✗ source activate py361 # Activate Python 3.6.1 environment
(py361) ➜ sparkling-water git:(mm/jira/sw-386) ✗ gw :sparkling-water-py:pyver
Found gradlew in /Users/michal/Devel/projects/h2o/repos/sparkling-water
:sparkling-water-py:pyver
Python 2.7.12 :: Anaconda custom (x86_64)

BUILD SUCCESSFUL

Total time: 1.388 secs
(py361) ➜ sparkling-water git:(mm/jira/sw-386) ✗ # OMG!!!
(py361) ➜ sparkling-water git:(mm/jira/sw-386) ✗ pkill java # Kill Gradle deamon
(py361) ➜ sparkling-water git:(mm/jira/sw-386) ✗ gw :sparkling-water-py:pyver # Start a new deamon
Found gradlew in /Users/michal/Devel/projects/h2o/repos/sparkling-water
Starting a Gradle Daemon (subsequent builds will be faster)
:sparkling-water-py:pyver
Python 3.6.1 :: Continuum Analytics, Inc.

BUILD SUCCESSFUL

Total time: 6.88 secs
(py361) ➜ sparkling-water git:(mm/jira/sw-386) ✗
{noformat}

The workaround is to kill/not use gradle daemon or specify Python executable via a property.

@exalate-issue-sync
Copy link
Author

Michal Malohlava commented: It seems that only PATH variable is affected.

@exalate-issue-sync
Copy link
Author

Jakub Hava commented: Michal:
it should be possible to prefix all python calls with env call

{code:java}
commandLine getOsSpecificCommandLine(["env", "python", "--version"])
{code}

Yup, it works!

@DinukaH2O
Copy link

JIRA Issue Migration Info

Jira Issue: SW-392
Assignee: Jakub Hava
Reporter: Jakub Hava
State: Resolved
Fix Version: 1.6.10
Attachments: N/A
Development PRs: Available

Linked PRs from JIRA

#246

@hasithjp
Copy link
Member

JIRA Issue Migration Info Cont'd

Jira Issue Created Date: 2017-04-06T03:21:58.788-0700

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants