Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions .github/workflows/linux-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ name: Linux tests

on: [pull_request, push]

concurrency:
group: linux-tests-${{ github.ref }}
cancel-in-progress: true

jobs:
tests:
name: Test Python ${{ matrix.python-version }} Executable ${{ matrix.conda-like }}
Expand All @@ -13,13 +17,13 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ['3.7', '3.10']
python-version: ['3.9', '3.11']
conda-like: ['micromamba', 'conda']
steps:
- name: Checkout branch
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: Install Conda
uses: conda-incubator/setup-miniconda@v2
uses: conda-incubator/setup-miniconda@v3
with:
auto-update-conda: true
channels: conda-forge
Expand All @@ -30,7 +34,7 @@ jobs:
if: ${{matrix.conda-like == 'micromamba'}}
shell: bash -l {0}
run: |
curl -Ls https://micro.mamba.pm/api/micromamba/linux-64/latest | tar -xvj bin/micromamba
curl -Ls https://micro.mamba.pm/api/micromamba/linux-64/1.5.10 | tar -xvj bin/micromamba
echo "ENV_BACKEND_EXECUTABLE=${{ github.workspace }}/bin/micromamba" >> $GITHUB_ENV
- name: Setup executable backend with conda
if: ${{matrix.conda-like == 'conda'}}
Expand All @@ -44,9 +48,9 @@ jobs:
- name: Run tests
shell: bash -l {0}
run: |
pytest --cov-report xml --cov=envs_manager -vv -x
pytest --cov-report xml --cov=envs_manager --color=yes -vv -x
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: true
Expand Down
16 changes: 10 additions & 6 deletions .github/workflows/macos-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ name: Macos tests

on: [pull_request, push]

concurrency:
group: macos-tests-${{ github.ref }}
cancel-in-progress: true

jobs:
tests:
name: Test Python ${{ matrix.python-version }} Executable ${{ matrix.conda-like }}
Expand All @@ -13,13 +17,13 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ['3.7', '3.10']
python-version: ['3.9', '3.11']
conda-like: ['micromamba', 'conda']
steps:
- name: Checkout branch
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: Install Conda
uses: conda-incubator/setup-miniconda@v2
uses: conda-incubator/setup-miniconda@v3
with:
auto-update-conda: true
channels: conda-forge
Expand All @@ -30,7 +34,7 @@ jobs:
if: ${{matrix.conda-like == 'micromamba'}}
shell: bash -l {0}
run: |
curl -Ls https://micro.mamba.pm/api/micromamba/osx-64/latest | tar -xvj bin/micromamba
curl -Ls https://micro.mamba.pm/api/micromamba/osx-64/1.5.10 | tar -xvj bin/micromamba
echo "ENV_BACKEND_EXECUTABLE=${{ github.workspace }}/bin/micromamba" >> $GITHUB_ENV
- name: Setup executable backend with conda
if: ${{matrix.conda-like == 'conda'}}
Expand All @@ -44,9 +48,9 @@ jobs:
- name: Run tests
shell: bash -l {0}
run: |
pytest --cov-report xml --cov=envs_manager -vv -x
pytest --cov-report xml --cov=envs_manager --color=yes -vv -x
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: true
Expand Down
12 changes: 7 additions & 5 deletions .github/workflows/black.yml → .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
# Run the project's Pre-Commit hooks
name: Black
name: Pre-commit

on: [pull_request, push]

jobs:
black:
name: Black with Pre-Commit
name: Validations with Pre-Commit
runs-on: ubuntu-latest
steps:
- name: Checkout envs-manager repository
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: '3.9'
- name: Run Pre-Commit hooks
uses: pre-commit/action@v3.0.0
uses: pre-commit/action@v3.0.1
16 changes: 10 additions & 6 deletions .github/workflows/windows-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ name: Windows tests

on: [pull_request, push]

concurrency:
group: windows-tests-${{ github.ref }}
cancel-in-progress: true

jobs:
tests:
name: Test Python ${{ matrix.python-version }} Executable ${{ matrix.conda-like }}
Expand All @@ -13,13 +17,13 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ['3.7', '3.10']
python-version: ['3.9', '3.11']
conda-like: ['micromamba', 'conda']
steps:
- name: Checkout branch
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: Install Conda
uses: conda-incubator/setup-miniconda@v2
uses: conda-incubator/setup-miniconda@v3
with:
auto-update-conda: true
channels: conda-forge
Expand All @@ -31,7 +35,7 @@ jobs:
shell: bash -l {0}
run: |
mkdir micromamba
curl -Ls https://micro.mamba.pm/api/micromamba/win-64/latest | tar -xvj -C micromamba
curl -Ls https://micro.mamba.pm/api/micromamba/win-64/1.5.10 | tar -xvj -C micromamba
echo "ENV_BACKEND_EXECUTABLE=${{ github.workspace }}\micromamba\Library\bin\micromamba.exe" >> $GITHUB_ENV
echo "MAMBA_ROOT_PREFIX=${{ github.workspace }}\micromamba" >> $GITHUB_ENV
- name: Setup executable backend with conda
Expand All @@ -46,9 +50,9 @@ jobs:
- name: Run tests
shell: bash -l {0}
run: |
pytest --cov-report xml --cov=envs_manager -vv -x
pytest --cov-report xml --cov=envs_manager --color=yes -vv -x
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: true
Expand Down
14 changes: 9 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,16 @@
exclude: ^envs_manager/tests/env_files
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.3.0
rev: v4.6.0
hooks:
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/hadialqattan/pycln
rev: v2.5.0
hooks:
- id: pycln
- repo: https://github.com/psf/black
rev: 22.6.0
rev: 24.10.0
hooks:
- id: black
30 changes: 21 additions & 9 deletions envs_manager/backends/conda_like_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from pathlib import Path
import subprocess

