Skip to content

Commit 4db7c0c

Browse files
sethknilfm99
authored andcommitted
Don't install cythonize dependencies unless cythonizing
Numpy is not building in my environment, but I should not need to have it if all I want to build is the default libvmaf target. Additionally: Instead of using the mtime of the .venv directory as a marker for whether meson and ninja were successfully installed, use their wrapper scripts from .venv/bin. The $(VENV) target uses set -e and escaped newlines to run all commands in a single shell invocation. Unless these commands are modifying the shell's environment, this is redundant and mimics the way make already works when you put a single command on each line.
1 parent f413312 commit 4db7c0c

File tree

1 file changed

+23
-15
lines changed

1 file changed

+23
-15
lines changed

Makefile

+23-15
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ VIRTUAL_ENV_PATH := $(VENV)/bin
99
PYTHON_INTERPRETER := python3.10
1010
VENV_PIP := $(VIRTUAL_ENV_PATH)/pip
1111
VENV_PYTHON := $(VIRTUAL_ENV_PATH)/python
12-
MESON_SETUP := $(VIRTUAL_ENV_PATH)/meson setup
12+
MESON := $(VIRTUAL_ENV_PATH)/meson
13+
MESON_SETUP := $(MESON) setup
1314
NINJA := $(VIRTUAL_ENV_PATH)/ninja
1415

1516
# Build types and options
@@ -22,31 +23,31 @@ LIBVMAF_DIR := libvmaf
2223
BUILD_DIR := $(LIBVMAF_DIR)/build
2324
DEBUG_DIR := $(LIBVMAF_DIR)/debug
2425

25-
.PHONY: default all debug build install cythonize clean distclean
26+
.PHONY: default all debug build install cythonize clean distclean cythonize-deps
2627

2728
default: build
2829

2930
all: build debug install test cythonize
3031

31-
$(BUILD_DIR): $(VENV)
32+
$(BUILD_DIR): $(MESON) $(NINJA)
3233
PATH="$(VENV)/bin:$$PATH" $(MESON_SETUP) $(BUILD_DIR) $(LIBVMAF_DIR) $(BUILDTYPE_RELEASE) $(ENABLE_FLOAT)
3334

34-
$(DEBUG_DIR): $(VENV)
35+
$(DEBUG_DIR): $(MESON) $(NINJA)
3536
PATH="$(VENV)/bin:$$PATH" $(MESON_SETUP) $(DEBUG_DIR) $(LIBVMAF_DIR) $(BUILDTYPE_DEBUG) $(ENABLE_FLOAT)
3637

37-
cythonize: $(VENV)
38+
cythonize: cythonize-deps
3839
pushd python && ../$(VENV_PYTHON) setup.py build_ext --build-lib . && popd || exit 1
3940

40-
build: $(BUILD_DIR) $(VENV)
41+
build: $(BUILD_DIR) $(NINJA)
4142
PATH="$(VENV)/bin:$$PATH" $(NINJA) -vC $(BUILD_DIR)
4243

43-
test: build $(VENV)
44+
test: build $(NINJA)
4445
PATH="$(VENV)/bin:$$PATH" $(NINJA) -vC $(BUILD_DIR) test
4546

46-
debug: $(DEBUG_DIR) $(VENV)
47+
debug: $(DEBUG_DIR) $(NINJA)
4748
PATH="$(VENV)/bin:$$PATH" $(NINJA) -vC $(DEBUG_DIR)
4849

49-
install: $(BUILD_DIR) $(VENV)
50+
install: $(BUILD_DIR) $(NINJA)
5051
PATH="$(VENV)/bin:$$PATH" $(NINJA) -vC $(BUILD_DIR) install
5152

5253
clean:
@@ -57,10 +58,17 @@ distclean: clean
5758
rm -rf $(VENV)
5859

5960
# Set up or rebuild virtual environment
60-
$(VENV):
61+
$(VENV_PIP):
6162
@echo "Setting up the virtual environment..."
62-
@set -e; \
63-
$(PYTHON_INTERPRETER) -m venv $(VENV) || { echo "Failed to create virtual environment"; exit 1; }; \
64-
$(VENV_PIP) install --upgrade pip || { echo "Failed to upgrade pip"; exit 1; }; \
65-
$(VENV_PIP) install meson ninja cython numpy || { echo "Failed to install dependencies"; exit 1; }
66-
@echo "Virtual environment setup complete."
63+
$(PYTHON_INTERPRETER) -m venv $(VENV) || { echo "Failed to create virtual environment"; exit 1; }
64+
$(VENV_PIP) install --upgrade pip || { echo "Failed to upgrade pip"; exit 1; }
65+
@echo "Virtual environment setup complete."
66+
67+
$(MESON): $(VENV_PIP)
68+
$(VENV_PIP) install meson || { echo "Failed to install meson"; exit 1; }
69+
70+
$(NINJA): $(VENV_PIP)
71+
$(VENV_PIP) install ninja || { echo "Failed to install ninja"; exit 1; }
72+
73+
cythonize-deps: $(VENV_PIP)
74+
$(VENV_PIP) install setuptools cython numpy || { echo "Failed to install dependencies"; exit 1; }

0 commit comments

Comments
 (0)