Skip to content

Commit

Permalink
Don't use setuptools Feature PYTHON-639
Browse files Browse the repository at this point in the history
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
behackett committed Feb 16, 2014
1 parent 566473a commit 29db2e9
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 27 deletions.
20 changes: 16 additions & 4 deletions ez_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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
Expand All @@ -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':
Expand All @@ -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']
Expand All @@ -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']
Expand Down
41 changes: 18 additions & 23 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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:
Expand Down Expand Up @@ -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=[
Expand Down

0 comments on commit 29db2e9

Please sign in to comment.