Git Product home page Git Product logo

setup-conda's Introduction

setup-conda

Tests All Contributors

This action adds the conda command from the on the worker preinstalled miniconda version to the known shell commands.

Inputs

Name Requirement Default Description
activate-conda optional true Whether to activate the conda base env.
update-conda optional false If conda should be updated before running other commands.
python-version optional 'default' Python version which should be installed with conda.
conda-channels optional '' Additional channels like 'conda-forge', as coma separated list, which can be used to install packages. The last channel in the list, will have the highest priority.

Usage

See action.yml

Basic:

The basic usage makes the conda python version the default python ($ conda activate base).

steps:
  - uses: actions/checkout@v3
  - uses: s-weigand/setup-conda@v1
  - run: conda --version
  - run: which python

If you don't want to change the python version which is used (e.g. you just need to install a none python package), you can use activate-conda: false.

steps:
  - uses: actions/checkout@v3
  - name: Set up Python 3.8
    uses: actions/setup-python@v4
    with:
      python-version: 3.8
  - uses: s-weigand/setup-conda@v1
    with:
      activate-conda: false
  - run: conda --version
  - run: which python

Matrix Testing:

jobs:
  build:
    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        os: [ubuntu-latest, windows-latest, macOS-latest]
        python-version: [3.6, 3.7, 3.8]
    name: Python ${{ matrix.python-version }} example
    steps:
      - uses: actions/checkout@v3
      - name: Setup conda
        uses: s-weigand/setup-conda@v1
        with:
          update-conda: true
          python-version: ${{ matrix.python-version }}
          conda-channels: anaconda, conda-forge
      - run: conda --version
      - run: which python

Contributors ✨

Thanks goes to these wonderful people (emoji key):

Sebastian Weigand
Sebastian Weigand

πŸ’» πŸ€” πŸš‡ 🚧 ⚠️ πŸ‘€
Santiago Castro
Santiago Castro

πŸ“–
Derrick
Derrick

πŸ“–
Pietro Fumiani
Pietro Fumiani

πŸ›
Doug
Doug

πŸ›
Filipe
Filipe

πŸ›
Carl Simon Adorf
Carl Simon Adorf

πŸ›
wvxvw
wvxvw

πŸ›
violafanfani
violafanfani

πŸ›
Oleg Broytman
Oleg Broytman

πŸ› πŸ’»

This project follows the all-contributors specification. Contributions of any kind welcome!

setup-conda's People

Contributors

allcontributors[bot] avatar bryant1410 avatar d-chambers avatar dependabot[bot] avatar lgtm-com[bot] avatar phdru avatar s-weigand avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

setup-conda's Issues

Macos issue

When using s-weigand/setup-conda@v1 on macos-latest and Python 3.6/3.7/3.8 I get a the following log:

stdout /usr/local/bin/python

/usr/local/bin/python
Adding conda path to path: /usr/local/miniconda
Activating conda base
bash /var/folders/24/8k48jl6d249_n_qfxwsl6xvm0000gn/T/202049-728-koszql.l278a.sh
Changing owner of conda folders
sudo chown -R runner:staff /Users/runner/.conda
sudo chown -R runner:staff /usr/local/miniconda
Adding conda-channels
conda config --add channels conda-forge
Updating conda
conda update -y -n base -c defaults conda
Collecting package metadata (current_repodata.json): ...working... failed

CondaHTTPError: HTTP 000 CONNECTION FAILED for url <https://repo.anaconda.com/pkgs/main/osx-64/current_repodata.json>
Elapsed: -

An HTTP error occurred when trying to retrieve this URL.
HTTP errors are often intermittent, and a simple retry will get you on your way.

It does not really seem to be an intermittent HTTP error as I could reproduce it every single time since two days on this repo: https://github.com/martinRenou/ipycanvas. If you want to see the full log: https://github.com/martinRenou/ipycanvas/runs/658592457

I wonder if the URL changed?

Error: The "path" argument must be of type string. Received type undefined

Describe the bug
Error: The "path" argument must be of type string. Received type undefined. Why am I getting this and how to solve?
Expected behavior
There is no path argument in conda action to provide a path. Error is not clear

Screenshots
If applicable, add screenshots to help explain your problem.
image

Desktop (please complete the following information):

  • ubuntu-latest
  • chrome

Unexpected input(s) 'auto-update-conda', valid inputs are ['activate-conda', 'update-conda', 'python-version', 'conda-channels']

Describe the bug

I get a warning about a non-existent input.

To Reproduce

Run s-weigand/setup-conda@v1
  with:
    activate-conda: false
    auto-update-conda: true
    python-version: 3.6
    update-conda: false
  env:
    pythonLocation: C:\hostedtoolcache\windows\Python\3.6.8\x64
    TOXENV: py36-windows

Expected behavior

Setting up conda works without any warning.

Environment

  • OS: windows-latest

Additional context

It worked in the past, but has recently been broken.

Version 1.0.6 broke testing on Windows and macOS