from packaging.version import parse
import yaml

from envs_manager.api import EnvManagerInstance, run_command, get_package_info
Expand Down Expand Up @@ -38,9 +39,17 @@ def validate(self):
result = run_command(command, capture_output=True)
version = result.stdout.split()
if len(version) <= 1:
self.executable_variant = MICROMAMBA_VARIANT
# We don't support Micromamba 2.0+ because it's not very reliable
if parse(version[0]) < parse("2.0.0"):
self.executable_variant = MICROMAMBA_VARIANT
else:
return False
else:
self.executable_variant = version[0]
# This is the minimal conda version we support
if parse(version[1]) > parse("24.1.0"):
self.executable_variant = version[0]
else:
return False
return True
except Exception as error:
logger.error(error.stderr)
Expand Down Expand Up @@ -101,6 +110,7 @@ def export_environment(self, export_file_path=None):
logger.info(result.stdout)
return (True, result)
except subprocess.CalledProcessError as error:
logger.error(error.stderr)
return (False, f"{error.returncode}: {error.stderr}")

def import_environment(self, import_file_path, force=False):
Expand All @@ -112,8 +122,6 @@ def import_environment(self, import_file_path, force=False):
self.environment_path,
f"--file={import_file_path}",
]
if force:
command += ["-y"]
else:
command = [
self.external_executable,
Expand All @@ -123,13 +131,16 @@ def import_environment(self, import_file_path, force=False):
self.environment_path,
f"--file={import_file_path}",
]
if force:
command += ["--force"]

if force:
command += ["-y"]

try:
result = run_command(command, capture_output=True)
logger.info(result.stdout)
return (True, result)
except subprocess.CalledProcessError as error:
logger.error(error.stderr)
return (
False,
f"{error.returncode}: {error.stderr}\nNote: Importing environments only works for environment definitions created with the same operating system.",
Expand All @@ -142,8 +153,6 @@ def install_packages(
force=False,
capture_output=False,
):
if self.executable_variant != MICROMAMBA_VARIANT:
packages = [f"'{package}'" for package in packages]
command = [
self.external_executable,
"install",
Expand All @@ -161,6 +170,7 @@ def install_packages(
logger.info(result.stdout)
return (True, result)
except subprocess.CalledProcessError as error:
logger.error(error.stderr)
formatted_error = f"{error.returncode}: {error.stderr}"
return (False, formatted_error)

Expand All @@ -181,6 +191,7 @@ def uninstall_packages(self, packages, force=False, capture_output=False):
except subprocess.CalledProcessError as error:
if "PackagesNotFoundError" in error.stderr:
return (True, error)
logger.error(error.stderr)
formatted_error = f"{error.returncode}: {error.stderr}"
return (False, formatted_error)

Expand All @@ -204,6 +215,7 @@ def update_packages(self, packages, force=False, capture_output=False):
else:
return (True, result)
except subprocess.CalledProcessError as error:
logger.error(error.stderr)
formatted_error = f"{error.returncode}: {error.stderr}"
return (False, formatted_error)

Expand Down Expand Up @@ -284,6 +296,6 @@ def list_environments(cls, root_path, external_executable=None):

return (environments, result)
except subprocess.CalledProcessError as error:
logger.error(error.stderr)
formatted_error = f"{error.returncode}: {error.stderr}"
logger.error(formatted_error)
return (environments, formatted_error)
2 changes: 1 addition & 1 deletion envs_manager/backends/venv_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def python_executable_path(self):

def validate(self):
try:
import venv
import venv # noqa

return True
except ImportError:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name:
name:
channels:
- https://conda.anaconda.org/conda-forge
dependencies:
Expand Down Expand Up @@ -27,4 +27,3 @@ dependencies:
- tzdata==2022c=h191b570_0
- wheel==0.37.1=pyhd8ed1ab_0
- xz==5.2.6=h166bdaf_0

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name:
name:
channels:
- https://conda.anaconda.org/conda-forge
dependencies:
Expand All @@ -20,4 +20,3 @@ dependencies:
- tzdata==2022c=h191b570_0
- wheel==0.37.1=pyhd8ed1ab_0
- xz==5.2.6=h775f41a_0

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name:
name:
channels:
- https://conda.anaconda.org/conda-forge
dependencies:
Expand All @@ -21,4 +21,3 @@ dependencies:
- vs2015_runtime==14.29.30139=h890b9b1_7
- wheel==0.37.1=pyhd8ed1ab_0
- xz==5.2.6=h8d14728_0

6 changes: 5 additions & 1 deletion envs_manager/tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,11 @@
("venv", [""], "test_env", "pip"),
(
"conda-like",
["Transaction finished", "Executing transaction: ...working... done"],
[
"Transaction finished",
"Executing transaction:",
"Downloading and Extracting Packages:",
],
"test_env",
"python",
),
Expand Down
Loading
Loading