How to code an installation according to the python version?

servoz's Avatar

servoz

16 Apr, 2020 02:59 PM

I would like to install with pip a particular version of a library depending on the version of python.
Something like this:
if ["$python_version" == "3.5"]; then pip3 install Foofoo==1.1.1; fi

the current appveyor.yml file:

environment:


matrix: - PYTHON: "C:\Python35" - PYTHON: "C:\Python36" - PYTHON: "C:\Python37"


build: off


install: - ps: iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-desktop.ps1')) - "SET PATH=%PYTHON%;%PYTHON%\Scripts;%PATH%" - "python -m pip install --upgrade pip" - "pip install --upgrade -vv setuptools" - "pip install --upgrade cython" - "pip install numpy" - "pip install freetype-py" - "pip install pypng" - "pip install --upgrade pywavelets" - "pip install pypiwin32" - "python setup.py install" - "git lfs install" - "git lfs pull" - "echo y | pip uninstall PyQt5" - "pip install PyQt5==5.9.2" - "git clone --depth=50 --branch=master https://github.com/populse/populse_db.git C:\projects\populse-db" - "cd C:\projects\populse-db" - "pip install -e .[postgres]" #- "pip install --force-reinstall lark-parser==0.6.7" - "cd .." - "git clone --depth=50 --branch=master https://github.com/populse/soma-base.git C:\projects\soma-base" - "cd populse-mia" - "SET PYTHONPATH=C:\projects\populse-mia\python\;%PYTHONPATH%" - "SET PYTHONPATH=C:\projects\soma-base\python\;%PYTHONPATH%"


test_script: - "python --version" - "python .\python\populse_mia\test.py -v"


notifications: - provider: Email to: - '{{commitAuthorEmail}}' on_build_failure: true on_build_success: false on_build_status_changed: true

the appveyor.yml file (but with the right syntax that I can't find!) that I would like to use:

environment:


matrix: - PYTHON: "C:\Python35" - PYTHON: "C:\Python36" - PYTHON: "C:\Python37"


build: off


install: - ps: iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-desktop.ps1')) - "SET PATH=%PYTHON%;%PYTHON%\Scripts;%PATH%" - "python -m pip install --upgrade pip" - "pip install --upgrade -vv setuptools" - "pip install --upgrade cython" - "pip install numpy" - "pip install freetype-py" - "pip install pypng" - "pip install --upgrade pywavelets" - "pip install pypiwin32"
if ["$python_version" == "3.5"]; then pip3 install Foofoo==1.1.1; fi # but with the good syntax
  - "python setup.py install"
  - "git lfs install"
  - "git lfs pull"
  - "echo y | pip uninstall PyQt5"
  - "pip install PyQt5==5.9.2"
  - "git clone --depth=50 --branch=master https://github.com/populse/populse_db.git C:\projects\populse-db"
  - "cd C:\projects\populse-db"
  - "pip install -e .[postgres]"
  #- "pip install --force-reinstall lark-parser==0.6.7"
  - "cd .."
  - "git clone --depth=50 --branch=master https://github.com/populse/soma-base.git C:\projects\soma-base"
  - "cd populse-mia"
  - "SET PYTHONPATH=C:\projects\populse-mia\python\;%PYTHONPATH%"
  - "SET PYTHONPATH=C:\projects\soma-base\python\;%PYTHONPATH%"


test_script: - "python --version" - "python .\python\populse_mia\test.py -v"


notifications: - provider: Email to: - '{{commitAuthorEmail}}' on_build_failure: true on_build_success: false on_build_status_changed: true
  1. Support Staff 1 Posted by Feodor Fitsner on 16 Apr, 2020 10:41 PM

    Feodor Fitsner's Avatar

    So, on Windows you can have something like:

    install:
    ...
    - IF "%PYTHON%"=="C:\Python35" pip3 install Foofoo==1.1.1
    - IF "%PYTHON%"=="C:\Python36" pip3 install Foofoo==2.2.2
    - IF "%PYTHON%"=="C:\Python37" pip3 install Foofoo==3.3.3
    ...
    
  2. Support Staff 2 Posted by Feodor Fitsner on 16 Apr, 2020 10:44 PM

    Feodor Fitsner's Avatar

    ...or, alternatively have different install sections for every Python:

    environment:
    
      matrix:
        - PYTHON: "C:\Python35"
        - PYTHON: "C:\Python36"
        - PYTHON: "C:\Python37"
    
    for:
    -
      matrix:
        only:
          - PYTHON: "C:\Python35"
    
      install:
      - pip3 install Foofoo==1.1.1
      
    -
      matrix:
        only:
          - PYTHON: "C:\Python36"
    
      install:
      - pip3 install Foofoo==2.2.2
    
    -
      matrix:
        only:
          - PYTHON: "C:\Python37"
    
      install:
      - pip3 install Foofoo==3.3.3
    
  3. 3 Posted by servoz on 16 Apr, 2020 11:19 PM

    servoz's Avatar

    Thank you very much!
    As always you give a precise and very high quality answer !
    You solved my problem perfectly!
    Thank's again !
    All the best

  4. servoz closed this discussion on 16 Apr, 2020 11:19 PM.

Comments are currently closed for this discussion. You can start a new one.

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