Skip to content
This repository has been archived by the owner on Sep 12, 2024. It is now read-only.

prefer python3 over python2 #813

Closed
Klaas- opened this issue Aug 20, 2021 · 4 comments
Closed

prefer python3 over python2 #813

Klaas- opened this issue Aug 20, 2021 · 4 comments

Comments

@Klaas-
Copy link

Klaas- commented Aug 20, 2021

Hi,
you currently prefer python2 over python3, I think this should be the other way around seeing that python2 upstream is no longer supported and downstream (rhel) it will only receive security fixes

So a check like here:

char* getPythonProvider()
{
int buffer_length = 128;
char buffer[buffer_length];
char* result = malloc(1);
*result = 0;
FILE* pipe = popen("python2 --version 2>&1", "r");
if(!pipe) {
printf("Cant start command.");
}
while(fgets(buffer, 128, pipe) != NULL) {
result = realloc(result, (result ? strlen(result) : 0) + buffer_length );
strcat(result,buffer);
}
// If python2 --version does not contain 'not found' return python2
if(strstr(result, "not found") == NULL) {
return PYTHON2_COMMAND;
}
// Look for python3
result = malloc(1);
*result = 0;
pipe = popen("python3 --version 2>&1", "r");
if(!pipe) {
printf("Cant start command.");
}
while(fgets(buffer, 128, pipe) != NULL) {
result = realloc(result, (result ? strlen(result) : 0) + buffer_length );
strcat(result,buffer);
}
// If python3 --version does not contain 'not found' return python3
if(strstr(result, "not found") == NULL) {
return PYTHON3_COMMAND;
}
return PYTHON_COMMAND;
}

should be the other way around, use python3 first if not exists then python2. I am not sure if you actually need the unversioned python as a fallback, at least for rhel 6+ I can say that python2 exists :)

The current behavior leads to problems on el8 systems that have both python2 and python3 installed because a lot of the python2 paths assume that python is aliased to python2, which it is not ( #801 )

Greetings
Klaas

@nbjohnson
Copy link

I would also like to see python3 preferred in all locations possible. Currently when both python2 and python3 are installed on my system (with python3 as the default python) it is trying to run the python2 compatible scripts with python3 and is erroring out. If this can be addressed that would be greatly appreciated!

@Klaas-
Copy link
Author

Klaas- commented Jun 8, 2022

@nbjohnson open a support request with azure and increase the pressure for them to fix it, I tried for months and did not succeed :)

@Klaas-
Copy link
Author

Klaas- commented Jun 8, 2022

but your problem is not this one, it's #801 :)

@Klaas-
Copy link
Author

Klaas- commented Aug 5, 2022

I think this is fixed via d1c9ac9 by @samarth793
I am not sure why it's still falling back to "python" if neither python3 nor python2 work (without checking if python actually works).

@Klaas- Klaas- closed this as completed Aug 5, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants