summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOleg Pudeyev <oleg@bsdpower.com>2014-01-12 18:29:36 -0500
committerOleg Pudeyev <oleg@bsdpower.com>2014-01-12 21:58:53 -0500
commit53aedebddffb6e633d489965d2132047a70e17b1 (patch)
treeb9eb9553dca86cb5db278f551744f534554e2f98
parentacf513a52dad17ac0ad823497ac53bca8b73aa73 (diff)
downloadpycurl-53aedebddffb6e633d489965d2132047a70e17b1.tar.gz
Move unix to precede windows
-rw-r--r--setup.py174
1 files changed, 87 insertions, 87 deletions
diff --git a/setup.py b/setup.py
index d180f37..33f9127 100644
--- a/setup.py
+++ b/setup.py
@@ -77,93 +77,6 @@ def add_libdirs(envvar, sep, fatal=False):
fail("FATAL: bad directory %s in environment variable %s" % (dir, envvar))
-def configure_windows():
- # Windows users have to pass --curl-dir parameter to specify path
- # to libcurl, because there is no curl-config on windows at all.
- curl_dir = scan_argv("--curl-dir=")
- if curl_dir is None:
- fail("Please specify --curl-dir=/path/to/built/libcurl")
- if not os.path.exists(curl_dir):
- fail("Curl directory does not exist: %s" % curl_dir)
- if not os.path.isdir(curl_dir):
- fail("Curl directory is not a directory: %s" % curl_dir)
- print("Using curl directory: %s" % curl_dir)
- include_dirs.append(os.path.join(curl_dir, "include"))
-
- # libcurl windows documentation states that for linking against libcurl
- # dll, the import library name is libcurl_imp.lib.
- # in practice, the library name sometimes is libcurl.lib.
- # override with: --libcurl-lib-name=libcurl_imp.lib
- curl_lib_name = scan_argv('--libcurl-lib-name=', 'libcurl.lib')
-
- if scan_argv("--use-libcurl-dll") is not None:
- libcurl_lib_path = os.path.join(curl_dir, "lib", curl_lib_name)
- extra_link_args.extend(["ws2_32.lib"])
- if str.find(sys.version, "MSC") >= 0:
- # build a dll
- extra_compile_args.append("-MD")
- else:
- extra_compile_args.append("-DCURL_STATICLIB")
- libcurl_lib_path = os.path.join(curl_dir, "lib", curl_lib_name)
- extra_link_args.extend(["gdi32.lib", "wldap32.lib", "winmm.lib", "ws2_32.lib",])
-
- if not os.path.exists(libcurl_lib_path):
- fail("libcurl.lib does not exist at %s.\nCurl directory must point to compiled libcurl (bin/include/lib subdirectories): %s" %(libcurl_lib_path, curl_dir))
- extra_objects.append(libcurl_lib_path)
-
- # make pycurl binary work on windows xp.
- # we use inet_ntop which was added in vista and implement a fallback.
- # our implementation will not be compiled with _WIN32_WINNT targeting
- # vista or above, thus said binary won't work on xp.
- # http://curl.haxx.se/mail/curlpython-2013-12/0007.html
- extra_compile_args.append("-D_WIN32_WINNT=0x0501")
-
- if str.find(sys.version, "MSC") >= 0:
- extra_compile_args.append("-O2")
- extra_compile_args.append("-GF") # enable read-only string pooling
- extra_compile_args.append("-WX") # treat warnings as errors
- p = subprocess.Popen(['cl.exe'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
- out, err = p.communicate()
- match = re.search(r'Version (\d+)', err.decode().split("\n")[0])
- if match and int(match.group(1)) < 16:
- # option removed in vs 2010:
- # connect.microsoft.com/VisualStudio/feedback/details/475896/link-fatal-error-lnk1117-syntax-error-in-option-opt-nowin98/
- extra_link_args.append("/opt:nowin98") # use small section alignment
-
-def get_bdist_msi_version_hack():
- # workaround for distutils/msi version requirement per
- # epydoc.sourceforge.net/stdlib/distutils.version.StrictVersion-class.html -
- # only x.y.z version numbers are supported, whereas our versions might be x.y.z.p.
- # bugs.python.org/issue6040#msg133094
- from distutils.command.bdist_msi import bdist_msi
- import inspect
- import types
- import re
-
- class bdist_msi_version_hack(bdist_msi):
- """ MSI builder requires version to be in the x.x.x format """
- def run(self):
- def monkey_get_version(self):
- """ monkey patch replacement for metadata.get_version() that
- returns MSI compatible version string for bdist_msi
- """
- # get filename of the calling function
- if inspect.stack()[1][1].endswith('bdist_msi.py'):
- # strip revision from version (if any), e.g. 11.0.0-r31546
- match = re.match(r'(\d+\.\d+\.\d+)', self.version)
- assert match
- return match.group(1)
- else:
- return self.version
-
- # monkeypatching get_version() call for DistributionMetadata
- self.distribution.metadata.get_version = \
- types.MethodType(monkey_get_version, self.distribution.metadata)
- bdist_msi.run(self)
-
- return bdist_msi_version_hack
-
-
def configure_unix():
OPENSSL_DIR = scan_argv("--openssl-dir=")
if OPENSSL_DIR is not None:
@@ -289,6 +202,93 @@ def configure_unix():
extra_link_args.append("-flat_namespace")
+def configure_windows():
+ # Windows users have to pass --curl-dir parameter to specify path
+ # to libcurl, because there is no curl-config on windows at all.
+ curl_dir = scan_argv("--curl-dir=")
+ if curl_dir is None:
+ fail("Please specify --curl-dir=/path/to/built/libcurl")
+ if not os.path.exists(curl_dir):
+ fail("Curl directory does not exist: %s" % curl_dir)
+ if not os.path.isdir(curl_dir):
+ fail("Curl directory is not a directory: %s" % curl_dir)
+ print("Using curl directory: %s" % curl_dir)
+ include_dirs.append(os.path.join(curl_dir, "include"))
+
+ # libcurl windows documentation states that for linking against libcurl
+ # dll, the import library name is libcurl_imp.lib.
+ # in practice, the library name sometimes is libcurl.lib.
+ # override with: --libcurl-lib-name=libcurl_imp.lib
+ curl_lib_name = scan_argv('--libcurl-lib-name=', 'libcurl.lib')
+
+ if scan_argv("--use-libcurl-dll") is not None:
+ libcurl_lib_path = os.path.join(curl_dir, "lib", curl_lib_name)
+ extra_link_args.extend(["ws2_32.lib"])
+ if str.find(sys.version, "MSC") >= 0:
+ # build a dll
+ extra_compile_args.append("-MD")
+ else:
+ extra_compile_args.append("-DCURL_STATICLIB")
+ libcurl_lib_path = os.path.join(curl_dir, "lib", curl_lib_name)
+ extra_link_args.extend(["gdi32.lib", "wldap32.lib", "winmm.lib", "ws2_32.lib",])
+
+ if not os.path.exists(libcurl_lib_path):
+ fail("libcurl.lib does not exist at %s.\nCurl directory must point to compiled libcurl (bin/include/lib subdirectories): %s" %(libcurl_lib_path, curl_dir))
+ extra_objects.append(libcurl_lib_path)
+
+ # make pycurl binary work on windows xp.
+ # we use inet_ntop which was added in vista and implement a fallback.
+ # our implementation will not be compiled with _WIN32_WINNT targeting
+ # vista or above, thus said binary won't work on xp.
+ # http://curl.haxx.se/mail/curlpython-2013-12/0007.html
+ extra_compile_args.append("-D_WIN32_WINNT=0x0501")
+
+ if str.find(sys.version, "MSC") >= 0:
+ extra_compile_args.append("-O2")
+ extra_compile_args.append("-GF") # enable read-only string pooling
+ extra_compile_args.append("-WX") # treat warnings as errors
+ p = subprocess.Popen(['cl.exe'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+ out, err = p.communicate()
+ match = re.search(r'Version (\d+)', err.decode().split("\n")[0])
+ if match and int(match.group(1)) < 16:
+ # option removed in vs 2010:
+ # connect.microsoft.com/VisualStudio/feedback/details/475896/link-fatal-error-lnk1117-syntax-error-in-option-opt-nowin98/
+ extra_link_args.append("/opt:nowin98") # use small section alignment
+
+def get_bdist_msi_version_hack():
+ # workaround for distutils/msi version requirement per
+ # epydoc.sourceforge.net/stdlib/distutils.version.StrictVersion-class.html -
+ # only x.y.z version numbers are supported, whereas our versions might be x.y.z.p.
+ # bugs.python.org/issue6040#msg133094
+ from distutils.command.bdist_msi import bdist_msi
+ import inspect
+ import types
+ import re
+
+ class bdist_msi_version_hack(bdist_msi):
+ """ MSI builder requires version to be in the x.x.x format """
+ def run(self):
+ def monkey_get_version(self):
+ """ monkey patch replacement for metadata.get_version() that
+ returns MSI compatible version string for bdist_msi
+ """
+ # get filename of the calling function
+ if inspect.stack()[1][1].endswith('bdist_msi.py'):
+ # strip revision from version (if any), e.g. 11.0.0-r31546
+ match = re.match(r'(\d+\.\d+\.\d+)', self.version)
+ assert match
+ return match.group(1)
+ else:
+ return self.version
+
+ # monkeypatching get_version() call for DistributionMetadata
+ self.distribution.metadata.get_version = \
+ types.MethodType(monkey_get_version, self.distribution.metadata)
+ bdist_msi.run(self)
+
+ return bdist_msi_version_hack
+
+
def configure():
if sys.platform == "win32":
configure_windows()