Open aholmes opened 7 months ago
The Makefile attempts to install the correct psycopg2 dependency. make $(SETUP_DEV_SENTINEL)
and make $(SETUP_CICD_SENTINEL)
will install the src/database[postgres-binary]
dependency, which installs psycopg2-binary
. Similarly, make $(PACKAGES)
will install BL_Python.database[postgres-binary]
if the target is BL_Python.database
. There are no checks that the package works correctly; it is assumed that the correct binary package will be installed by pip
.
However, in another project (internal name "CAP") we have gone further and verified the installation works and tried to resolve installation problems with it. This project installs BL_Python.database[postgres-binary]
(per its pyproject.toml dependencies). This happens automatically when make
is run (through the chain of prereqs).
validate-psycopg2-install: $(VENV) $(SETUP_DEV_BACKEND_SENTINEL)
@$(ACTIVATE_VENV) && \
if ! python3 -c 'import psycopg2'; then \
pip install psycopg2-binary --no-cache-dir --force-reinstall; \
fi ; \
if ! python3 -c 'import psycopg2'; then \
echo "psycopg2 is not properly installed in the venv at $(VENV)"; \
else \
echo "psycopg2 is installed and working in the venv at $(VENV)."; \
fi
Note that we have thus far intentionally avoided compiling psycopg2 on development machines because many of them lack the libxml2 dependencies.
Currently, postgres support requires running
pip install BL_Python.database[postgres]
orpip install BL_Python.database[postgres-binary]
. Document this. Or, is there a better way to go about it?The reason it is an optional dependency is because the psycopg2 binary must be built, or the pre-built binary must be used. Some machines can build the binary without issue while others require some extra steps. The intent is to make this easier for users.