Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jensens committed Feb 27, 2024
1 parent 7ec99f4 commit ab6f55c
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 11 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ PYTHON_PACKAGE_INSTALLER?=uv
# Flag whether to use a global installed 'uv' or install
# it in the virtual environment.
# Default: false
PYTHON_UV_GLOBAL?=true
PYTHON_UV_GLOBAL?=false

# Flag whether to use virtual environment. If `false`, the
# interpreter according to `PRIMARY_PYTHON` found in `PATH` is used.
Expand Down
4 changes: 4 additions & 0 deletions src/mxmake/tests/test_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ def test_MakefileParser(self, tempdir):
"core.base.EXTRA_PATH": "",
"core.mxenv.PRIMARY_PYTHON": "python3",
"core.mxenv.PYTHON_MIN_VERSION": "3.7",
"core.mxenv.PYTHON_PACKAGE_INSTALLER": "pip",
"core.mxenv.PYTHON_UV_GLOBAL": "false",
"core.mxenv.VENV_ENABLED": "true",
"core.mxenv.VENV_CREATE": "true",
"core.mxenv.VENV_FOLDER": "venv",
Expand Down Expand Up @@ -65,6 +67,8 @@ def test_MakefileParser(self, tempdir):
"core.base.EXTRA_PATH": "",
"core.mxenv.PRIMARY_PYTHON": "python3",
"core.mxenv.PYTHON_MIN_VERSION": "3.7",
"core.mxenv.PYTHON_PACKAGE_INSTALLER": "pip",
"core.mxenv.PYTHON_UV_GLOBAL": "false",
"core.mxenv.VENV_ENABLED": "true",
"core.mxenv.VENV_CREATE": "true",
"core.mxenv.VENV_FOLDER": "venv",
Expand Down
51 changes: 41 additions & 10 deletions src/mxmake/tests/test_templates.py
Original file line number Diff line number Diff line change
Expand Up @@ -526,6 +526,8 @@ def test_Makefile(self, tempdir):
"core.base.EXTRA_PATH": "",
"core.mxenv.PRIMARY_PYTHON": "python3",
"core.mxenv.PYTHON_MIN_VERSION": "3.7",
"core.mxenv.PYTHON_PACKAGE_INSTALLER": "pip",
"core.mxenv.PYTHON_UV_GLOBAL": "false",
"core.mxenv.VENV_ENABLED": "true",
"core.mxenv.VENV_CREATE": "true",
"core.mxenv.VENV_FOLDER": "venv",
Expand Down Expand Up @@ -596,6 +598,11 @@ def test_Makefile(self, tempdir):
# Default: pip
PYTHON_PACKAGE_INSTALLER?=pip
# Flag whether to use a global installed 'uv' or install
# it in the virtual environment.
# Default: false
PYTHON_UV_GLOBAL?=false
# Flag whether to use virtual environment. If `false`, the
# interpreter according to `PRIMARY_PYTHON` found in `PATH` is used.
# Default: true
Expand Down Expand Up @@ -683,20 +690,44 @@ def test_Makefile(self, tempdir):
MXENV_PYTHON=$(PRIMARY_PYTHON)
endif
# determine the package installer
ifeq ("$(PYTHON_PACKAGE_INSTALLER)","uv")
# use uv
PYTHON_PACKAGE_COMMAND=uv pip
else
# use/default to pip
PYTHON_PACKAGE_COMMAND=$(MXENV_PYTHON) -m pip
endif # /PYTHON_PACKAGE_INSTALLER
MXENV_TARGET:=$(SENTINEL_FOLDER)/mxenv.sentinel
$(MXENV_TARGET): $(SENTINEL)
ifeq ("$(VENV_ENABLED)", "true")
# Use a venv
ifeq ("$(VENV_CREATE)", "true")
@echo "Setup Python Virtual Environment under '$(VENV_FOLDER)'"
@$(PRIMARY_PYTHON) -m venv $(VENV_FOLDER)
endif
endif
@$(MXENV_PYTHON) -m ensurepip -U
@$(PYTHON_PACKAGE_COMMAND) install -U pip setuptools wheel
@$(PYTHON_PACKAGE_COMMAND) install -U $(MXDEV)
@$(PYTHON_PACKAGE_COMMAND) install -U $(MXMAKE)
@touch $(MXENV_TARGET)
# Create a venv
ifeq ("$(PYTHON_PACKAGE_INSTALLER)$(PYTHON_UV_GLOBAL)", "uvtrue")
# create venv with global uv
@echo "Setup Python Virtual Environment using package 'uv' at '$(VENV_FOLDER)'"
@uv venv -p $(PRIMARY_PYTHON) --seed $(VENV_FOLDER)
else
@echo "Setup Python Virtual Environment using module 'venv' at '$(VENV_FOLDER)'"
@$(MXENV_PYTHON) -m venv $(VENV_FOLDER)
@$(MXENV_PYTHON) -m ensurepip -U
endif # /PYTHON_PACKAGE_INSTALLER uv and PYTHON_UV_GLOBAL
ifeq ("$(PYTHON_PACKAGE_INSTALLER)$(PYTHON_UV_GLOBAL)", "uvfalse")
@echo "Install uv"
@$(MXENV_PYTHON) -m pip install uv
endif # /PYTHON_PACKAGE_INSTALLER uv and not PYTHON_UV_GLOBAL
# always update pip, setuptools and wheel
@$(PYTHON_PACKAGE_COMMAND) install -U pip setuptools wheel
endif # /VENV_CREATE
else
@echo "Using system Python interpreter"
endif # /VENV_ENABLED
@echo "Install/Update MXStack Python packages"
@$(PYTHON_PACKAGE_COMMAND) install -U $(MXDEV) $(MXMAKE)
@touch $(MXENV_TARGET)
.PHONY: mxenv
mxenv: $(MXENV_TARGET)
Expand Down

0 comments on commit ab6f55c

Please sign in to comment.