Ubuntu Python 3 as default

Ian's Avatar

Ian

20 Dec, 2018 09:40 PM

Hello,
Im trying to add a matrix for Ubuntu with python 3 as the default python interpreter. Meaning, i need to have python = python3

I have tried to use alias python='python3' and stack: python 3 but those do not seem to work.

I have no trouble with the Windows builds, just Ubuntu w/python3. Here is my .yml, any help is appreciated:

version: '1.0.{build}'

environment:

  GEO_VERSION: '18b'

  matrix:
    # Windows w/64 bit Geo & python 3.6
    - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
      PYTHON: "C:\\Python36-x64"
      PYTHON_ARCH: "64"

    # Windows w/64 bit Geo & python 2.7
    - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
      PYTHON: "C:\\Python27-x64"
      PYTHON_ARCH: "64"

    # Windows w/32 bit Geo & python 3.6
    - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
      PYTHON: "C:\\Python36"
      PYTHON_ARCH: "32"

    # Windows w/32 bit Geo & python 2.7
    - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
      PYTHON: "C:\\Python27"
      PYTHON_ARCH: "32"

    # Ubuntu - python 2.7
    - APPVEYOR_BUILD_WORKER_IMAGE: Ubuntu

    # Ubuntu - python 3
    - APPVEYOR_BUILD_WORKER_IMAGE: Ubuntu
      stack: python 3

build_script:
  - ps: .\appveyor\build.ps1

install:
  - pip install --user -e .[dev] # user flag to prevent permission errors

test_script:
  - invoke test all
  1. Support Staff 1 Posted by Owen McDonnell on 21 Dec, 2018 05:29 PM

    Owen McDonnell's Avatar

    Have you tried stack: python 3.4 or stack: python 3.5 etc. ?

  2. 2 Posted by Ian on 21 Dec, 2018 06:27 PM

    Ian's Avatar

    yes i have tried stack set to python 3.4, 3.5 and 3.6. The system interpreter is still set to python 2.7 as you can see from the build_script phase:

    python --version
    Python 2.7.12
    pip --version
    pip 18.1 from /usr/local/lib/python2.7/dist-packages/pip-18.1-py2.7.egg/pip (python 2.7)
    python -c "import sys, platform, struct; print(sys.platform, platform.machine(), struct.calcsize('P')*8)"
    ('linux2', 'x86_64', 64)
    
  3. Support Staff 3 Posted by Owen McDonnell on 21 Dec, 2018 06:53 PM

    Owen McDonnell's Avatar

    Sorry, I forgot to mention, stack: should be at top level of yaml. (i.e. the same level as build_script:).

  4. 4 Posted by Ian on 21 Dec, 2018 07:13 PM

    Ian's Avatar

    So if I understand correctly, stack wont allow me to specify the python version in each build? it seems it's a constant used by all builds.

    I need to test in both python 2.7 and python 3+ on windows and linux. Windows needs to be tested in both x86 and x64 python versions - this is 6 builds altogether. Im not sure how I would achieve this using stack. Should i be modifying the system path in linux as I have done in the windows builds, or is there an easier way?

    Thanks in advance.

  5. 5 Posted by Ian on 21 Dec, 2018 07:26 PM

    Ian's Avatar

    Maybe I have it understood now. I will try this:

    stack: python 2.7, python 3.6
    
    environment:
      GEO_VERSION: '18b'
    
      matrix:
         # ... windows here ...
    
        # Ubuntu - python 2.7
        - APPVEYOR_BUILD_WORKER_IMAGE: Ubuntu
          stack: python 2.7
    
        # Ubuntu - python 3
        - APPVEYOR_BUILD_WORKER_IMAGE: Ubuntu
          stack: python 3.6
    
  6. 6 Posted by Ian on 21 Dec, 2018 07:38 PM

    Ian's Avatar

    the above will set both Ubuntu builds to python 3. Not able to use python 2.7 as intended in first build.

  7. 7 Posted by Ian on 22 Dec, 2018 02:03 AM

    Ian's Avatar

    You were right. I needed to understand the execution better. I got it to work with this:

    
    environment:
      GEO_VERSION: '18b'
      matrix:
         # ... windows here ...
        # Ubuntu - python 2.7
        - APPVEYOR_BUILD_WORKER_IMAGE: Ubuntu
          PYTHON: "2.7"
        # Ubuntu - python 3
        - APPVEYOR_BUILD_WORKER_IMAGE: Ubuntu
          PYTHON: "3.6"
    stack: python %PYTHON%
    

    Feel free to make this thread pubic if you think it's useful.

  8. Support Staff 8 Posted by Owen McDonnell on 22 Dec, 2018 08:05 AM

    Owen McDonnell's Avatar

    Sorry for not clarifying earlier. Anyway, you figured it out.

    Sure, I'll make the thread public so its searchable.

Reply to this discussion

Internal reply

Formatting help / Preview (switch to plain text) No formatting (switch to Markdown)

Attaching KB article:

»

Attached Files

You can attach files up to 10MB

If you don't have an account yet, we need to confirm you're human and not a machine trying to post spam.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac