1
# setup.py - distutils packaging
3
# Copyright (C) 2003-2004 Federico Di Gregorio <fog@debian.org>
5
# This program is free software; you can redistribute it and/or modify
6
# it under the terms of the GNU General Public License as published by the
7
# Free Software Foundation; either version 2, or (at your option) any later
10
# This program is distributed in the hope that it will be useful, but
11
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTIBILITY
12
# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14
"""Python-PostgreSQL Database Adapter
16
psycopg is a PostgreSQL database adapter for the Python programming
17
language. This is version 2, a complete rewrite of the original code to
18
provide new-style classes for connection and cursor objects and other sweet
19
candies. Like the original, psycopg 2 was written with the aim of being
20
very small and fast, and stable as a rock.
22
psycopg is different from the other database adapter because it was
23
designed for heavily multi-threaded applications that create and destroy
24
lots of cursors and make a conspicuous number of concurrent INSERTs or
25
UPDATEs. psycopg 2 also provide full asycronous operations for the really
30
Development Status :: 4 - Beta
31
Intended Audience :: Developers
32
License :: OSI Approved :: GNU General Public License (GPL)
33
License :: OSI Approved :: Zope Public License
34
Programming Language :: Python
35
Programming Language :: C
36
Programming Language :: SQL
38
Topic :: Database :: Front-Ends
39
Topic :: Software Development
40
Topic :: Software Development :: Libraries :: Python Modules
41
Operating System :: Microsoft :: Windows
42
Operating System :: Unix
46
from distutils.core import setup, Extension
47
from distutils.sysconfig import get_python_inc
48
import distutils.ccompiler
50
PSYCOPG_VERSION = '1.99.10'
52
have_pydatetime = False
53
have_mxdatetime = False
56
# windows-only definitions (TODO: this should be moved to setup.cfg!)
57
POSTGRESQLDIR = "D:\\POSTGRESQL-7.4.2"
60
# to work around older distutil limitations
61
if sys.version < '2.2.3':
62
from distutils.dist import DistributionMetadata
63
DistributionMetadata.classifiers = None
64
DistributionMetadata.download_url = None
66
# let's start with macro definitions (the ones not already in setup.cfg)
70
define_macros.append(('PY_MAJOR_VERSION', str(sys.version_info[0])))
71
define_macros.append(('PY_MINOR_VERSION', str(sys.version_info[1])))
73
# some macros related to python versions and features
74
if sys.version_info[0] >= 2 and sys.version_info[1] >= 3:
75
define_macros.append(('HAVE_PYBOOL','1'))
76
if sys.version_info[0] >= 2 and sys.version_info[1] >= 4:
77
define_macros.append(('HAVE_DECIMAL','1'))
79
# gather information to build the extension module
80
ext = [] ; data_files = []
81
library_dirs = [] ; libraries = [] ; include_dirs = []
83
if sys.platform != 'win32':
84
define_macros.append(('PSYCOPG_VERSION', '"'+PSYCOPG_VERSION+'"'))
86
define_macros.append(('PSYCOPG_VERSION', '\\"'+PSYCOPG_VERSION+'\\"'))
88
POSTGRESQLDIR + "\\src\\interfaces\\libpq",
89
POSTGRESQLDIR + "\\src\\include" ]
90
library_dirs = [ POSTGRESQLDIR + "\\src\\interfaces\\libpq\\Release" ]
91
libraries = ["ws2_32"]
93
data_files.append((".\\lib\site-packages\\",
94
[POSTGRESQLDIR + "\\src\interfaces\\libpq\\Release\\libpq.dll"]))
95
libraries.append("libpqdll")
97
libraries.append("libpq")
98
libraries.append("advapi32")
100
# extra checks on darwin
101
if sys.platform == "darwin":
102
# fink installs lots of goodies in /sw/... - make sure we check there
103
include_dirs.append("/sw/include/postgresql")
104
library_dirs.append("/sw/lib")
109
'psycopgmodule.c', 'pqpath.c', 'typecast.c',
110
'microprotocols.c', 'microprotocols_proto.c',
111
'connection_type.c', 'connection_int.c', 'cursor_type.c', 'cursor_int.c',
112
'adapter_qstring.c', 'adapter_pboolean.c', 'adapter_binary.c']
114
# check for mx package
115
mxincludedir = os.path.join(get_python_inc(plat_specific=1), "mx")
116
if os.path.exists(mxincludedir):
117
include_dirs.append(mxincludedir)
118
define_macros.append(('HAVE_MXDATETIME','1'))
119
sources.append('adapter_mxdatetime.c')
120
have_mxdatetime = True
122
# check for python datetime package
123
if os.path.exists(os.path.join(get_python_inc(plat_specific=1),"datetime.h")):
124
define_macros.append(('HAVE_PYDATETIME','1'))
125
sources.append('adapter_datetime.c')
126
have_pydatetime = True
128
# now decide which package will be the default for date/time typecasts
129
if have_pydatetime and use_pydatetime \
130
or have_pydatetime and not have_mxdatetime:
131
define_macros.append(('PSYCOPG_DEFAULT_PYDATETIME','1'))
132
elif have_mxdatetime:
133
define_macros.append(('PSYCOPG_DEFAULT_MXDATETIME','1'))
135
sys.stderr.write("error: psycopg requires a datetime module:\n")
136
sys.stderr.write("error: mx.DateTime module not found\n")
137
sys.stderr.write("error: python datetime module not found\n")
140
# build the extension
142
sources = map(lambda x: os.path.join('psycopg', x), sources)
144
ext.append(Extension("psycopg._psycopg", sources,
145
include_dirs=include_dirs,
146
library_dirs=library_dirs,
147
define_macros=define_macros,
149
libraries=libraries))
151
setup(name="psycopg",
152
version=PSYCOPG_VERSION,
153
maintainer="Federico Di Gregorio",
154
maintainer_email="fog@initd.org",
155
author="Federico Di Gregorio",
156
author_email="fog@initd.org",
157
url="http://initd.org/software/initd/psycopg",
158
download_url = "http://initd.org/software/initd/psycopg",
159
license="GPL or ZPL",
161
description=__doc__.split("\n")[0],
162
long_description="\n".join(__doc__.split("\n")[2:]),
163
classifiers=filter(None, classifiers.split("\n")),
164
data_files=data_files,
165
package_dir={'psycopg':'lib'},
166
packages=['psycopg'],