use python venv with nix

This commit is contained in:
Jesse Cirimelli-Low 2026-05-04 16:39:33 -07:00
parent 07b33b3dfd
commit 5bd5293b4e
3 changed files with 16 additions and 2 deletions

1
.gitignore vendored
View File

@ -19,6 +19,7 @@ compiler/tests/results/
open_pdks/
dist/
openram.egg-info/
.venv/
sky130A
sky130B
gf180mcuA

View File

@ -246,5 +246,5 @@ build_library:
# Build and install the openram library
library: build_library
@python3 -m pip install --force dist/openram*.whl
@python3 -m pip install --force-reinstall dist/openram*.whl
.PHONY: library

View File

@ -38,11 +38,24 @@
pkgs.git
pkgs.gnumake
pkgs.curl
# Python + pip (user installs, venvs; prefer Nix where possible)
pkgs.python3
pkgs.python3Packages.pip
];
shellHook = ''
export OPENRAM_USE_CONDA=0
echo "OpenRAM: using tools from Nix devShell"
# PEP 668: Nix `python3` is externally managed. Put a repo-local venv first on PATH
# so `make library` uses it. Use $PWD (writable checkout), not `toString self` (nix store).
OPENRAM_VENV="''${OPENRAM_HOME}/.venv"
if [ ! -x "$OPENRAM_VENV/bin/python3" ]; then
echo "OpenRAM: creating venv at $OPENRAM_VENV"
${pkgs.python3}/bin/python3 -m venv "$OPENRAM_VENV"
fi
export VIRTUAL_ENV="$OPENRAM_VENV"
export PATH="$OPENRAM_VENV/bin:$PATH"
echo "OpenRAM: Nix devShell (venv on PATH: $OPENRAM_VENV)"
'';
};
});