Skip to content

Commit

Permalink
Add IN_VIRTUAL_ENV
Browse files Browse the repository at this point in the history
Closes #39
  • Loading branch information
brettcannon committed Sep 17, 2023
1 parent 48782ea commit 6098f43
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
7 changes: 7 additions & 0 deletions microvenv/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,8 @@
import sys

# Exported as part of the public API.
from ._create import create as create

# https://docs.python.org/3/library/venv.html#how-venvs-work
IN_VIRTUAL_ENV = sys.prefix != sys.base_prefix

7 changes: 7 additions & 0 deletions tests/test_in_virtual_env.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import sys

import microvenv


def test_in_virtual_env():
assert microvenv.IN_VIRTUAL_ENV == (sys.prefix != sys.base_prefix)

0 comments on commit 6098f43

Please sign in to comment.