Skip to content

Commit

Permalink
Support running tests in more environments (#84)
Browse files Browse the repository at this point in the history
  • Loading branch information
tjni committed Aug 8, 2023
1 parent ba4f329 commit ab037cb
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
5 changes: 5 additions & 0 deletions setuptools_git_versioning.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@
from pprint import pformat
from typing import TYPE_CHECKING, Any, Callable

# because we use distutils in this file, we need to ensure that setuptools is
# imported first so that it can do monkey patching. this is not always already
# done for us, for example, when running this in a test or as a module
import setuptools # noqa: F401

if TYPE_CHECKING:
# avoid importing 'packaging' because setuptools-git-versioning can be installed using sdist
# where 'packaging' is not installed yet
Expand Down
7 changes: 7 additions & 0 deletions tests/lib/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,13 @@ def rand_sha() -> str:

def execute(cwd: str | os.PathLike, cmd: str, **kwargs) -> str:
log.info(f"Executing '{cmd}' at '{cwd}'")

if "env" in kwargs:
kwargs["env"]["PATH"] = os.environ["PATH"]
pythonpath = os.getenv("PYTHONPATH", None)
if pythonpath:
kwargs["env"]["PYTHONPATH"] = pythonpath

return subprocess.check_output(cmd, cwd=cwd, shell=True, universal_newlines=True, **kwargs) # nosec


Expand Down

0 comments on commit ab037cb

Please sign in to comment.