Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't install cythonize dependencies unless cythonizing #1405

Merged
merged 1 commit into from
Feb 12, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 23 additions & 15 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ VIRTUAL_ENV_PATH := $(VENV)/bin
PYTHON_INTERPRETER := python3.10
VENV_PIP := $(VIRTUAL_ENV_PATH)/pip
VENV_PYTHON := $(VIRTUAL_ENV_PATH)/python
MESON_SETUP := $(VIRTUAL_ENV_PATH)/meson setup
MESON := $(VIRTUAL_ENV_PATH)/meson
MESON_SETUP := $(MESON) setup
NINJA := $(VIRTUAL_ENV_PATH)/ninja

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

.PHONY: default all debug build install cythonize clean distclean
.PHONY: default all debug build install cythonize clean distclean cythonize-deps

default: build

all: build debug install test cythonize

$(BUILD_DIR): $(VENV)
$(BUILD_DIR): $(MESON) $(NINJA)
PATH="$(VENV)/bin:$$PATH" $(MESON_SETUP) $(BUILD_DIR) $(LIBVMAF_DIR) $(BUILDTYPE_RELEASE) $(ENABLE_FLOAT)

$(DEBUG_DIR): $(VENV)
$(DEBUG_DIR): $(MESON) $(NINJA)
PATH="$(VENV)/bin:$$PATH" $(MESON_SETUP) $(DEBUG_DIR) $(LIBVMAF_DIR) $(BUILDTYPE_DEBUG) $(ENABLE_FLOAT)

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

build: $(BUILD_DIR) $(VENV)
build: $(BUILD_DIR) $(NINJA)
PATH="$(VENV)/bin:$$PATH" $(NINJA) -vC $(BUILD_DIR)

test: build $(VENV)
test: build $(NINJA)
PATH="$(VENV)/bin:$$PATH" $(NINJA) -vC $(BUILD_DIR) test

debug: $(DEBUG_DIR) $(VENV)
debug: $(DEBUG_DIR) $(NINJA)
PATH="$(VENV)/bin:$$PATH" $(NINJA) -vC $(DEBUG_DIR)

install: $(BUILD_DIR) $(VENV)
install: $(BUILD_DIR) $(NINJA)
PATH="$(VENV)/bin:$$PATH" $(NINJA) -vC $(BUILD_DIR) install

clean:
Expand All @@ -57,10 +58,17 @@ distclean: clean
rm -rf $(VENV)

# Set up or rebuild virtual environment
$(VENV):
$(VENV_PIP):
@echo "Setting up the virtual environment..."
@set -e; \
$(PYTHON_INTERPRETER) -m venv $(VENV) || { echo "Failed to create virtual environment"; exit 1; }; \
$(VENV_PIP) install --upgrade pip || { echo "Failed to upgrade pip"; exit 1; }; \
$(VENV_PIP) install meson ninja cython numpy || { echo "Failed to install dependencies"; exit 1; }
@echo "Virtual environment setup complete."
$(PYTHON_INTERPRETER) -m venv $(VENV) || { echo "Failed to create virtual environment"; exit 1; }
$(VENV_PIP) install --upgrade pip || { echo "Failed to upgrade pip"; exit 1; }
@echo "Virtual environment setup complete."

$(MESON): $(VENV_PIP)
$(VENV_PIP) install meson || { echo "Failed to install meson"; exit 1; }

$(NINJA): $(VENV_PIP)
$(VENV_PIP) install ninja || { echo "Failed to install ninja"; exit 1; }

cythonize-deps: $(VENV_PIP)
$(VENV_PIP) install setuptools cython numpy || { echo "Failed to install dependencies"; exit 1; }
Loading