Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Conversation

omajid
Copy link
Member

@omajid omajid commented Aug 8, 2018

If I am reading it correctly, the windows build scripts (build.cmd) try finding python in order of python3, python2 and then python:

echo import sys; sys.stdout.write(sys.executable) | (py -3 || py -2 || python3 || python2 || python) > %TEMP%\pythonlocation.txt 2> NUL

The unix build scripts don't. They just try python2 variants and then fail. This change makes brings them closer together by letting users build using only python3 on unix.

The support for using python3 for Windows was added here: 54a362c (#15611)

As an side, I see both the unix build scripts and Windows build scripts test for python and fail if it's not found. However CMakeLists.txt also tests for python again (and then doesn't use it?):

coreclr/CMakeLists.txt

Lines 40 to 43 in b4131b9

find_program(PYTHON NAMES python2.7 python2 python)
if (PYTHON STREQUAL "PYTHON-NOTFOUND")
message(FATAL_ERROR "PYTHON not found: Please install Python 2.7.9 or later from https://www.python.org/downloads/")
endif()

Is that useful to keep? It will prevent someone from building when python3 is available but not python2 or python.

The windows build scripts try finding python in order of python3,
python2 and then python. The unix build scripts dont. They just try
python2 variants and then fail. This change makes brings them closer
together by letting users build using only python3.
@omajid omajid changed the title Support building with python3 on unix Build with python3 on unix Aug 8, 2018
@omajid
Copy link
Member Author

omajid commented Aug 9, 2018

Guessing some CC's based on reviewers on the linked PR @gkhanna79 @leemgs @jkotas @janvorli @BruceForstall @nategraf

@BruceForstall
Copy link

I don't build on Linux much, but this seems reasonable to me. I there a reason to drop/replace the "python2.7" check instead of just adding the python3 check?

As for:

# Ensure that python is present                                                                                                                                                                                                                                                          find_program(PYTHON NAMES python2.7 python2 python)                                                                                                                                                                                                                                      if (PYTHON STREQUAL "PYTHON-NOTFOUND")                                                                                                                                                                                                                                                       message(FATAL_ERROR "PYTHON not found: Please install Python 2.7.9 or later from https://www.python.org/downloads/")                                                                                                                                                                 endif()                                                                                                                          

it does seem like this is not used. Maybe you should add a python3 check here as well, to be consistent?

It looks like src\build.proj has:

<Exec Command="python $(MSBuildThisFileDirectory)scripts\pgocheck.py @(PGOEnforcedFiles)" />  

but that doesn't look like it's using the cmake found PYTHON.

@jashook
Copy link

jashook commented Aug 9, 2018

We have a few different moving parts that have python dependencies. Currently the expected/supported version is 2.7; however, long term I believe we are planning to move to python3. That being said there are several other scripts which use python3 explicitly. Pulling in some people who are more familiar with other dependencies: @adiaaida @jorive @nategraf

I can speak to the build/run steps of coreclr's infrastructure. We currently have a requirement on python 2.7, and during build time I believe we should be enforcing this requirement until we move off it to python3.

Note that python isn't explicitely during the build, the cmake addition is basically a captcha for whether your system is setup to build and run tests with coreclr.

@jashook jashook self-requested a review August 9, 2018 18:06
@jashook
Copy link

jashook commented Aug 9, 2018

@RussKeldorph @BruceForstall opinions?

@RussKeldorph
Copy link

It sounds like we need to get to python3 soon if we are going to keep a python dependency, but we should enforce what the build scripts require. We should first make the build scripts work with either version and then start enforcing python3 after a grace period where we print out big warnings that 2.7 will no longer sufficient.

@BruceForstall
Copy link

My opinion would be that we can officially depend on 2.7, and make that primary. But if 3 "works", then that's fine. And if it "works" on 3 on Windows but not on Linux, due to this minor script issue, then adding support for Linux makes sense.

@jorive
Copy link

jorive commented Aug 9, 2018

@jashook Performance infrastructure relies on >=Python3.5

@omajid
Copy link
Member Author

omajid commented Aug 9, 2018

@BruceForstall said:

I don't build on Linux much, but this seems reasonable to me. I there a reason to drop/replace the "python2.7" check instead of just adding the python3 check?

No, I just wanted to bring Linux closer in line to Windows.

As for:

# Ensure that python is present

it does seem like this is not used. Maybe you should add a python3 check here as well, to be consistent?

Would it make more sense to just remove it? If it's not being used (I don't know this for sure), why keep the code around?

It looks like src\build.proj has:

but that doesn't look like it's using the cmake found PYTHON.

