Permalink
Browse files

Don't use setuptools Feature PYTHON-639

Feature has been removed from setuptools. This change
also updates ez_setup.py to install setuptools 1.4.2,
the final version that supports python 2.4 and 2.5.
  • Loading branch information...
1 parent 566473a commit 29db2e94d84971259b5dfb5dff55dd1b78e7b2f4 @behackett behackett committed Feb 16, 2014
Showing with 34 additions and 27 deletions.
  1. +16 −4 ez_setup.py
  2. +18 −23 setup.py
View
@@ -29,7 +29,7 @@
except ImportError:
USER_SITE = None
-DEFAULT_VERSION = "1.1.5"
+DEFAULT_VERSION = "1.4.2"
DEFAULT_URL = "https://pypi.python.org/packages/source/s/setuptools/"
def _python_cmd(*args):
@@ -151,6 +151,18 @@ def use_setuptools(version=DEFAULT_VERSION, download_base=DEFAULT_URL,
return _do_download(version, download_base, to_dir,
download_delay)
+def _clean_check(cmd, target):
+ """
+ Run the command to download target. If the command fails, clean up before
+ re-raising the error.
+ """
+ try:
+ subprocess.check_call(cmd)
+ except subprocess.CalledProcessError:
+ if os.access(target, os.F_OK):
+ os.unlink(target)
+ raise
+
def download_file_powershell(url, target):
"""
Download the file at url to target using Powershell (which will validate
@@ -162,7 +174,7 @@ def download_file_powershell(url, target):
'-Command',
"(new-object System.Net.WebClient).DownloadFile(%(url)r, %(target)r)" % vars(),
]
- subprocess.check_call(cmd)
+ _clean_check(cmd, target)
def has_powershell():
if platform.system() != 'Windows':
@@ -182,7 +194,7 @@ def has_powershell():
def download_file_curl(url, target):
cmd = ['curl', url, '--silent', '--output', target]
- subprocess.check_call(cmd)
+ _clean_check(cmd, target)
def has_curl():
cmd = ['curl', '--version']
@@ -200,7 +212,7 @@ def has_curl():
def download_file_wget(url, target):
cmd = ['wget', url, '--quiet', '--output-document', target]
- subprocess.check_call(cmd)
+ _clean_check(cmd, target)
def has_wget():
cmd = ['wget', '--version']
View
@@ -19,11 +19,11 @@
# Don't force people to install setuptools unless
# we have to.
try:
- from setuptools import setup, Feature
+ from setuptools import setup
except ImportError:
from ez_setup import use_setuptools
use_setuptools()
- from setuptools import setup, Feature
+ from setuptools import setup
from distutils.cmd import Command
from distutils.command.build_ext import build_ext
@@ -206,21 +206,21 @@ def build_extension(self, ext):
"to take advantage of the "
"extension."))
-c_ext = Feature(
- "optional C extensions",
- standard=True,
- ext_modules=[Extension('bson._cbson',
- include_dirs=['bson'],
- sources=['bson/_cbsonmodule.c',
- 'bson/time64.c',
- 'bson/buffer.c',
- 'bson/encoding_helpers.c']),
- Extension('pymongo._cmessage',
- include_dirs=['bson'],
- sources=['pymongo/_cmessagemodule.c',
- 'bson/buffer.c'])])
-
-features = {}
+ext_modules = [Extension('bson._cbson',
+ include_dirs=['bson'],
+ sources=['bson/_cbsonmodule.c',
+ 'bson/time64.c',
+ 'bson/buffer.c',
+ 'bson/encoding_helpers.c']),
+ Extension('pymongo._cmessage',
+ include_dirs=['bson'],
+ sources=['pymongo/_cmessagemodule.c',
+ 'bson/buffer.c'])]
+
+extra_opts = {
+ "packages": ["bson", "pymongo", "gridfs"],
+ "test_suite": "nose.collector"
+}
if "--no_ext" in sys.argv:
sys.argv.remove("--no_ext")
elif (sys.platform.startswith("java") or
@@ -241,12 +241,8 @@ def build_extension(self, ext):
*****************************************************\n
""")
else:
- features = {"c-ext": c_ext}
+ extra_opts['ext_modules'] = ext_modules
-extra_opts = {
- "packages": ["bson", "pymongo", "gridfs"],
- "test_suite": "nose.collector"
-}
if PY3:
extra_opts["use_2to3"] = True
if should_run_tests:
@@ -283,7 +279,6 @@ def build_extension(self, ext):
url="http://github.com/mongodb/mongo-python-driver",
keywords=["mongo", "mongodb", "pymongo", "gridfs", "bson"],
install_requires=[],
- features=features,
license="Apache License, Version 2.0",
tests_require=["nose"],
classifiers=[

0 comments on commit 29db2e9

Please sign in to comment.