Skip to content

Moved speedups to a separate package. #77

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
706 changes: 0 additions & 706 deletions lib/sqlalchemy/cextension/processors.c

This file was deleted.

718 changes: 0 additions & 718 deletions lib/sqlalchemy/cextension/resultproxy.c

This file was deleted.

225 changes: 0 additions & 225 deletions lib/sqlalchemy/cextension/utils.c

This file was deleted.

4 changes: 2 additions & 2 deletions lib/sqlalchemy/engine/result.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
# We need a different reconstructor on the C extension so that we can
# add extra checks that fields have correctly been initialized by
# __setstate__.
from sqlalchemy.cresultproxy import safe_rowproxy_reconstructor
from sqlalchemy_speedups.cresultproxy import safe_rowproxy_reconstructor

# The extra function embedding is needed so that the
# reconstructor function has the same signature whether or not
Expand All @@ -34,7 +34,7 @@ def rowproxy_reconstructor(cls, state):
return obj

try:
from sqlalchemy.cresultproxy import BaseRowProxy
from sqlalchemy_speedups.cresultproxy import BaseRowProxy
except ImportError:
class BaseRowProxy(object):
__slots__ = ('_parent', '_row', '_processors', '_keymap')
Expand Down
2 changes: 1 addition & 1 deletion lib/sqlalchemy/engine/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,6 @@ def _distill_params(multiparams, params):

return locals()
try:
from sqlalchemy.cutils import _distill_params
from sqlalchemy_speedups.cutils import _distill_params
except ImportError:
globals().update(py_fallback())
2 changes: 1 addition & 1 deletion lib/sqlalchemy/processors.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ def int_to_boolean(value):
return locals()

try:
from sqlalchemy.cprocessors import UnicodeResultProcessor, \
from sqlalchemy_speedups.cprocessors import UnicodeResultProcessor, \
DecimalResultProcessor, \
to_float, to_str, int_to_boolean, \
str_to_datetime, str_to_time, \
Expand Down
91 changes: 7 additions & 84 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,12 @@
import os
import re
import sys
from distutils.command.build_ext import build_ext
from distutils.errors import (CCompilerError, DistutilsExecError,
DistutilsPlatformError)
try:
from setuptools import setup, Extension, Feature
from setuptools import setup
has_setuptools = True
except ImportError:
has_setuptools = False
from distutils.core import setup, Extension
Feature = None
from distutils.core import setup

cmdclass = {}
pypy = hasattr(sys, 'pypy_version_info')
Expand All @@ -28,48 +24,6 @@
elif sys.version_info >= (3, 0):
py3k = True

ext_modules = [
Extension('sqlalchemy.cprocessors',
sources=['lib/sqlalchemy/cextension/processors.c']),
Extension('sqlalchemy.cresultproxy',
sources=['lib/sqlalchemy/cextension/resultproxy.c']),
Extension('sqlalchemy.cutils',
sources=['lib/sqlalchemy/cextension/utils.c'])
]

ext_errors = (CCompilerError, DistutilsExecError, DistutilsPlatformError)
if sys.platform == 'win32':
# 2.6's distutils.msvc9compiler can raise an IOError when failing to
# find the compiler
ext_errors += (IOError,)

class BuildFailed(Exception):

def __init__(self):
self.cause = sys.exc_info()[1] # work around py 2/3 different syntax

class ve_build_ext(build_ext):
# This class allows C extension building to fail.

def run(self):
try:
build_ext.run(self)
except DistutilsPlatformError:
raise BuildFailed()

def build_extension(self, ext):
try:
build_ext.build_extension(self, ext)
except ext_errors:
raise BuildFailed()
except ValueError:
# this can happen on Windows 64 bit, see Python issue 7511
if "'path'" in str(sys.exc_info()[1]): # works with both py 2/3
raise BuildFailed()
raise

cmdclass['build_ext'] = ve_build_ext

def status_msgs(*msgs):
print('*' * 75)
for msg in msgs:
Expand Down Expand Up @@ -97,17 +51,8 @@ def find_packages(location):
r_file.close()


def run_setup(with_cext):
def run_setup():
kwargs = extra.copy()
if with_cext:
if Feature:
kwargs['features'] = {'cextensions': Feature(
"optional C speed-enhancements",
standard=True,
ext_modules=ext_modules
)}
else:
kwargs['ext_modules'] = ext_modules

setup(name="SQLAlchemy",
version=VERSION,
Expand All @@ -122,6 +67,9 @@ def run_setup(with_cext):
tests_require=['pytest >= 2.5.2', 'mock'],
test_suite="pytest.main",
long_description=readme,
extras_require=dict(
speedups=['sqlalchemy-speedups>=1.0,<2.0'],
),
classifiers=[
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Developers",
Expand All @@ -137,29 +85,4 @@ def run_setup(with_cext):
**kwargs
)

if pypy or jython:
run_setup(False)
status_msgs(
"WARNING: C extensions are not supported on " +
"this Python platform, speedups are not enabled.",
"Plain-Python build succeeded."
)
else:
try:
run_setup(True)
except BuildFailed as exc:
status_msgs(
exc.cause,
"WARNING: The C extension could not be compiled, " +
"speedups are not enabled.",
"Failure information, if any, is above.",
"Retrying the build without the C extension now."
)

run_setup(False)

status_msgs(
"WARNING: The C extension could not be compiled, " +
"speedups are not enabled.",
"Plain-Python build succeeded."
)
run_setup()
Loading