Skip to content

Commit c49fbbc

Browse files
authored
Merge pull request #566 from ccordoba12/fix-getting-pixi-info-on-posix
PR: Fix getting Pixi environment info on Posix systems
2 parents 6af56c8 + 014c455 commit c49fbbc

File tree

6 files changed

+74
-4
lines changed

6 files changed

+74
-4
lines changed

.github/workflows/linux-pip-tests.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,17 @@ jobs:
4646
shell: bash -l {0}
4747
run: |
4848
pip install -e .[test]
49+
- name: Install Pixi
50+
uses: prefix-dev/[email protected]
51+
with:
52+
run-install: false
53+
- name: Create environment with Pixi
54+
shell: bash -l {0}
55+
run: |
56+
cd ~
57+
pixi init pixi-test
58+
cd pixi-test
59+
pixi add python
4960
- name: Show environment information
5061
shell: bash -l {0}
5162
run: |

.github/workflows/linux-tests.yml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,18 @@ jobs:
5252
run: conda install --file requirements/tests.txt -y -q
5353
- name: Install Package
5454
shell: bash -l {0}
55-
run: pip install -e .
55+
run: pip install --no-deps -e .
56+
- name: Install Pixi
57+
uses: prefix-dev/[email protected]
58+
with:
59+
run-install: false
60+
- name: Create environment with Pixi
61+
shell: bash -l {0}
62+
run: |
63+
cd ~
64+
pixi init pixi-test
65+
cd pixi-test
66+
pixi add python
5667
- name: Show environment information
5768
shell: bash -l {0}
5869
run: |

.github/workflows/macos-tests.yml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,18 @@ jobs:
4848
run: conda install --file requirements/tests.txt -y -q
4949
- name: Install Package
5050
shell: bash -l {0}
51-
run: pip install -e .
51+
run: pip install --no-deps -e .
52+
- name: Install Pixi
53+
uses: prefix-dev/[email protected]
54+
with:
55+
run-install: false
56+
- name: Create environment with Pixi
57+
shell: bash -l {0}
58+
run: |
59+
cd ~
60+
pixi init pixi-test
61+
cd pixi-test
62+
pixi add python
5263
- name: Show environment information
5364
shell: bash -l {0}
5465
run: |

.github/workflows/windows-tests.yml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,18 @@ jobs:
4848
conda install --file requirements/tests.txt -y -q
4949
- name: Install Package
5050
shell: bash -l {0}
51-
run: pip install -e .
51+
run: pip install --no-deps -e .
52+
- name: Install Pixi
53+
uses: prefix-dev/[email protected]
54+
with:
55+
run-install: false
56+
- name: Create environment with Pixi
57+
shell: bash -l {0}
58+
run: |
59+
cd ~
60+
pixi init pixi-test
61+
cd pixi-test
62+
pixi add python
5263
- name: Show environment information
5364
shell: bash -l {0}
5465
run: |

spyder_kernels/utils/pythonenv.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,15 +64,17 @@ def get_conda_env_path(pyexec, quote=False):
6464

6565
def get_pixi_manifest_path_and_env_name(pyexec, quote=False):
6666
pyexec_path = Path(pyexec.replace("\\", "/"))
67-
pixi_env_path = pyexec_path.parent
67+
pixi_env_path = pyexec_path.parents[0 if os.name == "nt" else 1]
6868
pixi_env_name = pixi_env_path.name
6969
pixi_dir_path = pixi_env_path.parents[1]
70+
7071
pixi_manifest_path = None
7172
pixi_manifest_paths = [
7273
pixi_dir_path.parent / "pixi.toml",
7374
pixi_dir_path.parent / "pyproject.toml",
7475
pixi_dir_path.parent / "manifests" / "pixi-global.toml",
7576
]
77+
7678
for manifest_path in pixi_manifest_paths:
7779
if manifest_path.exists():
7880
pixi_manifest_path = manifest_path

spyder_kernels/utils/tests/test_pythonenv.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212

1313
# Standard library imports
1414
import os
15+
from pathlib import Path
16+
import shutil
1517

1618
# Third-party imports
1719
import pytest
@@ -21,6 +23,7 @@
2123
add_quotes,
2224
get_conda_env_path,
2325
get_env_dir,
26+
get_pixi_manifest_path_and_env_name,
2427
)
2528

2629

@@ -62,5 +65,26 @@ def test_get_env_dir():
6265
assert output == "foobar"
6366

6467

68+
@pytest.mark.skipif(
69+
not (
70+
shutil.which("pixi.exe" if os.name == "nt" else "pixi")
71+
and os.environ.get("CI")
72+
),
73+
reason="Only works with Pixi on CIs",
74+
)
75+
def test_get_pixi_info():
76+
home_path = Path(os.environ["HOME"])
77+
pixi_env_dir = home_path / "pixi-test" / ".pixi" / "envs" / "default"
78+
pixi_env_info = get_pixi_manifest_path_and_env_name(
79+
str(pixi_env_dir / "python.exe")
80+
if os.name == "nt"
81+
else str(pixi_env_dir / "bin" / "python")
82+
)
83+
84+
assert pixi_env_info == (
85+
str(home_path / "pixi-test" / "pixi.toml"), "default"
86+
)
87+
88+
6589
if __name__ == "__main__":
6690
pytest.main()

0 commit comments

Comments
 (0)