Skip to content

Commit

Permalink
Trac #13013: Trac #13013: Minor fixes for Python 2.7.3
Browse files Browse the repository at this point in the history
  • Loading branch information
Volker Braun committed May 26, 2012
1 parent 4c7acb8 commit ee7874a
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 23 deletions.
12 changes: 10 additions & 2 deletions src/doc/en/thematic_tutorials/tutorial-objects-and-classes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -296,15 +296,23 @@ Some particular actions modify the data structure of ``el``::
sage: type(e)
<type 'sage.rings.integer.Integer'>
sage: e.__dict__
<dictproxy object at 0x...>
dict_proxy({'__module__': 'sage.categories.euclidean_domains',
'_reduction': (<built-in function getattr>, (Category of
euclidean domains, 'element_class')), '__doc__': None,
'_sage_src_lines_': <staticmethod object at 0x...>})
sage: e.__dict__.keys()
['__module__', '_reduction', '__doc__', '_sage_src_lines_']

sage: id4 = SymmetricGroup(4).one()
sage: type(id4)
<type 'sage.groups.perm_gps.permgroup_element.PermutationGroupElement'>
sage: id4.__dict__
<dictproxy object at 0x...>
dict_proxy({'__module__': 'sage.categories.category',
'_reduction': (<built-in function getattr>, (Join of Category
of finite permutation groups and Category of finite weyl
groups, 'element_class')), '__doc__': '\n Put methods for
elements here.\n ', '_sage_src_lines_': <staticmethod object
at 0x...>})

.. note::

Expand Down
6 changes: 3 additions & 3 deletions src/sage/misc/prandom.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,11 +209,11 @@ def expovariate(lambd):
EXAMPLES:
sage: [expovariate(0.001) for i in range(3)]
[2194.27528710212, 664.856145830767, 3108.01255906546]
[118.152309288166, 722.261959038118, 45.7190543690470]
sage: [expovariate(1.0) for i in range(3)]
[1.10114367058632, 0.652772818610748, 1.69983589896220]
[0.404201816061304, 0.735220464997051, 0.201765578600627]
sage: [expovariate(1000) for i in range(3)]
[0.0003554358393809391, 0.0025254102812587195, 0.0001175899408167489]
[0.0012068700332283973, 8.340929747302108e-05, 0.00219877067980605]
"""
return _pyrand().expovariate(lambd)

Expand Down
35 changes: 17 additions & 18 deletions src/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,17 +67,7 @@
'%s/sage/sage/ext'%SAGE_DEVEL]

# search for dependencies only
extra_include_dirs = ['%s/include/python%s'%(SAGE_LOCAL,platform.python_version().rsplit('.', 1)[0]),
# finally, standard C/C++ include dirs
'/usr/local/include/',
'/usr/include']

try:
from subprocess import Popen, PIPE
gccinclude = Popen(['gcc', '--print-file-name=include'], stdout=PIPE).communicate()[0]
extra_include_dirs.extend( gccinclude.splitlines() )
except OSError:
pass
extra_include_dirs = [ '%s/include/python%s'%(SAGE_LOCAL,platform.python_version().rsplit('.', 1)[0]) ]

extra_compile_args = [ ]
extra_link_args = [ ]
Expand All @@ -102,7 +92,6 @@
### Testing related stuff
#########################################################


class CompileRecorder(object):

def __init__(self, f):
Expand Down Expand Up @@ -160,14 +149,14 @@ def __call__(self, *args):
if os.path.exists(sage.misc.lazy_import_cache.get_cache_file()):
os.unlink(sage.misc.lazy_import_cache.get_cache_file())


######################################################################
# CODE for generating C/C++ code from Cython and doing dependency
# checking, etc. In theory distutils would run Cython, but I don't
# trust it at all, and it won't have the more sophisticated dependency
# checking that we need.
######################################################################


# Do not put all, but only the most common libraries and their headers
# (that are likely to change on an upgrade) here:
# [At least at the moment. Make sure the headers aren't copied with "-p",
Expand Down Expand Up @@ -276,8 +265,9 @@ def execute_list_of_commands(command_list):
# normalize the command_list to handle strings correctly
command_list = [ [run_command, x] if isinstance(x, str) else x for x in command_list ]

# No need for more threads than there are commands
# No need for more threads than there are commands, but at least one
nthreads = min(len(command_list), nthreads)
nthreads = max(1, nthreads)

def plural(n,noun):
if n == 1:
Expand Down Expand Up @@ -307,7 +297,6 @@ def plural(n,noun):
##
########################################################################


from distutils.command.build_ext import build_ext
from distutils.dep_util import newer_group
from types import ListType, TupleType
Expand Down Expand Up @@ -526,6 +515,14 @@ def build_extension(self, p):
import re
dep_regex = re.compile(r'^ *(?:(?:cimport +([\w\. ,]+))|(?:from +([\w.]+) +cimport)|(?:include *[\'"]([^\'"]+)[\'"])|(?:cdef *extern *from *[\'"]([^\'"]+)[\'"]))', re.M)

# system headers should have pointy brackets, as in
# cdef extern from "<math.h>":
# but we didn't add them consistently. Workaround:
system_header_files = \
['complex.h', 'signal.h', 'math.h', 'limits.h', 'stdlib.h',
'arpa/inet.h', 'float.h', 'string.h', 'stdint.h', 'stdio.h',
'dlfcn.h', 'setjmp.h' ]

class DependencyTree:
"""
This class stores all the information about the dependencies of a set of
Expand Down Expand Up @@ -615,7 +612,7 @@ def parse_deps(self, filename, ext_module, verify=True):
raw_deps.append((path, base_dependency_name))
else: # include or extern from
extern_file = groups[2] or groups[3]
path = '%s/%s'%(dirname, extern_file)
path = os.path.join(dirname, extern_file)
if not os.path.exists(path):
path = extern_file
raw_deps.append((path, extern_file))
Expand All @@ -628,9 +625,11 @@ def parse_deps(self, filename, ext_module, verify=True):
# we didn't find the file locally, so check the
# Cython include path.
else:
found_include = False
found_include = path.startswith('<') and path.endswith('>')
if path in system_header_files:
found_include = True
for idir in ext_module.include_dirs + CYTHON_INCLUDE_DIRS + include_dirs + extra_include_dirs:
new_path = os.path.normpath(idir + '/' + base_dependency_name)
new_path = os.path.normpath(os.path.join(idir, base_dependency_name))
if os.path.exists(new_path):
deps.add(new_path)
found_include = True
Expand Down

0 comments on commit ee7874a

Please sign in to comment.