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

Incorect Python version on MacOS latest #179

Closed
2 of 7 tasks
NicolasGensollen opened this issue Dec 22, 2020 · 3 comments
Closed
2 of 7 tasks

Incorect Python version on MacOS latest #179

NicolasGensollen opened this issue Dec 22, 2020 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@NicolasGensollen
Copy link

Describe the bug

On MacOS-latest, the version of Python is not the expected one.
The following input:

name: 'test'                                                                                                                                                                                               
                                                                                                                                                                                                            
 on:                                                                                                                                                                                                        
   push:                                                                                                                                                                                                    
     branches:                                                                                                                                                                                              
       - "main"                                                                                                                                                                                             
   pull_request:                                                                                                                                                                                            
     branches:                                                                                                                                                                                              
       - '*'                                                                                                                                                                                                
                                                                                                                                                                                                            
 jobs:                                                                                                                                                                                                      
   build:                                                                                                                                                                                                   
     runs-on: ${{ matrix.os }}                                                                                                                                                                              
     strategy:                                                                                                                                                                                              
       matrix:                                                                                                                                                                                              
         os: [ubuntu-latest, windows-latest, macos-latest]                                                                                                                                                  
         python-version: ["3.7"]                                                                                                                                                                            
     steps:                                                                                                                                                                                                 
       - uses: actions/checkout@v2                                                                                                                                                                          
       - name: Set up Python                                                                                                                                                                                
         uses: actions/setup-python@v2                                                                                                                                                                      
         with:                                                                                                                                                                                              
           python-version: ${{ matrix.python-version }}                                                                                                                                                     
       - shell: bash -l {0}                                                                                                                                                                                 
         name: 'Display Python version and location'                                                                                                                                                        
         run: |                                                                                                                                                                                             
             python --version                                                                                                                                                                               
             which python

yields the following output:

Ubuntu

Python 3.7.9
/opt/hostedtoolcache/Python/3.7.9/x64/bin/python

Windows

Python 3.7.9
/c/hostedtoolcache/windows/Python/3.7.9/x64/python

MacOS

Python 2.7.18
/usr/local/bin/python

Which version of the action are you using?

  • v1
  • v2
  • Some other tag (such as v2.0.1 or master)

Environment

  • self-hosted
  • Linux
  • Windows
  • Mac

Am I missing something here?
Thanks!

@yuxiang-he
Copy link

Also adding on to the issue here, all dependencies in our tests were installed in /Library/Frameworks/Python.framework/Versions/2.7/bin which is not on $PATH of the test environment by default.

@maxim-lobanov
Copy link
Contributor

Hello,
Your issue is caused by -l argument in - shell: bash -l {0}.

actions/setup-python prepends $PATH with folder where specified Python is located. But when you add -l argument, bash is run in login mode and bash itself prepends $PATH with a few more folders including /usr/local/bin that contains default Python on MacOS.
I can confirm that same behavior on my local macOS machine. If bash is run like bash -l, it contains additional folders to PATH and there is no way to avoid it.

I have done a few experiments:

   runs-on: macos-latest
   steps:
     - uses: actions/checkout@v2
     - uses: actions/setup-python@v2
       with:
         python-version: 3.7
     - run: |
         echo $PATH
         python --version
         which python
     - run: |
         echo $PATH
         python --version
         which python
       shell: bash {0}
     - run: |
         echo $PATH
         python --version
         which python
       shell: bash -l {0}

The first bash step output (specified Python is the first in PATH):

/Users/runner/hostedtoolcache/Python/3.7.9/x64/bin:/Users/runner/hostedtoolcache/Python/3.7.9/x64:/usr/local/opt/pipx_bin:/Users/runner/.cargo/bin:/usr/local/lib/ruby/gems/2.7.0/bin:/usr/local/opt/ruby/bin:/usr/local/opt/curl/bin:/usr/local/bin:/usr/local/sbin:/Users/runner/bin:/Users/runner/.yarn/bin:/usr/local/go/bin:/Users/runner/Library/Android/sdk/tools:/Users/runner/Library/Android/sdk/platform-tools:/Users/runner/Library/Android/sdk/ndk-bundle:/Library/Frameworks/Mono.framework/Versions/Current/Commands:/usr/bin:/bin:/usr/sbin:/sbin:/Users/runner/.dotnet/tools:/Users/runner/.ghcup/bin:/Users/runner/hostedtoolcache/stack/2.5.1/x64
Python 3.7.9
/Users/runner/hostedtoolcache/Python/3.7.9/x64/bin/python

The second bash step output (specified Python is the first in PATH):

/Users/runner/hostedtoolcache/Python/3.7.9/x64/bin:/Users/runner/hostedtoolcache/Python/3.7.9/x64:/usr/local/opt/pipx_bin:/Users/runner/.cargo/bin:/usr/local/lib/ruby/gems/2.7.0/bin:/usr/local/opt/ruby/bin:/usr/local/opt/curl/bin:/usr/local/bin:/usr/local/sbin:/Users/runner/bin:/Users/runner/.yarn/bin:/usr/local/go/bin:/Users/runner/Library/Android/sdk/tools:/Users/runner/Library/Android/sdk/platform-tools:/Users/runner/Library/Android/sdk/ndk-bundle:/Library/Frameworks/Mono.framework/Versions/Current/Commands:/usr/bin:/bin:/usr/sbin:/sbin:/Users/runner/.dotnet/tools:/Users/runner/.ghcup/bin:/Users/runner/hostedtoolcache/stack/2.5.1/x64
Python 3.7.9
/Users/runner/hostedtoolcache/Python/3.7.9/x64/bin/python

The third bash step output (bash is run with -l flag and bash adds additional folders to PATH):

/usr/local/opt/pipx_bin:/Users/runner/.cargo/bin:/usr/local/lib/ruby/gems/2.7.0/bin:/usr/local/opt/ruby/bin:/usr/local/opt/curl/bin:/usr/local/bin:/usr/local/sbin:/Users/runner/bin:/Users/runner/.yarn/bin:/usr/local/go/bin:/Users/runner/Library/Android/sdk/tools:/Users/runner/Library/Android/sdk/platform-tools:/Users/runner/Library/Android/sdk/ndk-bundle:/Library/Frameworks/Mono.framework/Versions/Current/Commands:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Apple/usr/bin:/Library/Frameworks/Mono.framework/Versions/Current/Commands:/Users/runner/hostedtoolcache/Python/3.7.9/x64/bin:/Users/runner/hostedtoolcache/Python/3.7.9/x64:/usr/local/opt/pipx_bin:/Users/runner/.cargo/bin:/usr/local/lib/ruby/gems/2.7.0/bin:/usr/local/opt/ruby/bin:/usr/local/opt/curl/bin:/usr/local/sbin:/Users/runner/bin:/Users/runner/.yarn/bin:/usr/local/go/bin:/Users/runner/Library/Android/sdk/tools:/Users/runner/Library/Android/sdk/platform-tools:/Users/runner/Library/Android/sdk/ndk-bundle:/Users/runner/.dotnet/tools:/Users/runner/.ghcup/bin:/Users/runner/hostedtoolcache/stack/2.5.1/x64:/Users/runner/.dotnet/tools:/Users/runner/.ghcup/bin:/Users/runner/hostedtoolcache/stack/2.5.1/x64
Python 2.7.18
/usr/local/bin/python

Unfortunately, there is no way to fix it from task side since it is by design.
I suggest using shell without -l argument or adds the following line to bash step to prepend PATH already after bash initialization:

export PATH="$pythonLocation:$PATH"

@maxim-lobanov maxim-lobanov self-assigned this Dec 23, 2020
@NicolasGensollen
Copy link
Author

Thanks for the explanations @maxim-lobanov !
I confirm that the proposed solutions work for me, closing this...

