Skip to content

Commit

Permalink
Check in default location if pixi not found (#38)
Browse files Browse the repository at this point in the history
  • Loading branch information
pavelzw authored Oct 4, 2024
1 parent fd3e992 commit 394950b
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@ jobs:
environments: ${{ matrix.environment }}
- run: pixi run fmt-check
- run: pixi run lint-check
- run: pixi run test
- run: pixi run test --color=yes
15 changes: 14 additions & 1 deletion conda
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,28 @@ import traceback
from functools import lru_cache
from pathlib import Path

ON_WINDOWS = os.name == "nt"
ENABLE_LOGGING = True

# assuming __file__ is .pixi/envs/<env>/libexec/conda
# or .pixi\envs\<env>\libexec\conda.bat\..\conda.py
PIXI_ENVIRONMENT_FILE = Path(__file__).resolve().parent.parent / "conda-meta" / "pixi"
DEFAULT_PIXI_EXECUTABLE_PATH = (
Path(Path.home()) / ".pixi" / "bin" / f"pixi{'.exe' if ON_WINDOWS else ''}"
)


def pixi(cmd):
out = subprocess.check_output(["pixi", *cmd])
try:
out = subprocess.check_output(["pixi", *cmd])
except FileNotFoundError as e:
# if pixi is not on PATH, try to run it from the default location
# see https://pixi.sh/install.sh or https://pixi.sh/install.ps1
try:
out = subprocess.check_output([str(DEFAULT_PIXI_EXECUTABLE_PATH), *cmd])
except FileNotFoundError:
msg = "pixi not found. Is it installed in your PATH?"
raise FileNotFoundError(msg) from e
return out.decode(locale.getpreferredencoding())


Expand Down
2 changes: 1 addition & 1 deletion pixi.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "pixi-pycharm"
version = "0.0.6"
version = "0.0.7"
description = "Conda shim for PyCharm that proxies pixi"
authors = ["Pavel Zwerschke <pavelzw@gmail.com>"]
channels = ["conda-forge"]
Expand Down

0 comments on commit 394950b

Please sign in to comment.