From 98ad0d6a87da9fda05adafc46ec59af1c47fbdbf Mon Sep 17 00:00:00 2001 From: brizental Date: Thu, 18 Nov 2021 10:43:04 +0100 Subject: [PATCH 1/2] Attempt to get virtualenv name from environment --- glean/src/cli.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/glean/src/cli.ts b/glean/src/cli.ts index ebc26a02b..614be7008 100644 --- a/glean/src/cli.ts +++ b/glean/src/cli.ts @@ -14,9 +14,16 @@ import log, { LoggingLevel } from "./core/log.js"; const LOG_TAG = "CLI"; -// The name of the directory which will contain the Python virtual environment +// The name of the directory which contains / will contain the Python virtual environment // used to run the glean-parser. -const VIRTUAL_ENVIRONMENT_DIR = ".venv"; +// +// > When a virtual environment is active, the VIRTUAL_ENV environment variable +// > is set to the path of the virtual environment. This can be used to check if +// > one is running inside a virtual environment. +// +// See: https://docs.python.org/3/library/venv.html +// (Also applies to envs created using virtualenv though) +const VIRTUAL_ENVIRONMENT_DIR = process.env.VIRTUAL_ENV?.split("/").slice(-1)[0] || ".venv"; // The version of glean_parser to install from PyPI. const GLEAN_PARSER_VERSION = "4.1.1"; From 070c7f57f8b9675213bfafd12ee666abb42ffd93 Mon Sep 17 00:00:00 2001 From: brizental Date: Thu, 18 Nov 2021 10:54:23 +0100 Subject: [PATCH 2/2] Update CHANGELOG.md --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a548214e3..747e5d684 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ [Full changelog](https://github.com/mozilla/glean.js/compare/v0.25.0...main) +* [#965](https://github.com/mozilla/glean.js/pull/965): Attempt to infer the Python virtualenv folder from the environment before falling back to the default `.venv`. + * Users may provide a folder name through the `VIRTUAL_ENV` environment variable. + * If the user is inside an active virtualenv the `VIRTUAL_ENV` environment variable is already set by Python. See: https://docs.python.org/3/library/venv.html. + # v0.25.0 (2021-11-15) [Full changelog](https://github.com/mozilla/glean.js/compare/v0.24.0...v0.25.0)