sgbaird added a commit to sparks-baird/mat_discover that referenced this issue Feb 17, 2022
iwishiwasaneagle added a commit to iwishiwasaneagle/pytest-extra-markers that referenced this issue Mar 5, 2023
WenjieDu added a commit to WenjieDu/PyPOTS that referenced this issue Apr 17, 2023
tbaudier added a commit to OpenGATE/opengate that referenced this issue Jul 7, 2023
For windows compilation

Need to change not by !
or by ||
and by &&
fMapOfDigiInVolume need to contain pointer to GateDigiAdderInVolume instead of element

The templated function with specialization (.icc) need to be in the cpp but the instanciation of the class only works with windows
https://learn.microsoft.com/bs-latn-ba/cpp/cpp/source-code-organization-cpp-templates?view=msvc-160

For windows on github actions, move dist repository
Add tests for windows
Need to add PLATFORM variable because in windows it's just amd not x68 - intel

Use cibuildwheel for Windows CI
Repair wheel for windows with delvewheel
Own delvewheel to take into account case sensitivity
Do not use QT because delvewheel do not take into account very well

Example to try ssh with github actions

Be sure to have a correct seed for windows
if windows, the long integer type are 4 bytes instead of 8 bytes for python and unix system
https://fr.wikipedia.org/wiki/Entier_long

Remove MT for windows
And remove fork/spawn: fork is not usable on windows and spawn produces an error
            # to be able to run process, we will need to start the example in __main__
            # https://stackoverflow.com/questions/18204782/runtimeerror-on-windows-trying-python-multiprocessing

Encode to be able to print the dump_tree_of_volumes
https://stackoverflow.com/questions/27092833/unicodeencodeerror-charmap-codec-cant-encode-characters

Remove -l option to bash
actions/setup-python#179
tbaudier added a commit to OpenGATE/opengate that referenced this issue Jul 7, 2023
For windows compilation

Need to change not by !
or by ||
and by &&
fMapOfDigiInVolume need to contain pointer to GateDigiAdderInVolume instead of element

The templated function with specialization (.icc) need to be in the cpp but the instanciation of the class only works with windows
https://learn.microsoft.com/bs-latn-ba/cpp/cpp/source-code-organization-cpp-templates?view=msvc-160

For windows on github actions, move dist repository
Add tests for windows
Need to add PLATFORM variable because in windows it's just amd not x68 - intel

Use cibuildwheel for Windows CI
Repair wheel for windows with delvewheel
Own delvewheel to take into account case sensitivity
Do not use QT because delvewheel do not take into account very well

Example to try ssh with github actions

Be sure to have a correct seed for windows
if windows, the long integer type are 4 bytes instead of 8 bytes for python and unix system
https://fr.wikipedia.org/wiki/Entier_long

Remove MT for windows
And remove fork/spawn: fork is not usable on windows and spawn produces an error
            # to be able to run process, we will need to start the example in __main__
            # https://stackoverflow.com/questions/18204782/runtimeerror-on-windows-trying-python-multiprocessing

Encode to be able to print the dump_tree_of_volumes
https://stackoverflow.com/questions/27092833/unicodeencodeerror-charmap-codec-cant-encode-characters

Remove -l option to bash
actions/setup-python#179
tbaudier added a commit to OpenGATE/opengate that referenced this issue Jul 17, 2023
For windows compilation

Need to change not by !
or by ||
and by &&
fMapOfDigiInVolume need to contain pointer to GateDigiAdderInVolume instead of element

The templated function with specialization (.icc) need to be in the cpp but the instanciation of the class only works with windows
https://learn.microsoft.com/bs-latn-ba/cpp/cpp/source-code-organization-cpp-templates?view=msvc-160

For windows on github actions, move dist repository
Add tests for windows
Need to add PLATFORM variable because in windows it's just amd not x68 - intel

Use cibuildwheel for Windows CI
Repair wheel for windows with delvewheel
Own delvewheel to take into account case sensitivity
Do not use QT because delvewheel do not take into account very well

Example to try ssh with github actions

Be sure to have a correct seed for windows
if windows, the long integer type are 4 bytes instead of 8 bytes for python and unix system
https://fr.wikipedia.org/wiki/Entier_long

