summaryrefslogtreecommitdiff
path: root/setup.py
diff options
context:
space:
mode:
authorAlastair Houghton <alastair@alastairs-place.net>2012-01-30 12:26:44 +0000
committerAlastair Houghton <alastair@alastairs-place.net>2012-01-30 12:26:44 +0000
commit451fb9574813c771fcba696cf4d130d2a92c080d (patch)
tree1a4f30afe69911d61740a11cdc75cc3adfb9de58 /setup.py
parente10f3627c391d48bde65fe803164b4ddb299e933 (diff)
downloadnetifaces-git-451fb9574813c771fcba696cf4d130d2a92c080d.tar.gz
Improved setup script so it will build successfully in more cases. Added a version constant to the module. Fixed odd error behaviour for interfaces with no addresses on Linux.
Diffstat (limited to 'setup.py')
-rw-r--r--setup.py24
1 files changed, 14 insertions, 10 deletions
diff --git a/setup.py b/setup.py
index a9335e4..9973d0b 100644
--- a/setup.py
+++ b/setup.py
@@ -7,8 +7,13 @@ from setuptools.command.build_ext import build_ext
from distutils.errors import *
import pickle
-# Disable hard links, otherwise building distributions fails
-del os.link
+__version__ = "0.7"
+
+# Disable hard links, otherwise building distributions fails on OS X
+try:
+ del os.link
+except:
+ pass
# On Windows, we need ws2_32 and iphlpapi
if getattr(sys, 'getwindowsversion', None):
@@ -21,6 +26,8 @@ else:
libraries = ['socket', 'nsl']
def_macros = []
+def_macros.append(("NETIFACES_VERSION", __version__))
+
iface_mod = Extension('netifaces', sources=['netifaces.c'],
libraries=libraries,
define_macros=def_macros)
@@ -33,7 +40,7 @@ class my_build_ext(build_ext):
self.check_requirements()
build_ext.build_extensions(self)
- def test_build(self, contents, link=True, execute=True, libraries=None,
+ def test_build(self, contents, link=True, execute=False, libraries=None,
include_dirs=None, library_dirs=None):
name = os.path.join(self.build_temp, 'conftest-%s.c' % self.conftestidx)
self.conftestidx += 1
@@ -43,9 +50,6 @@ class my_build_ext(build_ext):
print >>thefile, contents
thefile.close()
- tmpext = Extension('_dummy', [], libraries = libraries)
- libraries = self.get_libraries(tmpext)
-
sys.stdout.flush()
sys.stderr.flush()
mystdout = os.dup(1)
@@ -275,7 +279,7 @@ class my_build_ext(build_ext):
int main (void) { return 0; }
""" % header
- if self.test_build(testrig, link=False, execute=False):
+ if self.test_build(testrig, link=False):
result.append(header)
if result:
@@ -309,7 +313,7 @@ class my_build_ext(build_ext):
}
"""
- result = self.test_build(testrig, execute=False)
+ result = self.test_build(testrig)
if result:
print 'yes. %s' % cached
@@ -356,7 +360,7 @@ class my_build_ext(build_ext):
in optional_headers]),
'sockaddr': sockaddr }
- if self.test_build(testrig, execute=False):
+ if self.test_build(testrig):
result.append(sockaddr)
if result:
@@ -381,7 +385,7 @@ if not getattr(sys, 'getwindowsversion', None):
setuptools.command.build_ext.build_ext = my_build_ext
setup (name='netifaces',
- version='0.6',
+ version=__version__,
description="Portable network interface information.",
license="MIT License",
long_description="""\