55
66# Python version (python3 required).
77export PYTHON ?= python3
8- # Python packaging
9- export PIP ?= pip3
108# PIP_OPTIONS ?= # empty
119# Derived variable to allow filtering -e, or inserting other options
1210# (the option --editable must always be last and only applies to src install)
@@ -120,7 +118,6 @@ Variables:
120118 VIRTUAL_ENV: absolute path to (re-)use for the virtual environment
121119 TMPDIR: path to use for temporary storage instead of the system default
122120 PYTHON: name of the Python binary
123- PIP: name of the Python packaging binary
124121 PIP_OPTIONS: extra options for the `pip install` command like `-q` or `-v` or `-e`
125122 TESSERACT_MODELS: list of additional models/languages to download for Tesseract. Default: "$(ALL_TESSERACT_MODELS ) "
126123 TESSERACT_CONFIG: command line options for Tesseract `configure`. Default: "$(TESSERACT_CONFIG ) "
@@ -158,20 +155,20 @@ deinit:
158155
159156# Get Python modules.
160157
161- $(VIRTUAL_ENV ) /bin/$( PIP ) : $(ACTIVATE_VENV )
162- . $(ACTIVATE_VENV ) && $(SEMPIP ) $( PIP ) install --upgrade pip setuptools
158+ $(VIRTUAL_ENV ) /bin/pip : $(ACTIVATE_VENV )
159+ . $(ACTIVATE_VENV ) && $(SEMPIP ) pip install --upgrade pip setuptools
163160
164161$(ACTIVATE_VENV ) $(VIRTUAL_ENV ) :
165162 $(SEMPIP ) $(PYTHON ) -m venv $(VIRTUAL_ENV )
166163
167164.PHONY : wheel
168165wheel : $(BIN ) /wheel
169166$(BIN ) /wheel : | $(ACTIVATE_VENV )
170- . $(ACTIVATE_VENV ) && $(SEMPIP ) $( PIP ) install --force-reinstall $(PIP_OPTIONS_E ) wheel
167+ . $(ACTIVATE_VENV ) && $(SEMPIP ) pip install --force-reinstall $(PIP_OPTIONS_E ) wheel
171168
172169# avoid making this .PHONY so it does not have to be repeated
173170$(SHARE ) /numpy : | $(ACTIVATE_VENV ) $(SHARE )
174- . $(ACTIVATE_VENV ) && $(SEMPIP ) $( PIP ) install $(PIP_OPTIONS_E ) numpy
171+ . $(ACTIVATE_VENV ) && $(SEMPIP ) pip install $(PIP_OPTIONS_E ) numpy
175172 @touch $@
176173
177174# Install modules from source.
@@ -180,7 +177,7 @@ $(SHARE)/numpy: | $(ACTIVATE_VENV) $(SHARE)
180177ocrd : $(BIN ) /ocrd
181178deps-ubuntu-modules : core
182179$(BIN ) /ocrd : core
183- . $(ACTIVATE_VENV ) && $(MAKE ) -C $< install PIP=" $( SEMPIP) $( PIP ) " PIP_INSTALL=" $( SEMPIP) $( PIP ) install $( PIP_OPTIONS) " && touch -c $@
180+ . $(ACTIVATE_VENV ) && $(MAKE ) -C $< install PIP=" $( SEMPIP) pip PIP_INSTALL=" $(SEMPIP ) pip install $(PIP_OPTIONS ) " && touch -c $@
184181
185182# Convert the executable names (1) to a pattern rule,
186183# so that the recipe will be used with single-recipe-
@@ -193,7 +190,7 @@ OCRD_EXECUTABLES += $(PAGE2IMG)
193190PAGE2IMG := $(BIN ) /page2img
194191format-converters/page2img.py : format-converters
195192$(PAGE2IMG ) : format-converters/page2img.py
196- . $(ACTIVATE_VENV ) && $(SEMPIP ) $( PIP ) install validators
193+ . $(ACTIVATE_VENV ) && $(SEMPIP ) pip install validators
197194 echo " #!$( BIN) /python3" | cat - $< > $@
198195 chmod +x $@
199196endif
@@ -206,7 +203,7 @@ opencv-python: GIT_RECURSIVE = --recursive
206203opencv-python/setup.py : opencv-python
207204$(SHARE ) /opencv-python : opencv-python/setup.py | $(ACTIVATE_VENV ) $(SHARE ) $(SHARE ) /numpy
208205 . $(ACTIVATE_VENV ) && cd opencv-python && ENABLE_HEADLESS=1 $(PYTHON ) setup.py bdist_wheel
209- . $(ACTIVATE_VENV ) && $(SEMPIP ) $( PIP ) install $(<D ) /dist/opencv_python_headless-* .whl
206+ . $(ACTIVATE_VENV ) && $(SEMPIP ) pip install $(<D ) /dist/opencv_python_headless-* .whl
210207 @touch $@
211208$(BIN ) /ocrd : $(SHARE ) /opencv-python
212209endif
@@ -609,17 +606,17 @@ endif
609606# install again forcefully without depds (to ensure
610607# the binary itself updates):
611608define pip_install
612- . $(ACTIVATE_VENV ) && cd $< && $(SEMPIP ) $( PIP ) install $(PIP_OPTIONS_E ) . && touch -c $@
609+ . $(ACTIVATE_VENV ) && cd $< && $(SEMPIP ) pip install $(PIP_OPTIONS_E ) . && touch -c $@
613610endef
614611
615612# Workaround for missing prebuilt versions of TF<2 for Python==3.8
616613# todo: find another solution for 3.9, 3.10 etc
617614# Nvidia has them, but under a different name, so let's rewrite that:
618615define pip_install_tf1nvidia =
619- . $(ACTIVATE_VENV ) && if test $(PYTHON_VERSION ) = 3.8 && ! $( PIP ) show -q tensorflow-gpu; then \
620- $(SEMPIP ) $( PIP ) install nvidia-pyindex && \
616+ . $(ACTIVATE_VENV ) && if test $(PYTHON_VERSION ) = 3.8 && ! pip show -q tensorflow-gpu; then \
617+ $(SEMPIP ) pip install nvidia-pyindex && \
621618 pushd $$(mktemp -d ) && \
622- $(SEMPIP ) $( PIP ) download --no-deps nvidia-tensorflow && \
619+ $(SEMPIP ) pip download --no-deps nvidia-tensorflow && \
623620 for name in nvidia_tensorflow-*.whl; do name=$${name%.whl}; done && \
624621 $(PYTHON ) -m wheel unpack $$name.whl && \
625622 for name in nvidia_tensorflow-*/; do name=$${name%/}; done && \
@@ -629,10 +626,10 @@ define pip_install_tf1nvidia =
629626 sed -i s/nvidia_tensorflow/tensorflow_gpu/g $$name/tensorflow_core/tools/pip_package/setup.py && \
630627 pushd $$name && for path in $$name*; do mv $$path $${path/$$name/$$newname}; done && popd && \
631628 $(PYTHON ) -m wheel pack $$name && \
632- $(SEMPIP ) $( PIP ) install $$newname*.whl && popd && rm -fr $$OLDPWD; fi
629+ $(SEMPIP ) pip install $$newname*.whl && popd && rm -fr $$OLDPWD; fi
633630# - preempt conflict over numpy between scikit-image and tensorflow
634631# - preempt conflict over numpy between tifffile and tensorflow (and allow py36)
635- . $(ACTIVATE_VENV ) && $(SEMPIP ) $( PIP ) install imageio==2.14.1 "tifffile<2022"
632+ . $(ACTIVATE_VENV ) && $(SEMPIP ) pip install imageio==2.14.1 "tifffile<2022"
636633endef
637634
638635# pattern for recursive make:
@@ -686,14 +683,14 @@ endif
686683# avoid making these .PHONY so they do not have to be repeated:
687684# tesserocr
688685$(SHARE ) /% : % | $(ACTIVATE_VENV ) $(SHARE )
689- . $(ACTIVATE_VENV ) && cd $< && $(SEMPIP ) $( PIP ) install $(PIP_OPTIONS ) .
686+ . $(ACTIVATE_VENV ) && cd $< && $(SEMPIP ) pip install $(PIP_OPTIONS ) .
690687 @touch $@
691688
692689$(SHARE ) :
693690 @mkdir -p " $@ "
694691
695692# At last, add venv dependency (must not become first):
696- $(OCRD_EXECUTABLES ) $(BIN ) /wheel : | $(VIRTUAL_ENV ) /bin/$( PIP )
693+ $(OCRD_EXECUTABLES ) $(BIN ) /wheel : | $(VIRTUAL_ENV ) /bin/pip
697694$(OCRD_EXECUTABLES ) : | $(BIN ) /wheel
698695# Also, add core dependency (but in a non-circular way):
699696$(filter-out $(BIN ) /ocrd,$(OCRD_EXECUTABLES ) ) : $(BIN ) /ocrd
@@ -706,7 +703,7 @@ show:
706703 @echo OCRD_EXECUTABLES = $(OCRD_EXECUTABLES:$(BIN ) /%=% )
707704
708705check : $(OCRD_EXECUTABLES:%=%-check ) $(OCRD_MODULES:%=%-check )
709- . $(ACTIVATE_VENV ) && $( PIP ) check
706+ . $(ACTIVATE_VENV ) && pip check
710707% -check : ;
711708
712709.PHONY : $(OCRD_EXECUTABLES:%=%-check )
@@ -840,7 +837,7 @@ endif
840837 chown -R --reference=$(HOME) $(HOME)/.parallel
841838
842839deps-ubuntu-modules :
843- set -e; for dir in $^; do $( MAKE) -C $$ dir deps-ubuntu PYTHON=$( PYTHON) PIP= $( PIP ) ; done
840+ set -e; for dir in $^; do $( MAKE) -C $$ dir deps-ubuntu PYTHON=$( PYTHON) ; done
844841 apt-get -y install $(CUSTOM_DEPS )
845842
846843.PHONY : deps-ubuntu deps-ubuntu-modules
0 commit comments