2010-11-13 22:45:45 +03:00
|
|
|
# Makefile for psycopg2. Do you want to...
|
|
|
|
#
|
|
|
|
# Build the library::
|
|
|
|
#
|
|
|
|
# make
|
|
|
|
#
|
|
|
|
# Build the documentation::
|
|
|
|
#
|
2014-08-25 02:08:01 +04:00
|
|
|
# make env (once)
|
2010-11-13 22:45:45 +03:00
|
|
|
# make docs
|
|
|
|
#
|
|
|
|
# Create a source package::
|
|
|
|
#
|
|
|
|
# make sdist
|
|
|
|
#
|
|
|
|
# Run the test::
|
|
|
|
#
|
2010-12-01 23:55:42 +03:00
|
|
|
# make check # this requires setting up a test database with the correct user
|
2010-11-13 22:45:45 +03:00
|
|
|
|
|
|
|
PYTHON := python$(PYTHON_VERSION)
|
2010-12-12 19:20:02 +03:00
|
|
|
PYTHON_VERSION ?= $(shell $(PYTHON) -c 'import sys; print ("%d.%d" % sys.version_info[:2])')
|
2010-11-13 22:45:45 +03:00
|
|
|
BUILD_DIR = $(shell pwd)/build/lib.$(PYTHON_VERSION)
|
2007-11-11 13:40:12 +03:00
|
|
|
|
2010-11-13 22:45:45 +03:00
|
|
|
SOURCE_C := $(wildcard psycopg/*.c psycopg/*.h)
|
|
|
|
SOURCE_PY := $(wildcard lib/*.py)
|
2011-01-02 04:57:33 +03:00
|
|
|
SOURCE_TESTS := $(wildcard tests/*.py)
|
2010-11-13 22:45:45 +03:00
|
|
|
SOURCE_DOC := $(wildcard doc/src/*.rst)
|
2011-01-02 04:57:33 +03:00
|
|
|
SOURCE := $(SOURCE_C) $(SOURCE_PY) $(SOURCE_TESTS) $(SOURCE_DOC)
|
2010-11-13 22:45:45 +03:00
|
|
|
|
|
|
|
PACKAGE := $(BUILD_DIR)/psycopg2
|
|
|
|
PLATLIB := $(PACKAGE)/_psycopg.so
|
2017-12-04 05:47:19 +03:00
|
|
|
PURELIB := $(patsubst lib/%,$(PACKAGE)/%,$(SOURCE_PY))
|
2010-11-13 22:45:45 +03:00
|
|
|
|
2010-11-14 21:23:09 +03:00
|
|
|
BUILD_OPT := --build-lib=$(BUILD_DIR)
|
|
|
|
BUILD_EXT_OPT := --build-lib=$(BUILD_DIR)
|
|
|
|
SDIST_OPT := --formats=gztar
|
|
|
|
|
|
|
|
ifdef PG_CONFIG
|
|
|
|
BUILD_EXT_OPT += --pg-config=$(PG_CONFIG)
|
|
|
|
endif
|
|
|
|
|
2010-11-13 22:45:45 +03:00
|
|
|
VERSION := $(shell grep PSYCOPG_VERSION setup.py | head -1 | sed -e "s/.*'\(.*\)'/\1/")
|
|
|
|
SDIST := dist/psycopg2-$(VERSION).tar.gz
|
|
|
|
|
2010-12-21 07:24:55 +03:00
|
|
|
.PHONY: env check clean
|
2010-11-13 22:45:45 +03:00
|
|
|
|
|
|
|
default: package
|
|
|
|
|
2010-12-21 07:24:55 +03:00
|
|
|
all: package sdist
|
2010-11-13 22:45:45 +03:00
|
|
|
|
|
|
|
package: $(PLATLIB) $(PURELIB)
|
|
|
|
|
|
|
|
docs: docs-html docs-txt
|
|
|
|
|
2010-11-13 23:31:53 +03:00
|
|
|
docs-html: doc/html/genindex.html
|
2010-11-13 22:45:45 +03:00
|
|
|
|
|
|
|
docs-txt: doc/psycopg2.txt
|
|
|
|
|
2010-12-05 00:45:14 +03:00
|
|
|
# for PyPI documentation
|
|
|
|
docs-zip: doc/docs.zip
|
|
|
|
|
2010-11-13 22:45:45 +03:00
|
|
|
sdist: $(SDIST)
|
|
|
|
|
2014-08-25 02:08:01 +04:00
|
|
|
env:
|
|
|
|
$(MAKE) -C doc $@
|
2007-11-11 13:40:12 +03:00
|
|
|
|
|
|
|
check:
|
2017-12-11 05:22:02 +03:00
|
|
|
PYTHONPATH=$(BUILD_DIR) $(PYTHON) -c "import tests; tests.unittest.main(defaultTest='tests.test_suite')" --verbose
|
2010-11-13 22:45:45 +03:00
|
|
|
|
|
|
|
testdb:
|
2007-11-11 13:40:12 +03:00
|
|
|
@echo "* Creating $(TESTDB)"
|
|
|
|
@if psql -l | grep -q " $(TESTDB) "; then \
|
|
|
|
dropdb $(TESTDB) >/dev/null; \
|
|
|
|
fi
|
|
|
|
createdb $(TESTDB)
|
2010-11-02 02:43:38 +03:00
|
|
|
# Note to packagers: this requires the postgres user running the test
|
|
|
|
# to be a superuser. You may change this line to use the superuser only
|
|
|
|
# to install the contrib. Feel free to suggest a better way to set up the
|
|
|
|
# testing environment (as the current is enough for development).
|
|
|
|
psql -f `pg_config --sharedir`/contrib/hstore.sql $(TESTDB)
|
2010-11-13 22:45:45 +03:00
|
|
|
|
|
|
|
|
|
|
|
$(PLATLIB): $(SOURCE_C)
|
2010-11-14 21:23:09 +03:00
|
|
|
$(PYTHON) setup.py build_ext $(BUILD_EXT_OPT)
|
2010-11-13 22:45:45 +03:00
|
|
|
|
|
|
|
$(PACKAGE)/%.py: lib/%.py
|
2011-01-02 04:37:36 +03:00
|
|
|
$(PYTHON) setup.py build_py $(BUILD_OPT)
|
|
|
|
touch $@
|
2010-11-13 22:45:45 +03:00
|
|
|
|
2011-01-02 04:57:33 +03:00
|
|
|
$(PACKAGE)/tests/%.py: tests/%.py
|
|
|
|
$(PYTHON) setup.py build_py $(BUILD_OPT)
|
|
|
|
touch $@
|
2010-11-13 22:45:45 +03:00
|
|
|
|
2016-03-08 07:34:12 +03:00
|
|
|
$(SDIST): $(SOURCE)
|
2010-11-14 21:23:09 +03:00
|
|
|
$(PYTHON) setup.py sdist $(SDIST_OPT)
|
2010-11-13 22:45:45 +03:00
|
|
|
|
|
|
|
# docs depend on the build as it partly use introspection.
|
2010-11-13 23:31:53 +03:00
|
|
|
doc/html/genindex.html: $(PLATLIB) $(PURELIB) $(SOURCE_DOC)
|
2015-04-28 11:30:59 +03:00
|
|
|
$(MAKE) -C doc html
|
2010-11-13 22:45:45 +03:00
|
|
|
|
2010-11-13 23:31:53 +03:00
|
|
|
doc/psycopg2.txt: $(PLATLIB) $(PURELIB) $(SOURCE_DOC)
|
2015-04-28 11:30:59 +03:00
|
|
|
$(MAKE) -C doc text
|
2010-11-13 22:45:45 +03:00
|
|
|
|
2010-12-05 00:45:14 +03:00
|
|
|
doc/docs.zip: doc/html/genindex.html
|
|
|
|
(cd doc/html && zip -r ../docs.zip *)
|
2010-11-13 22:45:45 +03:00
|
|
|
|
|
|
|
clean:
|
2016-03-08 07:34:12 +03:00
|
|
|
rm -rf build
|
2010-11-13 22:45:45 +03:00
|
|
|
$(MAKE) -C doc clean
|