Our setup in in ioos/erddapy@9232d71 works with version 1.0.5 but not 1.0.6. See ioos/erddapy#193 where we had to pin the to previous version version to make it work.

Note that, by using activate-conda: true we could get 1.0.6 to work on Linux only. However, my understanding is that we don't need to activate the base env b/c we are activating the TEST env later.

Happy to provide any with further details if needed. Also, thanks for the awesome GHA! Very useful!!

bash: /tmp/2021029-2444-1687tb4.wkq9.sh: No such file or directory

Describe the bug
Workflow fails and due to file not found error:

Run s-weigand/setup-conda@v1
  with:
    activate-conda: true
    update-conda: false
    python-version: default
  env:
    pythonLocation: /opt/hostedtoolcache/Python/3.7.9/x64
which python
stdout /opt/hostedtoolcache/Python/3.7.9/x64/bin/python

/opt/hostedtoolcache/Python/3.7.9/x64/bin/python
Adding conda path to path: /usr/share/miniconda
Activating conda base
bash /tmp/2021029-2444-c6jfmq.81qsc.sh
Activating conda base
bash /tmp/2021029-2444-1687tb4.wkq9.sh
bash: /tmp/2021029-2444-1687tb4.wkq9.sh: No such file or directory
Error: The process 'bash' failed with exit code 127

To Reproduce
Steps to reproduce the behavior:

Not sure how to reproduce, but here is the run that caused this error

Expected behavior

Setup Conda as expected

PyPy

It it possible to install PyPy (pypy for Python 2.7 and pypy3 for Python 3)?

python-version: pypy (with conda-channels: 'conda-forge') doesn't work, the error message is

Error: The value of "python-version" you provided was pypy, which is invalid.
  The value of "python-version" needs to be of form:
  /^\d+\.\d+(\.\d+)?$/

In command line the command is

conda create -c conda-forge -n pypy pypy

GDAL 3 Environment variables not being set

Describe the bug

Using setup-conda to install gdal 3+ on Ubuntu 18.04 and noticed GDAL_DATA and PROJ_LIB environment variables are not being set. This was noticed by getting the following error in one of our tests for a Python project when trying to use the gdal library:
ERROR 1: PROJ: proj_create_from_database: Open of /usr/share/miniconda/share/proj failed

When setting GDAL_DATA and PROJ_LIB environment variables in a yml workflow manually, calling printenv will show the paths to those variables, however, from the test in Python, printing os.environ shows that these variables are still not present or set (see screeshots).

To Reproduce
Steps to reproduce the behavior:

  1. Create a Github Actions workflow with OS as Ubuntu 18.04
  2. Use setup-conda and install gdal3+ from a requirements file
  3. Run a Python file that imports gdal and osr to load a EPSG Code
  4. See error

From dcdenu4/gdal3-conda-setup, .github/workflow/pythonpackage.yml :

name: Test PyGeoprocessing

on: [push, pull_request]

jobs:
  Test:
    runs-on: ${{ matrix.os }}
    env:
        PACKAGES: "pytest flake8"
    strategy:
      fail-fast: false
      max-parallel: 4
      matrix:
        python-version: [3.7]
        os: [ubuntu-18.04]

    steps:
    - uses: actions/checkout@v2
      with:
          # Fetch all history so that setuptool_scm can build the correct version string.
          fetch-depth: 0

    - name: setup-conda
      uses: s-weigand/[email protected]
      with:
        update-conda: false
        python-version: ${{ matrix.python-version }}
        activate-conda: true
        conda-channels: anaconda, conda-forge
    - name: Install dependencies
      shell: bash
      run: conda upgrade -y pip setuptools

    - name: Install GDAL3 Test (Linux)
      env: 
          GDAL_DATA: /usr/share/miniconda/share/gdal/
          PROJ_LIB: /usr/share/miniconda/share/proj/
      run: |
          conda install --file requirements.txt
          conda install $PACKAGES
          printenv
          find /usr -name proj.db 
          ls -l /usr/share/miniconda/share/proj/

    - name: Test with pytest
      run: pytest -s

Expected behavior
I would expect GDAL_DATA and PROJ_LIB to be set as environment variables and to be available to Python to run the GDAL Library.

Screenshots
Environment variables printed out using printenv after install gdal and manually setting environment variables. If not manually set, GDAL_DATA and PROJ_LIB do not appear here.
image

A Python test using os.environ to show environment variables. GDAL_DATA and PROJ_LIB not present and error occurs.
image

Desktop (please complete the following information):

  • OS: Ubuntu 18.04 via Github Actions VM
  • Browser [N / A]
  • Version [N / A]

Additional context
I created a dummy repo here: github.com/dcdenu4/gdal-conda-setup to help demonstrate this issue. Ultimately this problem has arisen from trying to go from GDAL 2 to GDAL 3 in a larger project, where using GDAL 3 our tests fail using this kind of workflow.

env activation is not persistent throughout the session

