Skip to content

Commit

Permalink
Merge pull request #70 from mariusvniekerk/issue-69
Browse files Browse the repository at this point in the history
  • Loading branch information
mariusvniekerk authored Sep 27, 2023
2 parents e9d21ff + 2be67dc commit 1daaae5
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/pythonpackage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
max-parallel: 6
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ['3.7', '3.10']
python-version: ['3.8', '3.10']

steps:
- uses: actions/checkout@v3
Expand Down Expand Up @@ -49,7 +49,6 @@ jobs:
run: |
pip install .
condax ensure-path
mkdir -p "${HOME}/.local/bin"
- name: Use library to add a package
run: |
Expand Down
1 change: 1 addition & 0 deletions condax/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ def remove(
This can update shell configuration files like `~/.bashrc`."""
)
def ensure_path() -> None:
config.CONFIG.link_destination.mkdir(parents=True, exist_ok=True)
paths.add_path_to_environment(config.CONFIG.link_destination)


Expand Down
11 changes: 10 additions & 1 deletion condax/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from typing import TYPE_CHECKING, Generator, List, Optional

import yaml
from pydantic import ConfigDict, Field
from pydantic import ConfigDict, Field, field_validator

with warnings.catch_warnings():
# requests which is a transitive dependency has some chatty warnings during import
Expand Down Expand Up @@ -34,6 +34,15 @@ class Config(BaseSettings):
)
model_config = ConfigDict(env_prefix="CONDAX_")

@field_validator("prefix_path", "link_destination", mode="before")
@classmethod
def ensure_prefix_path(cls, v: Path) -> Path:
v = v.expanduser()
if not v.exists():
v.mkdir(parents=True, exist_ok=True)
v = v.resolve()
return v

def ensure_conda_executable(self, require_mamba: bool = True):
def candidates() -> "Generator[Optional[StrPath], None, None]":
yield ensureconda(
Expand Down

0 comments on commit 1daaae5

Please sign in to comment.