Skip to content

Commit ab037cb

Browse files
authored
Support running tests in more environments (#84)
1 parent ba4f329 commit ab037cb

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

setuptools_git_versioning.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@
1515
from pprint import pformat
1616
from typing import TYPE_CHECKING, Any, Callable
1717

18+
# because we use distutils in this file, we need to ensure that setuptools is
19+
# imported first so that it can do monkey patching. this is not always already
20+
# done for us, for example, when running this in a test or as a module
21+
import setuptools # noqa: F401
22+
1823
if TYPE_CHECKING:
1924
# avoid importing 'packaging' because setuptools-git-versioning can be installed using sdist
2025
# where 'packaging' is not installed yet

tests/lib/util.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,13 @@ def rand_sha() -> str:
3030

3131
def execute(cwd: str | os.PathLike, cmd: str, **kwargs) -> str:
3232
log.info(f"Executing '{cmd}' at '{cwd}'")
33+
34+
if "env" in kwargs:
35+
kwargs["env"]["PATH"] = os.environ["PATH"]
36+
pythonpath = os.getenv("PYTHONPATH", None)
37+
if pythonpath:
38+
kwargs["env"]["PYTHONPATH"] = pythonpath
39+
3340
return subprocess.check_output(cmd, cwd=cwd, shell=True, universal_newlines=True, **kwargs) # nosec
3441

3542

0 commit comments

Comments
 (0)