From e410ead19170df6678675be533a01a6b9320c685 Mon Sep 17 00:00:00 2001 From: Alex Chew Date: Thu, 31 Oct 2024 14:31:39 -0700 Subject: [PATCH] chore: fix Python virtualenv commands on Windows (#5883) Using a virtual environment avoids polluting the system Python installation. Reverts dafny-lang/dafny#5880 --- Source/DafnyRuntime/DafnyRuntimePython/Makefile | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/Source/DafnyRuntime/DafnyRuntimePython/Makefile b/Source/DafnyRuntime/DafnyRuntimePython/Makefile index b6f480c3d6..481014c451 100644 --- a/Source/DafnyRuntime/DafnyRuntimePython/Makefile +++ b/Source/DafnyRuntime/DafnyRuntimePython/Makefile @@ -5,7 +5,14 @@ DAFNY = dotnet run --project ../../Dafny --no-build -- GENERATED_SYSTEM_MODULE_SOURCE=../obj/systemModulePopulator-py/System_.py GENERATED_SYSTEM_MODULE_TARGET=System_/__init__.py +# Use a virtual environment in order to avoid polluting the system installation, +# dependency conflicts, etc. VIRTUALENV = venv +ifeq ($(OS),Windows_NT) + VIRTUALENV_PYTHON = $(VIRTUALENV)/Scripts/python.exe +else + VIRTUALENV_PYTHON = $(VIRTUALENV)/bin/python +endif all: check-system-module @@ -20,16 +27,16 @@ update-system-module: build-system-module setup-venv: python -m venv --clear $(VIRTUALENV) - python -m pip install --upgrade build twine + $(VIRTUALENV_PYTHON) -m pip install --upgrade build twine clean-package: rm -rf dist/ *.egg-info/ build-package: - python -m build + $(VIRTUALENV_PYTHON) -m build upload-package-testpypi: - python -m twine upload --repository testpypi dist/* + $(VIRTUALENV_PYTHON) -m twine upload --repository testpypi dist/* upload-package-pypi: - python -m twine upload dist/* + $(VIRTUALENV_PYTHON) -m twine upload dist/*