Skip to content

Commit 16a0741

Browse files
colindeanGitHub Enterprise
authored andcommitted
Merge pull request #10 from python/linux-homebrew
Enables use with Homebrew on Linux by breaking some pyenv rules
2 parents 5abf350 + dd23ad9 commit 16a0741

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

Makefile

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,13 +237,28 @@ deps-ci: poetry-install $(DEPS_TASKS_IF_PERU_CONFIG) ## Install CI check and te
237237
install-python: $(PYTHON_EXEC) ## Installs appropriate Python version
238238
@echo "$(COLOR_GREEN)Python installed to $(PYTHON_EXEC)$(COLOR_RESET)"
239239

240+
# Pyenv already automatically uses Homebrew's libraries if available on macOS
241+
ifeq ($(shell uname -s), Darwin)
242+
PYENV_FLAGS =
243+
endif
244+
# Force use of Homebrew's libraries in Linux
245+
# Pyenv discourages this, preferring use of distro-provided libraries.
246+
# We want to link against Homebrew for dev workstation use, but rely on
247+
# distro Python in CI, which is why deps-ci doesn't install Python!
248+
ifeq ($(shell uname -s), Linux)
249+
PYENV_FLAGS = CFLAGS="$(shell pkg-config --cflags libffi ncurses readline)" \
250+
LDFLAGS="$(shell pkg-config --libs libffi ncurses readline)" \
251+
CC="$(firstword $(wildcard $(shell brew --prefix gcc)/bin/gcc-*))"
252+
endif
253+
240254
$(PYTHON_EXEC): $(PYTHON_VERSION_FILE)
241255
@echo "$(COLOR_BLUE)Installing Pythons from $(PYTHON_VERSION_FILE) using $(PYENV):$(COLOR_ORANGE)"
242256
@grep ^[^\n#] $(PYTHON_VERSION_FILE) | sed -e 's/^/\t/'
243257
@echo "$(COLOR_RESET)"
244258

245259
grep ^[^\n#] $(PYTHON_VERSION_FILE) | while read -r py ; do \
246-
$(PYENV) install --verbose --skip-existing "$${py}" ; done
260+
$(PYENV_FLAGS) $(PYENV) install --verbose --skip-existing "$${py}" ; \
261+
done
247262

248263
##@ Poetry
249264

0 commit comments

Comments
 (0)