Skip to content

Commit 9f473fe

Browse files
author
James William Pye
committed
Throw error if python <3.0 and conditionally compile extensions module.
1 parent 25a68d2 commit 9f473fe

1 file changed

Lines changed: 22 additions & 7 deletions

File tree

setup.py

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,13 @@
66
import sys
77
import os
88
from distutils.core import Extension
9+
10+
if sys.version_info[:2] < (3,0):
11+
sys.stderr.write(
12+
"ERROR: py-postgresql is for Python 3.0 and greater." + os.linesep
13+
)
14+
sys.exit(1)
15+
916
NAME = 'py-postgresql'
1017
VERSION = '0.8'
1118

@@ -50,6 +57,14 @@
5057
'Topic :: Database',
5158
]
5259

60+
extensions = [
61+
Extension(
62+
'postgresql.protocol.cbuffer',
63+
[os.path.join('postgresql', 'protocol', 'buffer.c')],
64+
libraries = (sys.platform == 'win32' and ['ws2_32'] or []),
65+
),
66+
]
67+
5368
defaults = {
5469
'name' : NAME,
5570
'version' : VERSION,
@@ -72,13 +87,13 @@
7287
'postgresql.resolved',
7388
],
7489

75-
'ext_modules' : [
76-
Extension(
77-
'postgresql.protocol.cbuffer',
78-
[os.path.join('postgresql', 'protocol', 'buffer.c')],
79-
libraries = (sys.platform == 'win32' and ['ws2_32'] or []),
80-
),
81-
],
90+
# Only build extension modules on win32 if PY_BUILD_EXTENSIONS is enabled.
91+
# People who get failures are more likely to just give up on the package
92+
# without reading the documentation. :(
93+
'ext_modules' : (
94+
extensions if sys.platform != 'win32' or os.environ.get('PY_BUILD_EXTENSIONS')
95+
else ()
96+
),
8297

8398
'scripts' : [
8499
'bin/pg_dotconf',

0 commit comments

Comments
 (0)