Describe the bug
If the command source activate <env-name> is executed in a previous step respect to one in which the environment is used, the env itself does not result activated and raise for using a command that is not installed in the base env.

To Reproduce
the actual YAML file with the workflow:

name: CI
on: push

jobs:
  test:
    name: Pytest Testing
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - name: Conda setup
        uses: s-weigand/[email protected]
        with:
          update-conda: true
          python-version: 3.7
      # env activation as suggested by @s-weigand
      - name: Conda environment creation
        run: |
          conda env create -f environment.yml
          source activate feat
          pip install -e .
      - name: Testing with pytest
        run: |
          pytest

the following error is reported in the Actions log:

2020-05-19T17:38:50.4263319Z ##[group]Run pytest
2020-05-19T17:38:50.4263646Z οΏ½[36;1mpytestοΏ½[0m
2020-05-19T17:38:50.4299399Z shell: /bin/bash -e {0}
2020-05-19T17:38:50.4299513Z ##[endgroup]
2020-05-19T17:38:50.4377171Z /home/runner/work/_temp/5ded05d7-e2df-43db-bfca-4721d3e5faea.sh: line 1: pytest: command not found
2020-05-19T17:38:50.4384238Z ##[error]Process completed with exit code 127.

Workaround
At the moment the only way I found to make it work is to run source activate feat also before the usage of the environment (in my case pytest command) like this:

name: CI
on: push

jobs:
  test:
    name: Pytest Testing
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - name: Conda setup
        uses: s-weigand/[email protected]
        with:
          update-conda: true
          python-version: 3.7
      # env activation as suggested by @s-weigand
      - name: Conda environment creation
        run: |
          conda env create -f environment.yml
          source activate feat
          pip install -e .
      - name: Testing with pytest
        run: |
          source activate feat
          pytest

This action fails in combination with Python 3.10

Describe the bug

Unable to use this step in combination with Python version "3.10".

The bug occurred as part of a workflow defined here.

To Reproduce

The following workflow definition should reproduce the problem:

  create-conda-environment:
    runs-on: ubuntu-latest

    - name: Setup Conda
      uses: s-weigand/setup-conda@v1
      with:
        python-version: '3.10'
        update-conda: false
        conda-channels: conda-forge

Expected behavior

The action creates a conda environment with Python 3.10.

[Security] Workflow release.yml is using vulnerable action s-weigand/setup-conda

The workflow release.yml is referencing action s-weigand/setup-conda using references v1. However this reference is missing the commit a30654e576ab9e21a25825bf7a5d5f2a9b95b202 which may contain fix to the some vulnerability.
The vulnerability fix that is missing by actions version could be related to:
(1) CVE fix
(2) upgrade of vulnerable dependency
(3) fix to secret leak and others.
Please consider to update the reference to the action.

Allow option to setup my own environment with environment.yml

Is your feature request related to a problem? Please describe.
It is not clear how to activate my own requirement
Describe the solution you'd like
I have a environment.yml file in my repository. I would like to run these commands

conda env create -f environment.yml
source ~/anaconda3/etc/profile.d/conda.sh
conda activate my_env

Currently, the second command does not work because it is not the correct path to conda.sh. I would like documentation for where the conda.sh file is located.

Describe alternatives you've considered
I have not found an alternative

failing action, bioconda channel not available

Describe the bug
I use the action to test and release a python package with the gihub CI. Lest week all worked correctly, but I am now getting an error:
UnavailableInvalidChannel: HTTP 404 NOT FOUND for channel bioconda <https://conda.anaconda.org/ bioconda> when creating the environment (/usr/share/miniconda/bin/conda create -y -n __setup_conda python=3.9). The bioconda channels doesn't seem to be down, as I tried generating the same environment on my local machine.

To Reproduce
Steps to reproduce the behavior:

  1. Go to netzoopy actions : 'https://github.com/netZoo/netZooPy/runs/6628979901?check_suite_focus=true'
  2. Click on 'actions'
  3. Scroll down to test conda #44
  4. See error

Expected behavior
The rule is supposed to run with no errors.

Additional context

Rule in CI:

      - name: "Setup Conda"
        uses: s-weigand/setup-conda@v1
        with:
          update-conda: true
          python-version: ${{ matrix.python-version }}
          conda-channels: anaconda, conda-forge, bioconda

Entire error:

Installing conda python 3.9
  /usr/share/miniconda/bin/conda create -y -n __setup_conda python=3.9
  Collecting package metadata (current_repodata.json): ...working... failed
  
  UnavailableInvalidChannel: HTTP 404 NOT FOUND for channel  bioconda <https://conda.anaconda.org/ bioconda>
  
  The channel is not accessible or is invalid.
  
  You will need to adjust your conda configuration to proceed.
  Use `conda config --show channels` to view your configuration's current state,
  and use `conda config --show-sources` to view config file locations.
  
  
  Error: The process '/usr/share/miniconda/bin/conda' failed with exit code 1

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.