Remove MT for windows
And remove fork/spawn: fork is not usable on windows and spawn produces an error
            # to be able to run process, we will need to start the example in __main__
            # https://stackoverflow.com/questions/18204782/runtimeerror-on-windows-trying-python-multiprocessing

Encode to be able to print the dump_tree_of_volumes
https://stackoverflow.com/questions/27092833/unicodeencodeerror-charmap-codec-cant-encode-characters

Remove -l option to bash
actions/setup-python#179
tbaudier added a commit to OpenGATE/opengate that referenced this issue Jul 18, 2023
For windows compilation

Need to change not by !
or by ||
and by &&
fMapOfDigiInVolume need to contain pointer to GateDigiAdderInVolume instead of element

The templated function with specialization (.icc) need to be in the cpp but the instanciation of the class only works with windows
https://learn.microsoft.com/bs-latn-ba/cpp/cpp/source-code-organization-cpp-templates?view=msvc-160

For windows on github actions, move dist repository
Add tests for windows
Need to add PLATFORM variable because in windows it's just amd not x68 - intel

Use cibuildwheel for Windows CI
Repair wheel for windows with delvewheel
Own delvewheel to take into account case sensitivity
Do not use QT because delvewheel do not take into account very well

Example to try ssh with github actions

Be sure to have a correct seed for windows
if windows, the long integer type are 4 bytes instead of 8 bytes for python and unix system
https://fr.wikipedia.org/wiki/Entier_long

Remove MT for windows
And remove fork/spawn: fork is not usable on windows and spawn produces an error
            # to be able to run process, we will need to start the example in __main__
            # https://stackoverflow.com/questions/18204782/runtimeerror-on-windows-trying-python-multiprocessing

Encode to be able to print the dump_tree_of_volumes
https://stackoverflow.com/questions/27092833/unicodeencodeerror-charmap-codec-cant-encode-characters

Remove -l option to bash
actions/setup-python#179
tbaudier added a commit to OpenGATE/opengate that referenced this issue Jul 18, 2023
For windows compilation

Need to change not by !
or by ||
and by &&
fMapOfDigiInVolume need to contain pointer to GateDigiAdderInVolume instead of element

The templated function with specialization (.icc) need to be in the cpp but the instanciation of the class only works with windows
https://learn.microsoft.com/bs-latn-ba/cpp/cpp/source-code-organization-cpp-templates?view=msvc-160

For windows on github actions, move dist repository
Add tests for windows
Need to add PLATFORM variable because in windows it's just amd not x68 - intel

Use cibuildwheel for Windows CI
Repair wheel for windows with delvewheel
Own delvewheel to take into account case sensitivity
Do not use QT because delvewheel do not take into account very well

Example to try ssh with github actions

Be sure to have a correct seed for windows
if windows, the long integer type are 4 bytes instead of 8 bytes for python and unix system
https://fr.wikipedia.org/wiki/Entier_long

Remove MT for windows
And remove fork/spawn: fork is not usable on windows and spawn produces an error
            # to be able to run process, we will need to start the example in __main__
            # https://stackoverflow.com/questions/18204782/runtimeerror-on-windows-trying-python-multiprocessing

Encode to be able to print the dump_tree_of_volumes
https://stackoverflow.com/questions/27092833/unicodeencodeerror-charmap-codec-cant-encode-characters

Remove -l option to bash
actions/setup-python#179
tbaudier added a commit to OpenGATE/opengate that referenced this issue Jul 18, 2023
For windows compilation

Need to change not by !
or by ||
and by &&
fMapOfDigiInVolume need to contain pointer to GateDigiAdderInVolume instead of element

The templated function with specialization (.icc) need to be in the cpp but the instanciation of the class only works with windows
https://learn.microsoft.com/bs-latn-ba/cpp/cpp/source-code-organization-cpp-templates?view=msvc-160

For windows on github actions, move dist repository
Add tests for windows
Need to add PLATFORM variable because in windows it's just amd not x68 - intel

Use cibuildwheel for Windows CI
Repair wheel for windows with delvewheel
Own delvewheel to take into account case sensitivity
Do not use QT because delvewheel do not take into account very well

Example to try ssh with github actions

Be sure to have a correct seed for windows
if windows, the long integer type are 4 bytes instead of 8 bytes for python and unix system
https://fr.wikipedia.org/wiki/Entier_long

Remove MT for windows
And remove fork/spawn: fork is not usable on windows and spawn produces an error
            # to be able to run process, we will need to start the example in __main__
            # https://stackoverflow.com/questions/18204782/runtimeerror-on-windows-trying-python-multiprocessing

Encode to be able to print the dump_tree_of_volumes
https://stackoverflow.com/questions/27092833/unicodeencodeerror-charmap-codec-cant-encode-characters

Remove -l option to bash
actions/setup-python#179
tbaudier added a commit to OpenGATE/opengate that referenced this issue Jul 19, 2023
For windows compilation

Need to change not by !
or by ||
and by &&
fMapOfDigiInVolume need to contain pointer to GateDigiAdderInVolume instead of element

The templated function with specialization (.icc) need to be in the cpp but the instanciation of the class only works with windows
https://learn.microsoft.com/bs-latn-ba/cpp/cpp/source-code-organization-cpp-templates?view=msvc-160

For windows on github actions, move dist repository
Add tests for windows
Need to add PLATFORM variable because in windows it's just amd not x68 - intel

Use cibuildwheel for Windows CI
Repair wheel for windows with delvewheel
Own delvewheel to take into account case sensitivity
Do not use QT because delvewheel do not take into account very well

Example to try ssh with github actions

Be sure to have a correct seed for windows
if windows, the long integer type are 4 bytes instead of 8 bytes for python and unix system
https://fr.wikipedia.org/wiki/Entier_long

Remove MT for windows
And remove fork/spawn: fork is not usable on windows and spawn produces an error
            # to be able to run process, we will need to start the example in __main__
            # https://stackoverflow.com/questions/18204782/runtimeerror-on-windows-trying-python-multiprocessing

Encode to be able to print the dump_tree_of_volumes
https://stackoverflow.com/questions/27092833/unicodeencodeerror-charmap-codec-cant-encode-characters

Remove -l option to bash
actions/setup-python#179
tbaudier added a commit to OpenGATE/opengate that referenced this issue Jul 19, 2023
For windows compilation

Need to change not by !
or by ||
and by &&
fMapOfDigiInVolume need to contain pointer to GateDigiAdderInVolume instead of element

The templated function with specialization (.icc) need to be in the cpp but the instanciation of the class only works with windows
https://learn.microsoft.com/bs-latn-ba/cpp/cpp/source-code-organization-cpp-templates?view=msvc-160

For windows on github actions, move dist repository
Add tests for windows
Need to add PLATFORM variable because in windows it's just amd not x68 - intel

Use cibuildwheel for Windows CI
Repair wheel for windows with delvewheel
Own delvewheel to take into account case sensitivity
Do not use QT because delvewheel do not take into account very well

Example to try ssh with github actions

Be sure to have a correct seed for windows
if windows, the long integer type are 4 bytes instead of 8 bytes for python and unix system
https://fr.wikipedia.org/wiki/Entier_long

Remove MT for windows
And remove fork/spawn: fork is not usable on windows and spawn produces an error
            # to be able to run process, we will need to start the example in __main__
            # https://stackoverflow.com/questions/18204782/runtimeerror-on-windows-trying-python-multiprocessing

Encode to be able to print the dump_tree_of_volumes
https://stackoverflow.com/questions/27092833/unicodeencodeerror-charmap-codec-cant-encode-characters

Remove -l option to bash
actions/setup-python#179
nr1118 added a commit to xpsi-group/neost that referenced this issue Nov 6, 2024
Seems there is a need to remove the -l argument otherwise the macos runner will always use Python 2.7.18. See this thread for further details: actions/setup-python#179 (comment)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants