Skip to content

Commit

Permalink
Add PYTHONPATH for all platforms in isolated environment
Browse files Browse the repository at this point in the history
  • Loading branch information
zackees committed Aug 20, 2024
1 parent 9e1dc84 commit 0e821d3
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/isolated_environment/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,8 @@ def _get_activated_environment(
out_env["PATH"] = str(env_path / "bin") + ":" + out_env["PATH"]

# set PYTHONPATH to make sure Python finds installed packages
if sys.platform == "win32":
out_env["PYTHONPATH"] = str(env_path / "Lib" / "site-packages")
else:
out_env["PYTHONPATH"] = str(env_path / "lib" / "site-packages")
out_env["PYTHONPATH"] = str(env_path / "lib" / "site-packages")


scripts = "Scripts" if sys.platform == "win32" else "bin"
python_name = "python.exe" if sys.platform == "win32" else "python"
Expand Down
41 changes: 41 additions & 0 deletions tests/test_aicode.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# pylint: disable=R0801

"""
Tests against a bug in aicode which uses isolated-environment.
"""

import subprocess
import unittest
from pathlib import Path
from tempfile import TemporaryDirectory

from isolated_environment.api import IsolatedEnvironment

HERE = Path(__file__).parent.absolute()


class AiderChatTester(unittest.TestCase):
"""Main tester class."""

def test_ensure_installed(self) -> None:
"""Tests that ensure_installed works."""
with TemporaryDirectory() as tmp_dir:
iso_env = IsolatedEnvironment(
Path(tmp_dir) / "venv",
requirements="advanced-aicode",
full_isolation=True,
)
# now create an inner environment without the static-ffmpeg
cmd_list = ["aicode", "--help"]
cp: subprocess.CompletedProcess = iso_env.run(
cmd_list, shell=False, capture_output=True
)
stdout = cp.stdout
stderr = cp.stderr
print(f"stdout: {stdout}")
print(f"stderr: {stderr}")
self.assertEqual(0, cp.returncode)


if __name__ == "__main__":
unittest.main()

0 comments on commit 0e821d3

Please sign in to comment.