Thanks for pointing me to this. I fixed a variant of this (#19043) but missed this one because it was not getting executed on my machine. I will open a separate PR for this, which should be much less controversial.

@omajid
Copy link
Member Author

omajid commented Aug 9, 2018

It sounds like we need to get to python3 soon if we are going to keep a python dependency

Yes! We have about a year to move away from python 2: https://pythonclock.org/

but we should enforce what the build scripts require.

How do we deal with the difference between what the Windows build scripts currently require - 3 is preferred over 2 - with what the *nix build scripts do - 2 without any fallback ?

We should first make the build scripts work with either version and then start enforcing python3 after a grace period where we print out big warnings that 2.7 will no longer sufficient.

Okay. I can do that.

@jashook
Copy link

jashook commented Aug 9, 2018

Yes! We have about a year to move away from python 2: https://pythonclock.org/

I know its so sad :(

@jashook
Copy link

jashook commented Aug 9, 2018

How do we deal with the difference between what the Windows build scripts currently require - 3 is preferred over 2 - with what the *nix build scripts do - 2 without any fallback ?

Currently for scripting used by coreclr the (somewhat poorly enforced) requirement is python2, for both Windows and Unix. We have python3 dependencies and will continue to get more as python2 goes away. As Russ mentioned, for now we should support either python3 or python2, but enforce having python2.

In the longer term there are scripts we need to port to python3. This is mostly to clarify.

@BruceForstall
Copy link

@omajid Is this still active?

@jashook Assuming it's still a valid change, do you think it requires more work, or is it ok?

@omajid
Copy link
Member Author

omajid commented Jan 8, 2019

@BruceForstall I would like to get this in, yes. We are even closer to the python2 EOL date and the build scripts don't even support python3 out of the box yet :(

I don't know how to meet this request from earlier in this thread:

but we should enforce what the build scripts require. We should first make the build scripts work with either version and then start enforcing python3 after a grace period where we print out big warnings that 2.7 will no longer sufficient.

@jashook
Copy link

jashook commented Jan 8, 2019

I'm good with the change.

@jashook jashook closed this Jan 8, 2019
@jashook jashook reopened this Jan 8, 2019
@jashook
Copy link

jashook commented Jan 8, 2019

I thinks its good to merge once testing is done.

@jashook
Copy link

jashook commented Jan 8, 2019

@RussKeldorph @BruceForstall @echesakov for a second opinion

@jashook
Copy link

jashook commented Jan 9, 2019

@omajid in regards to you comment, we have been slowly changing the python scripts to use both python3 and python2. Recently both runtest.py, run-pmi-diffs.py have both been changed to support python3, so this has mostly been in flight. I believe we are at the point where we can start moving entirely to python3 and give a warning if python2 is the only dependency found.

I don't know how to meet this request from earlier in this thread:

but we should enforce what the build scripts require. We should first make the build scripts work with either version and then start enforcing python3 after a grace period where we print out big warnings that 2.7 will no longer sufficient.

@jashook
Copy link

jashook commented Jan 9, 2019

Failures look unrelated merging. Thanks for the contribution!

@jashook jashook merged commit 7e0608f into dotnet:master Jan 9, 2019
omajid added a commit to omajid/dotnet-coreclr that referenced this pull request Aug 24, 2020
This is a combined fix from 3 different PRs and one additional fix for
2.1:

- dotnet#19043
- dotnet#19356
- dotnet#22145

The 2.1-specific fix is that python is is only used as a fallback, in
case all other python program names dont work.

As for the original PRs, they perform these changes:

build.sh and build.cmd contain logic to identify a working version of
python to use. System.Private.CoreLib ignores that and directly invokes
'python', which may not work, or even execute a different program. Fix
that.

The windows build scripts try finding python in order of python3,
python2 and then python. The unix build scripts dont. They just try
python2 variants and then fail. This change makes brings them closer
together by letting users build using only python3.

Use the same logic in CMakeLists.txt that's used in build.sh/build.cmd
to lookup python.
Anipik pushed a commit that referenced this pull request Sep 18, 2020
This is a combined fix from 3 different PRs and one additional fix for
2.1:

- #19043
- #19356
- #22145

The 2.1-specific fix is that python is is only used as a fallback, in
case all other python program names dont work.

As for the original PRs, they perform these changes:

build.sh and build.cmd contain logic to identify a working version of
python to use. System.Private.CoreLib ignores that and directly invokes
'python', which may not work, or even execute a different program. Fix
that.

The windows build scripts try finding python in order of python3,
python2 and then python. The unix build scripts dont. They just try
python2 variants and then fail. This change makes brings them closer
together by letting users build using only python3.

Use the same logic in CMakeLists.txt that's used in build.sh/build.cmd
to lookup python.
picenka21 pushed a commit to picenka21/runtime that referenced this pull request Feb 18, 2022
The windows build scripts try finding python in order of python3,
python2 and then python. The unix build scripts dont. They just try
python2 variants and then fail. This change makes brings them closer
together by letting users build using only python3.

Commit migrated from dotnet/coreclr@7e0608f
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants