Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 136 lines (104 sloc) 3.737 kb
9ffcb900 » dvarrazzo
2010-11-13 Added flesh to the Makefile.
1 # Makefile for psycopg2. Do you want to...
2 #
3 # Build the library::
4 #
5 # make
6 #
7 # Build the documentation::
8 #
9 # make env
10 # make docs
11 #
12 # Create a source package::
13 #
14 # make env # required to build the documentation
15 # make sdist
16 #
17 # Run the test::
18 #
5f80dd38 » fogzot
2010-12-01 Removed runtests target; checks is the default for Makefiles
19 # make check # this requires setting up a test database with the correct user
9ffcb900 » dvarrazzo
2010-11-13 Added flesh to the Makefile.
20
21 PYTHON := python$(PYTHON_VERSION)
22 PYTHON_VERSION ?= $(shell $(PYTHON) -c 'import sys; print "%d.%d" % sys.version_info[:2]')
23 BUILD_DIR = $(shell pwd)/build/lib.$(PYTHON_VERSION)
d07791cf » dvarrazzo
2010-11-13 Fixed setuptools installation from scratch.
24 ENV_DIR = $(shell pwd)/env/py-$(PYTHON_VERSION)
25 ENV_BIN = $(ENV_DIR)/bin
26 ENV_LIB = $(ENV_DIR)/lib
67afd678 » dvarrazzo
2007-11-11 Added 'make check' target, running all the available tests.
27
9ffcb900 » dvarrazzo
2010-11-13 Added flesh to the Makefile.
28 SOURCE_C := $(wildcard psycopg/*.c psycopg/*.h)
29 SOURCE_PY := $(wildcard lib/*.py)
17f69ba7 » dvarrazzo
2011-01-02 Fixed Makefile dependencies of the test suite.
30 SOURCE_TESTS := $(wildcard tests/*.py)
9ffcb900 » dvarrazzo
2010-11-13 Added flesh to the Makefile.
31 SOURCE_DOC := $(wildcard doc/src/*.rst)
17f69ba7 » dvarrazzo
2011-01-02 Fixed Makefile dependencies of the test suite.
32 SOURCE := $(SOURCE_C) $(SOURCE_PY) $(SOURCE_TESTS) $(SOURCE_DOC)
9ffcb900 » dvarrazzo
2010-11-13 Added flesh to the Makefile.
33
34 PACKAGE := $(BUILD_DIR)/psycopg2
35 PLATLIB := $(PACKAGE)/_psycopg.so
17f69ba7 » dvarrazzo
2011-01-02 Fixed Makefile dependencies of the test suite.
36 PURELIB := $(patsubst lib/%,$(PACKAGE)/%,$(SOURCE_PY)) \
37 $(patsubst tests/%,$(PACKAGE)/tests/%,$(SOURCE_TESTS))
9ffcb900 » dvarrazzo
2010-11-13 Added flesh to the Makefile.
38
0a285647 » dvarrazzo
2010-11-14 The Makefile can receive the pg_config location.
39 BUILD_OPT := --build-lib=$(BUILD_DIR)
40 BUILD_EXT_OPT := --build-lib=$(BUILD_DIR)
41 SDIST_OPT := --formats=gztar
42
43 ifdef PG_CONFIG
44 BUILD_EXT_OPT += --pg-config=$(PG_CONFIG)
45 endif
46
9ffcb900 » dvarrazzo
2010-11-13 Added flesh to the Makefile.
47 VERSION := $(shell grep PSYCOPG_VERSION setup.py | head -1 | sed -e "s/.*'\(.*\)'/\1/")
48 SDIST := dist/psycopg2-$(VERSION).tar.gz
49
d07791cf » dvarrazzo
2010-11-13 Fixed setuptools installation from scratch.
50 EASY_INSTALL = PYTHONPATH=$(ENV_LIB) $(ENV_BIN)/easy_install-$(PYTHON_VERSION) -d $(ENV_LIB) -s $(ENV_BIN)
51 EZ_SETUP = $(ENV_BIN)/ez_setup.py
9ffcb900 » dvarrazzo
2010-11-13 Added flesh to the Makefile.
52
53 .PHONY: env check runtests clean
54
55 default: package
56
57 all: package runtests sdist
58
59 package: $(PLATLIB) $(PURELIB)
60
61 docs: docs-html docs-txt
62
78dfbfb9 » dvarrazzo
2010-11-13 Fixed dependencies to build the docs.
63 docs-html: doc/html/genindex.html
9ffcb900 » dvarrazzo
2010-11-13 Added flesh to the Makefile.
64
65 docs-txt: doc/psycopg2.txt
66
13c2f5a7 » dvarrazzo
2010-12-04 Added target to package the docs for PyPI documentation.
67 # for PyPI documentation
68 docs-zip: doc/docs.zip
69
9ffcb900 » dvarrazzo
2010-11-13 Added flesh to the Makefile.
70 sdist: $(SDIST)
71
72 # The environment is currently required to build the documentation.
73 # It is not clean by 'make clean'
74
75 env: easy_install
d07791cf » dvarrazzo
2010-11-13 Fixed setuptools installation from scratch.
76 mkdir -p $(ENV_BIN)
77 mkdir -p $(ENV_LIB)
9ffcb900 » dvarrazzo
2010-11-13 Added flesh to the Makefile.
78 $(EASY_INSTALL) docutils
79 $(EASY_INSTALL) sphinx
80
81 easy_install: ez_setup
d07791cf » dvarrazzo
2010-11-13 Fixed setuptools installation from scratch.
82 PYTHONPATH=$(ENV_LIB) $(PYTHON) $(EZ_SETUP) -d $(ENV_LIB) -s $(ENV_BIN) setuptools
9ffcb900 » dvarrazzo
2010-11-13 Added flesh to the Makefile.
83
d07791cf » dvarrazzo
2010-11-13 Fixed setuptools installation from scratch.
84 ez_setup:
85 mkdir -p $(ENV_BIN)
86 mkdir -p $(ENV_LIB)
87 wget -O $(EZ_SETUP) http://peak.telecommunity.com/dist/ez_setup.py
67afd678 » dvarrazzo
2007-11-11 Added 'make check' target, running all the available tests.
88
89 check:
5f80dd38 » fogzot
2010-12-01 Removed runtests target; checks is the default for Makefiles
90 PYTHONPATH=$(BUILD_DIR):.:$(PYTHONPATH) $(PYTHON) tests/__init__.py --verbose
9ffcb900 » dvarrazzo
2010-11-13 Added flesh to the Makefile.
91
92 testdb:
67afd678 » dvarrazzo
2007-11-11 Added 'make check' target, running all the available tests.
93 @echo "* Creating $(TESTDB)"
94 @if psql -l | grep -q " $(TESTDB) "; then \
95 dropdb $(TESTDB) >/dev/null; \
96 fi
97 createdb $(TESTDB)
6cb949d3 » dvarrazzo
2010-11-01 Try to install the hstore type in the test database.
98 # Note to packagers: this requires the postgres user running the test
99 # to be a superuser. You may change this line to use the superuser only
100 # to install the contrib. Feel free to suggest a better way to set up the
101 # testing environment (as the current is enough for development).
102 psql -f `pg_config --sharedir`/contrib/hstore.sql $(TESTDB)
9ffcb900 » dvarrazzo
2010-11-13 Added flesh to the Makefile.
103
104
105 $(PLATLIB): $(SOURCE_C)
0a285647 » dvarrazzo
2010-11-14 The Makefile can receive the pg_config location.
106 $(PYTHON) setup.py build_ext $(BUILD_EXT_OPT)
9ffcb900 » dvarrazzo
2010-11-13 Added flesh to the Makefile.
107
108 $(PACKAGE)/%.py: lib/%.py
afb87bb1 » dvarrazzo
2011-01-02 Fixed "building" of purelib files with make.
109 $(PYTHON) setup.py build_py $(BUILD_OPT)
110 touch $@
9ffcb900 » dvarrazzo
2010-11-13 Added flesh to the Makefile.
111
17f69ba7 » dvarrazzo
2011-01-02 Fixed Makefile dependencies of the test suite.
112 $(PACKAGE)/tests/%.py: tests/%.py
113 $(PYTHON) setup.py build_py $(BUILD_OPT)
114 touch $@
9ffcb900 » dvarrazzo
2010-11-13 Added flesh to the Makefile.
115
58079c6c » dvarrazzo
2010-11-15 Fixed dependencies of the sdist target
116 $(SDIST): docs MANIFEST $(SOURCE)
0a285647 » dvarrazzo
2010-11-14 The Makefile can receive the pg_config location.
117 $(PYTHON) setup.py sdist $(SDIST_OPT)
9ffcb900 » dvarrazzo
2010-11-13 Added flesh to the Makefile.
118
58079c6c » dvarrazzo
2010-11-15 Fixed dependencies of the sdist target
119 MANIFEST: MANIFEST.in $(SOURCE)
9ffcb900 » dvarrazzo
2010-11-13 Added flesh to the Makefile.
120 # Run twice as MANIFEST.in includes MANIFEST
121 $(PYTHON) setup.py sdist --manifest-only
122 $(PYTHON) setup.py sdist --manifest-only
123
124 # docs depend on the build as it partly use introspection.
78dfbfb9 » dvarrazzo
2010-11-13 Fixed dependencies to build the docs.
125 doc/html/genindex.html: $(PLATLIB) $(PURELIB) $(SOURCE_DOC)
d07791cf » dvarrazzo
2010-11-13 Fixed setuptools installation from scratch.
126 PYTHONPATH=$(ENV_LIB):$(BUILD_DIR) $(MAKE) SPHINXBUILD=$(ENV_BIN)/sphinx-build -C doc html
9ffcb900 » dvarrazzo
2010-11-13 Added flesh to the Makefile.
127
78dfbfb9 » dvarrazzo
2010-11-13 Fixed dependencies to build the docs.
128 doc/psycopg2.txt: $(PLATLIB) $(PURELIB) $(SOURCE_DOC)
d07791cf » dvarrazzo
2010-11-13 Fixed setuptools installation from scratch.
129 PYTHONPATH=$(ENV_LIB):$(BUILD_DIR) $(MAKE) SPHINXBUILD=$(ENV_BIN)/sphinx-build -C doc text
9ffcb900 » dvarrazzo
2010-11-13 Added flesh to the Makefile.
130
13c2f5a7 » dvarrazzo
2010-12-04 Added target to package the docs for PyPI documentation.
131 doc/docs.zip: doc/html/genindex.html
132 (cd doc/html && zip -r ../docs.zip *)
9ffcb900 » dvarrazzo
2010-11-13 Added flesh to the Makefile.
133
134 clean:
135 rm -rf build MANIFEST
136 $(MAKE) -C doc clean
Something went wrong with that request. Please try again.