Skip to content

Instantly share code, notes, and snippets.

@royratcliffe
Last active July 29, 2025 09:58
Show Gist options
  • Select an option

  • Save royratcliffe/cbb98a962e0cbffe0804f79a9c3395c5 to your computer and use it in GitHub Desktop.

Select an option

Save royratcliffe/cbb98a962e0cbffe0804f79a9c3395c5 to your computer and use it in GitHub Desktop.
Python
if IS_WINDOWS:
import os
os.environ['PATH'] += ';' + os.path.dirname(__file__)
# Run a Python script in a virtual environment as superuser.
sudo -E env PATH=$PATH python script.py
# Makefile for setting up Python virtual environment and installing dependencies
.PHONY: all
all: .venv pip-install
# Create a Python virtual environment in the .venv directory
# and install the required packages from requirements.txt
#
# Ensure that the virtual environment is created before installing packages
.PHONY: .venv
.venv: ; python3 -m venv .venv
# Activate the virtual environment and install the required packages
.PHONY: pip-install
pip-install: requirements.txt ; pip install -r $<
{
"debugpy.debugJustMyCode": false
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment