regina 7.3.1.1__cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of regina might be problematic. Click here for more details.

Files changed (163) hide show
  1. regina/__init__.py +203 -0
  2. regina/engine.cpython-312-aarch64-linux-gnu.so +0 -0
  3. regina/plainCompleter.py +221 -0
  4. regina/pyCensus/__init__.py +14 -0
  5. regina/pyCensus/christy-knots-links.tdb +0 -0
  6. regina/pyCensus/closed-hyp-census-full.tdb +0 -0
  7. regina/pyCensus/closed-nor-census-11.tdb +0 -0
  8. regina/pyCensus/closed-or-census-11.tdb +0 -0
  9. regina/pyCensus/cusped-hyp-nor-census-9.tdb +0 -0
  10. regina/pyCensus/cusped-hyp-or-census-9.tdb +0 -0
  11. regina/sageRegina/__init__.py +2 -0
  12. regina/sageRegina/config.py +9 -0
  13. regina/sageRegina/test.py +132 -0
  14. regina/sageRegina/testsuite/CMakeLists.txt +60 -0
  15. regina/sageRegina/testsuite/O2_1.rga +15 -0
  16. regina/sageRegina/testsuite/O2_1.tri +28 -0
  17. regina/sageRegina/testsuite/README.txt +20 -0
  18. regina/sageRegina/testsuite/alltypes.out +1551 -0
  19. regina/sageRegina/testsuite/alltypes.test +88 -0
  20. regina/sageRegina/testsuite/angles.out +102 -0
  21. regina/sageRegina/testsuite/angles.test +72 -0
  22. regina/sageRegina/testsuite/basic_callback.out +124 -0
  23. regina/sageRegina/testsuite/basic_sub.out +7 -0
  24. regina/sageRegina/testsuite/bool.out +6 -0
  25. regina/sageRegina/testsuite/bool.test +64 -0
  26. regina/sageRegina/testsuite/bytes.out +17 -0
  27. regina/sageRegina/testsuite/bytes.test +78 -0
  28. regina/sageRegina/testsuite/callbacks.out +515 -0
  29. regina/sageRegina/testsuite/callbacks.test +281 -0
  30. regina/sageRegina/testsuite/census.out +120 -0
  31. regina/sageRegina/testsuite/census.test +157 -0
  32. regina/sageRegina/testsuite/clone.out +18 -0
  33. regina/sageRegina/testsuite/clone.test +101 -0
  34. regina/sageRegina/testsuite/constructors.out +14 -0
  35. regina/sageRegina/testsuite/constructors.test +97 -0
  36. regina/sageRegina/testsuite/cube.orb +87 -0
  37. regina/sageRegina/testsuite/discs.out +3 -0
  38. regina/sageRegina/testsuite/discs.test +40 -0
  39. regina/sageRegina/testsuite/docstrings.filter +19 -0
  40. regina/sageRegina/testsuite/docstrings.out +808 -0
  41. regina/sageRegina/testsuite/docstrings.out.v2 +808 -0
  42. regina/sageRegina/testsuite/docstrings.test +57 -0
  43. regina/sageRegina/testsuite/dodec.orb +309 -0
  44. regina/sageRegina/testsuite/embeddings.out +23 -0
  45. regina/sageRegina/testsuite/embeddings.test +89 -0
  46. regina/sageRegina/testsuite/enumerate.out +62 -0
  47. regina/sageRegina/testsuite/enumerate.test +82 -0
  48. regina/sageRegina/testsuite/equality.out +112 -0
  49. regina/sageRegina/testsuite/equality.test +310 -0
  50. regina/sageRegina/testsuite/euler.out +15 -0
  51. regina/sageRegina/testsuite/euler.test +95 -0
  52. regina/sageRegina/testsuite/exception.out +7 -0
  53. regina/sageRegina/testsuite/exception.test +100 -0
  54. regina/sageRegina/testsuite/facenumbering.out +546 -0
  55. regina/sageRegina/testsuite/facenumbering.test +74 -0
  56. regina/sageRegina/testsuite/faces.out +40 -0
  57. regina/sageRegina/testsuite/faces.test +72 -0
  58. regina/sageRegina/testsuite/file.out +1229 -0
  59. regina/sageRegina/testsuite/file.test +70 -0
  60. regina/sageRegina/testsuite/file1.rga +0 -0
  61. regina/sageRegina/testsuite/file2.rga +0 -0
  62. regina/sageRegina/testsuite/file3.rga +119 -0
  63. regina/sageRegina/testsuite/flype.out +37 -0
  64. regina/sageRegina/testsuite/flype.test +50 -0
  65. regina/sageRegina/testsuite/generic.out +116 -0
  66. regina/sageRegina/testsuite/generic.test +76 -0
  67. regina/sageRegina/testsuite/groups.out +70 -0
  68. regina/sageRegina/testsuite/groups.test +117 -0
  69. regina/sageRegina/testsuite/hypersurfaces.out +681 -0
  70. regina/sageRegina/testsuite/hypersurfaces.test +90 -0
  71. regina/sageRegina/testsuite/i18n-latin1.rga +8 -0
  72. regina/sageRegina/testsuite/i18n-utf8.rga +8 -0
  73. regina/sageRegina/testsuite/i18n.out +6 -0
  74. regina/sageRegina/testsuite/i18n.test +91 -0
  75. regina/sageRegina/testsuite/id.out +2 -0
  76. regina/sageRegina/testsuite/id.test +47 -0
  77. regina/sageRegina/testsuite/index.out +2 -0
  78. regina/sageRegina/testsuite/index.test +43 -0
  79. regina/sageRegina/testsuite/integer.out +74 -0
  80. regina/sageRegina/testsuite/integer.test +56 -0
  81. regina/sageRegina/testsuite/italian.orb +90 -0
  82. regina/sageRegina/testsuite/iterators.out +118 -0
  83. regina/sageRegina/testsuite/iterators.test +128 -0
  84. regina/sageRegina/testsuite/knotted-Y.orb +47 -0
  85. regina/sageRegina/testsuite/listener.out +43 -0
  86. regina/sageRegina/testsuite/listener.test +101 -0
  87. regina/sageRegina/testsuite/listview.out +416 -0
  88. regina/sageRegina/testsuite/listview.test +253 -0
  89. regina/sageRegina/testsuite/lookup.out +13 -0
  90. regina/sageRegina/testsuite/lookup.test +44 -0
  91. regina/sageRegina/testsuite/memory1.out +62 -0
  92. regina/sageRegina/testsuite/memory1.test +154 -0
  93. regina/sageRegina/testsuite/memory2.out +62 -0
  94. regina/sageRegina/testsuite/memory2.test +124 -0
  95. regina/sageRegina/testsuite/memory3.out +92 -0
  96. regina/sageRegina/testsuite/memory3.test +216 -0
  97. regina/sageRegina/testsuite/misc.out +7 -0
  98. regina/sageRegina/testsuite/misc.test +56 -0
  99. regina/sageRegina/testsuite/operators.out +129 -0
  100. regina/sageRegina/testsuite/operators.test +61 -0
  101. regina/sageRegina/testsuite/orb.out +441 -0
  102. regina/sageRegina/testsuite/orb.test +49 -0
  103. regina/sageRegina/testsuite/pdf.out +4 -0
  104. regina/sageRegina/testsuite/pdf.test +49 -0
  105. regina/sageRegina/testsuite/perm.out +55 -0
  106. regina/sageRegina/testsuite/perm.test +96 -0
  107. regina/sageRegina/testsuite/plantri.out +12 -0
  108. regina/sageRegina/testsuite/plantri.test +60 -0
  109. regina/sageRegina/testsuite/presentations.out +11 -0
  110. regina/sageRegina/testsuite/presentations.test +61 -0
  111. regina/sageRegina/testsuite/refs.out +51 -0
  112. regina/sageRegina/testsuite/refs.test +128 -0
  113. regina/sageRegina/testsuite/repr.out +951 -0
  114. regina/sageRegina/testsuite/repr.out.v2 +951 -0
  115. regina/sageRegina/testsuite/repr.test +548 -0
  116. regina/sageRegina/testsuite/safeheldtype_basic.out +17 -0
  117. regina/sageRegina/testsuite/safeheldtype_basic.test +113 -0
  118. regina/sageRegina/testsuite/safeheldtype_packet.out +58 -0
  119. regina/sageRegina/testsuite/safeheldtype_packet.test +181 -0
  120. regina/sageRegina/testsuite/sample.pdf +0 -0
  121. regina/sageRegina/testsuite/sets.out +7 -0
  122. regina/sageRegina/testsuite/sets.test +44 -0
  123. regina/sageRegina/testsuite/skeleton.out +308 -0
  124. regina/sageRegina/testsuite/skeleton.test +54 -0
  125. regina/sageRegina/testsuite/snappea.out +82 -0
  126. regina/sageRegina/testsuite/snappea.test +107 -0
  127. regina/sageRegina/testsuite/snapshot.out +15 -0
  128. regina/sageRegina/testsuite/snapshot.test +78 -0
  129. regina/sageRegina/testsuite/sort.out +57 -0
  130. regina/sageRegina/testsuite/sort.test +53 -0
  131. regina/sageRegina/testsuite/special.out +4 -0
  132. regina/sageRegina/testsuite/special.test +47 -0
  133. regina/sageRegina/testsuite/standardtri.out +12101 -0
  134. regina/sageRegina/testsuite/standardtri.test +455 -0
  135. regina/sageRegina/testsuite/surfaces.out +2133 -0
  136. regina/sageRegina/testsuite/surfaces.test +114 -0
  137. regina/sageRegina/testsuite/swapping.out +25 -0
  138. regina/sageRegina/testsuite/swapping.test +88 -0
  139. regina/sageRegina/testsuite/testall.in +176 -0
  140. regina/sageRegina/testsuite/testbasic.in +279 -0
  141. regina/sageRegina/testsuite/testcallback.in +150 -0
  142. regina/sageRegina/testsuite/testsub.in +150 -0
  143. regina/sageRegina/testsuite/theta_in_solid_torus.orb +65 -0
  144. regina/sageRegina/testsuite/tightencode.out +40 -0
  145. regina/sageRegina/testsuite/tightencode.test +108 -0
  146. regina/sageRegina/testsuite/treedecomp.out +135 -0
  147. regina/sageRegina/testsuite/treedecomp.test +66 -0
  148. regina/sageRegina/testsuite/treetraversal.out +52 -0
  149. regina/sageRegina/testsuite/treetraversal.test +190 -0
  150. regina/sageRegina/testsuite/trigeneral.out +1251 -0
  151. regina/sageRegina/testsuite/trigeneral.test +155 -0
  152. regina/sageRegina/testsuite/utf8.out +42 -0
  153. regina/sageRegina/testsuite/utf8.test +94 -0
  154. regina/sageRegina/version.py +5 -0
  155. regina/sageSetup.py +41 -0
  156. regina/test.py +6 -0
  157. regina-7.3.1.1.dist-info/METADATA +109 -0
  158. regina-7.3.1.1.dist-info/RECORD +163 -0
  159. regina-7.3.1.1.dist-info/WHEEL +6 -0
  160. regina-7.3.1.1.dist-info/top_level.txt +4 -0
  161. regina.libs/libbz2-738ca772.so.1.0.6 +0 -0
  162. regina.libs/libgmp-6683d5d4.so.10.2.0 +0 -0
  163. regina.libs/libgmpxx-7c3a5907.so.4.4.0 +0 -0
regina/__init__.py ADDED
@@ -0,0 +1,203 @@
1
+ # Regina - A Normal Surface Theory Calculator
2
+ # Python Module Initialisation
3
+ #
4
+ # Copyright (c) 2003-2023, Ben Burton
5
+ # For further details contact Ben Burton (bab@debian.org).
6
+ #
7
+ # This program is free software; you can redistribute it and/or
8
+ # modify it under the terms of the GNU General Public License as
9
+ # published by the Free Software Foundation; either version 2 of the
10
+ # License, or (at your option) any later version.
11
+ #
12
+ # As an exception, when this program is distributed through (i) the
13
+ # App Store by Apple Inc.; (ii) the Mac App Store by Apple Inc.; or
14
+ # (iii) Google Play by Google Inc., then that store may impose any
15
+ # digital rights management, device limits and/or redistribution
16
+ # restrictions that are required by its terms of service.
17
+ #
18
+ # This program is distributed in the hope that it will be useful, but
19
+ # WITHOUT ANY WARRANTY; without even the implied warranty of
20
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21
+ # General Public License for more details.
22
+ #
23
+ # You should have received a copy of the GNU General Public
24
+ # License along with this program; if not, write to the Free
25
+ # Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
26
+ # MA 02110-1301, USA.
27
+ #
28
+
29
+ try:
30
+ # SageRegina has some weirdness where "import engine" gives
31
+ # an error if not preceeded by "import sage.all"
32
+ # Needs some investigation, doing this as work-around for now.
33
+ import sage.all
34
+ _within_sage = True
35
+ except:
36
+ _within_sage = False
37
+
38
+ import sys, os
39
+ from . import engine
40
+ from .engine import *
41
+
42
+ if _within_sage:
43
+ # Typing "from regina import *" should not override certain
44
+ # names. This always applies to the built-in "open".
45
+ #
46
+ # Also: the Sage preparser adds "Integer" and relies on the name
47
+ # being bound to a Sage integer. If we override it, Sage
48
+ # breaks in multiple ways.
49
+ #
50
+ # We skip names_to_avoid in __all__.
51
+ names_to_avoid = set(['open', 'Integer'])
52
+ __all__ = (
53
+ [ name for name in engine.__dict__.keys()
54
+ if not name in names_to_avoid and not name.startswith('_') ] +
55
+ [ 'reginaSetup' ])
56
+
57
+ # All additional sage-related setup should be placed within sageSetup.py.
58
+ from . import sageSetup
59
+ del sageSetup
60
+ else:
61
+ # Typing "from regina import *" is not supposed to override the
62
+ # built-in "open". To achieve this, we skip it in __all__.
63
+ __all__ = (
64
+ [ name for name in engine.__dict__.keys()
65
+ if name != 'open' and not name.startswith('_') ] +
66
+ [ 'reginaSetup' ])
67
+
68
+ # In sageRegina, the census files are supplied differently.
69
+ # Set the location here.
70
+ try:
71
+ from .pyCensus import __path__ as _pyCensusPath
72
+ GlobalDirs.setDirs(
73
+ GlobalDirs.home(),
74
+ GlobalDirs.pythonModule(),
75
+ _pyCensusPath[0])
76
+ except ImportError:
77
+ pass
78
+
79
+ def reginaSetup(quiet = False, readline = True, banner = False,
80
+ snappyPath = True, namespace = None, builtinOpen = True):
81
+ """
82
+ Initialise a Regina python session.
83
+
84
+ Arguments:
85
+ quiet : If true, suppress informative messages that would
86
+ otherwise be written to standard output. If an error
87
+ occurs, details of the error will be written regardless.
88
+ readline : If true, attempt to enable tab completion.
89
+ snappyPath : Applies to platforms where SnapPy might not be installed
90
+ on the python path (e.g., macOS users with the SnapPy app
91
+ bundle). If true, this setup routine will (i) attempt
92
+ to locate SnapPy, and (ii) if successful, extend sys.path
93
+ to include the location of SnapPy's python module and its
94
+ dependencies.
95
+ banner : If true, print a welcome banner to standard output.
96
+ namespace : The global namespace in which the start-up library scripts
97
+ (if any) will be executed. This may be None, in which
98
+ case the caller's global namespace will be used.
99
+ builtinOpen: If true, sets "open" in the given namespace to Python's
100
+ builtin open() function. This is used to work around the
101
+ problem whereby "from regina import *", overrides Python's
102
+ open() function with Regina's. You will still be able to
103
+ access Regina's open() function by calling regina.open().
104
+ If the namespace argument above is None, then this option
105
+ has no effect.
106
+ """
107
+
108
+ if readline:
109
+ # Enable tab completion through readline, if we can.
110
+ try:
111
+ import rlcompleter, readline
112
+ # readline by default completes an empty string, whereas if
113
+ # we press tab we want to insert an actual tab character,
114
+ # so we have our own completion function.
115
+
116
+ __internal_python_completer = readline.get_completer()
117
+ def regina_completer(text, state):
118
+ if not text:
119
+ return ('\t', None)[state]
120
+ else:
121
+ return __internal_python_completer(text, state)
122
+ readline.set_completer(regina_completer)
123
+
124
+ if 'libedit' in readline.__doc__:
125
+ # Some systems work with libedit, not libreadline, which
126
+ # supports a different set of commands.
127
+ readline.parse_and_bind('bind ^I rl_complete')
128
+ else:
129
+ readline.parse_and_bind('tab: complete')
130
+ except:
131
+ pass
132
+
133
+ if snappyPath:
134
+ # For the time being, only find SnapPy on macOS.
135
+ if sys.platform == 'darwin':
136
+ if sys.version_info[:2] == (3, 8):
137
+ # Ask macOS where SnapPy lives.
138
+ import subprocess
139
+ try:
140
+ app = subprocess.check_output(['mdfind',
141
+ 'kMDItemDisplayName==SnapPy&&kMDItemKind==Application'])
142
+ if app:
143
+ app = app.strip().split('\n')[0]
144
+ except:
145
+ app = None
146
+
147
+ if not app:
148
+ app = '/Applications/SnapPy.app'
149
+ snappyLib = app + '/Contents/Resources/lib/python3.8'
150
+ snappyZip = app + '/Contents/Resources/lib/python38.zip'
151
+ if os.path.exists(snappyLib):
152
+ sys.path.append(snappyLib)
153
+ sys.path.append(snappyLib + '/site-packages.zip')
154
+ sys.path.append(snappyLib + '/lib-dynload')
155
+ if os.path.exists(snappyZip):
156
+ sys.path.append(snappyZip)
157
+
158
+ if banner:
159
+ print(engine.welcome())
160
+
161
+ if builtinOpen and namespace:
162
+ namespace['open'] = __builtins__['open']
163
+
164
+ def __execScript(namespace = None):
165
+ """
166
+ For internal use by regina-python.
167
+ Executes a given python script.
168
+
169
+ The filename of the script should be in sys.argv[1], and
170
+ any arguments to the script should be in sys.argv[2:].
171
+ However, ipython sets things up a little differently (it includes two
172
+ additional arguments), and we attempt to compensate for this here.
173
+
174
+ SIDE-EFFECT: sys.argv will be truncated to include the script and
175
+ its arguments only (i.e., sys.argv[0] will be removed).
176
+
177
+ Arguments:
178
+ namespace : The global namespace in which the script will be executed.
179
+ This may be None, in which case the caller's global
180
+ namespace will be used.
181
+ """
182
+
183
+ try:
184
+ __IPYTHON__
185
+ # Although python sets sys.argv = [ '-c', script, arg, ... ],
186
+ # ipython sets sys.argv as the full original command line:
187
+ # [ ipython, '-c', command, script, arg, ... ], or
188
+ # [ ipython, '-i', '-c', command, script, arg, ... ].
189
+ # Repair things here.
190
+ if len(sys.argv) >= 3 and sys.argv[1] == '-c':
191
+ sys.argv = [ '-c' ] + sys.argv[3:]
192
+ elif len(sys.argv) >= 4 and sys.argv[1:3] == ['-i', '-c']:
193
+ sys.argv = [ '-c' ] + sys.argv[4:]
194
+ except:
195
+ pass
196
+
197
+ script = __builtins__['open'](sys.argv[1]).read()
198
+ sys.argv = sys.argv[1:]
199
+ if namespace:
200
+ exec(script, namespace)
201
+ else:
202
+ exec(script)
203
+
@@ -0,0 +1,221 @@
1
+ """A copy of Python's rlcompleter module that removes all interaction
2
+ with the readline module. This is a trivial modification of rlcompleter.py
3
+ from Python 3.9, which is licensed under the Python Software Foundation
4
+ License Version 2.
5
+
6
+ This plainCompleter module is designed for use in Regina's GUI, which uses
7
+ Python subinterpreters. The readline module does not play well with
8
+ subinterpreters (due to the way it interacts with the GIL), and in some
9
+ settings this results in a completely reproducible deadlock. Such settings
10
+ include openSUSE Leap 15.2, and macOS 11.0 using the Python3 that is shipped
11
+ with Xcode.
12
+
13
+ This plainCompleter module still offers a Completer class (which is all
14
+ that the GUI needs), but it does not offer full readline functionality
15
+ at the command line. Crucially, importing this module will never attempt
16
+ to import the readline module as a side-effect.
17
+
18
+ Python's own rlcompleter documentation continues from here.
19
+
20
+ The completer completes keywords, built-ins and globals in a selectable
21
+ namespace (which defaults to __main__); when completing NAME.NAME..., it
22
+ evaluates (!) the expression up to the last dot and completes its attributes.
23
+
24
+ It's very cool to do "import sys" type "sys.", hit the completion key (twice),
25
+ and see the list of names defined by the sys module!
26
+
27
+ Tip: to use the tab key as the completion key, call
28
+
29
+ readline.parse_and_bind("tab: complete")
30
+
31
+ Notes:
32
+
33
+ - Exceptions raised by the completer function are *ignored* (and generally cause
34
+ the completion to fail). This is a feature -- since readline sets the tty
35
+ device in raw (or cbreak) mode, printing a traceback wouldn't work well
36
+ without some complicated hoopla to save, reset and restore the tty state.
37
+
38
+ - The evaluation of the NAME.NAME... form may cause arbitrary application
39
+ defined code to be executed if an object with a __getattr__ hook is found.
40
+ Since it is the responsibility of the application (or the user) to enable this
41
+ feature, I consider this an acceptable risk. More complicated expressions
42
+ (e.g. function calls or indexing operations) are *not* evaluated.
43
+
44
+ - When the original stdin is not a tty device, GNU readline is never
45
+ used, and this module (and the readline module) are silently inactive.
46
+
47
+ """
48
+
49
+ import atexit
50
+ import __main__
51
+
52
+ # The original rlcompleter simply imports the builtins module.
53
+ # However, we need to maintain compatibility with python 2 also.
54
+ try:
55
+ import builtins
56
+ except:
57
+ import __builtin__ as builtins
58
+
59
+ __all__ = ["Completer"]
60
+
61
+ class Completer:
62
+ def __init__(self, namespace = None):
63
+ """Create a new completer for the command line.
64
+
65
+ Completer([namespace]) -> completer instance.
66
+
67
+ If unspecified, the default namespace where completions are performed
68
+ is __main__ (technically, __main__.__dict__). Namespaces should be
69
+ given as dictionaries.
70
+
71
+ Completer instances should be used as the completion mechanism of
72
+ readline via the set_completer() call:
73
+
74
+ readline.set_completer(Completer(my_namespace).complete)
75
+ """
76
+
77
+ if namespace and not isinstance(namespace, dict):
78
+ raise TypeError('namespace must be a dictionary')
79
+
80
+ # Don't bind to namespace quite yet, but flag whether the user wants a
81
+ # specific namespace or to use __main__.__dict__. This will allow us
82
+ # to bind to __main__.__dict__ at completion time, not now.
83
+ if namespace is None:
84
+ self.use_main_ns = 1
85
+ else:
86
+ self.use_main_ns = 0
87
+ self.namespace = namespace
88
+
89
+ def complete(self, text, state):
90
+ """Return the next possible completion for 'text'.
91
+
92
+ This is called successively with state == 0, 1, 2, ... until it
93
+ returns None. The completion should begin with 'text'.
94
+
95
+ """
96
+ if self.use_main_ns:
97
+ self.namespace = __main__.__dict__
98
+
99
+ if not text.strip():
100
+ if state == 0:
101
+ if _readline_available:
102
+ readline.insert_text('\t')
103
+ readline.redisplay()
104
+ return ''
105
+ else:
106
+ return '\t'
107
+ else:
108
+ return None
109
+
110
+ if state == 0:
111
+ if "." in text:
112
+ self.matches = self.attr_matches(text)
113
+ else:
114
+ self.matches = self.global_matches(text)
115
+ try:
116
+ return self.matches[state]
117
+ except IndexError:
118
+ return None
119
+
120
+ def _callable_postfix(self, val, word):
121
+ if callable(val):
122
+ word = word + "("
123
+ return word
124
+
125
+ def global_matches(self, text):
126
+ """Compute matches when text is a simple name.
127
+
128
+ Return a list of all keywords, built-in functions and names currently
129
+ defined in self.namespace that match.
130
+
131
+ """
132
+ import keyword
133
+ matches = []
134
+ seen = {"__builtins__"}
135
+ n = len(text)
136
+ for word in keyword.kwlist:
137
+ if word[:n] == text:
138
+ seen.add(word)
139
+ if word in {'finally', 'try'}:
140
+ word = word + ':'
141
+ elif word not in {'False', 'None', 'True',
142
+ 'break', 'continue', 'pass',
143
+ 'else'}:
144
+ word = word + ' '
145
+ matches.append(word)
146
+ for nspace in [self.namespace, builtins.__dict__]:
147
+ for word, val in nspace.items():
148
+ if word[:n] == text and word not in seen:
149
+ seen.add(word)
150
+ matches.append(self._callable_postfix(val, word))
151
+ return matches
152
+
153
+ def attr_matches(self, text):
154
+ """Compute matches when text contains a dot.
155
+
156
+ Assuming the text is of the form NAME.NAME....[NAME], and is
157
+ evaluable in self.namespace, it will be evaluated and its attributes
158
+ (as revealed by dir()) are used as possible completions. (For class
159
+ instances, class members are also considered.)
160
+
161
+ WARNING: this can still invoke arbitrary C code, if an object
162
+ with a __getattr__ hook is evaluated.
163
+
164
+ """
165
+ import re
166
+ m = re.match(r"(\w+(\.\w+)*)\.(\w*)", text)
167
+ if not m:
168
+ return []
169
+ expr, attr = m.group(1, 3)
170
+ try:
171
+ thisobject = eval(expr, self.namespace)
172
+ except Exception:
173
+ return []
174
+
175
+ # get the content of the object, except __builtins__
176
+ words = set(dir(thisobject))
177
+ words.discard("__builtins__")
178
+
179
+ if hasattr(thisobject, '__class__'):
180
+ words.add('__class__')
181
+ words.update(get_class_members(thisobject.__class__))
182
+ matches = []
183
+ n = len(attr)
184
+ if attr == '':
185
+ noprefix = '_'
186
+ elif attr == '_':
187
+ noprefix = '__'
188
+ else:
189
+ noprefix = None
190
+ while True:
191
+ for word in words:
192
+ if (word[:n] == attr and
193
+ not (noprefix and word[:n+1] == noprefix)):
194
+ match = "%s.%s" % (expr, word)
195
+ try:
196
+ val = getattr(thisobject, word)
197
+ except Exception:
198
+ pass # Include even if attribute not set
199
+ else:
200
+ match = self._callable_postfix(val, match)
201
+ matches.append(match)
202
+ if matches or not noprefix:
203
+ break
204
+ if noprefix == '_':
205
+ noprefix = '__'
206
+ else:
207
+ noprefix = None
208
+ matches.sort()
209
+ return matches
210
+
211
+ def get_class_members(klass):
212
+ ret = dir(klass)
213
+ if hasattr(klass,'__bases__'):
214
+ for base in klass.__bases__:
215
+ ret = ret + get_class_members(base)
216
+ return ret
217
+
218
+ # Regina's edits are here.
219
+ # Instead of trying to import the readline module, we just ignore it
220
+ # and treat this module as a standalone completion tool.
221
+ _readline_available = False
@@ -0,0 +1,14 @@
1
+ """
2
+ Dummy module to obtain path for census files from python.
3
+
4
+ The TokyoCabinet database files .tdb are for versin version 1.0:910 and in
5
+ little endian encoding suitable. Note that sageRegina is compiling its own
6
+ version of TokyoCabinet so the files we supply should work on all operating
7
+ systems and little endian platforms.
8
+
9
+ The .tdb files will be incompatible with the TokyoCabinet version shipped
10
+ with Debian/Ubuntu because of a stupid bug: on these systems, TokyoCabinet
11
+ is always using non-native (!) endianess (since --enable-swap was
12
+ accidentally supplied to configure).
13
+
14
+ """
Binary file
Binary file
Binary file
@@ -0,0 +1,2 @@
1
+ from .version import *
2
+ from .test import *
@@ -0,0 +1,9 @@
1
+ tokyocabinet_uri = 'https://dbmx.net/tokyocabinet/tokyocabinet-1.4.48.tar.gz'
2
+ tokyocabinet_dir = 'tokyocabinet-1.4.48'
3
+
4
+ libxml_uri = 'http://xmlsoft.org/sources/libxml2-2.9.3.tar.gz'
5
+ libxml_dir = 'libxml2-2.9.3'
6
+
7
+ regina_hash = '979c943023' # 7.3.1
8
+ regina_uri = 'https://github.com/regina-normal/regina.git'
9
+ regina_dir = 'regina_%s' % regina_hash
@@ -0,0 +1,132 @@
1
+ from __future__ import print_function
2
+
3
+ #__all__ = ['runTests']
4
+
5
+ from .. import __dict__ as reginaDict
6
+ from . version import version
7
+
8
+ import sys
9
+ import os
10
+ import re
11
+ import glob
12
+ import difflib
13
+ import traceback
14
+ from io import StringIO
15
+
16
+ base_path = os.path.split(__file__)[0]
17
+ testsuite_path = os.path.join(base_path, 'testsuite')
18
+
19
+ def runSource(source):
20
+
21
+ original_stdout = sys.stdout
22
+ original_displayhook = sys.displayhook
23
+ original_argv = sys.argv
24
+
25
+ fakeout = StringIO()
26
+
27
+ sys.stdout = fakeout
28
+ sys.displayhook = sys.__displayhook__
29
+ sys.argv = ['regina', testsuite_path]
30
+
31
+ try:
32
+ globs = reginaDict.copy()
33
+
34
+ class ReginaWrapper:
35
+ pass
36
+ reginaWrapper = ReginaWrapper()
37
+ reginaWrapper.__dict__ = reginaDict.copy()
38
+ globs['regina'] = reginaWrapper
39
+
40
+ exception_info = None
41
+ try:
42
+ exec(source, globs)
43
+ except:
44
+ exception_info = sys.exc_info()
45
+
46
+ finally:
47
+ sys.stdout = original_stdout
48
+ sys.displayhook = original_displayhook
49
+ sys.argv = original_argv
50
+
51
+ return fakeout.getvalue(), exception_info
52
+
53
+ def runFile(path):
54
+ return runSource(open(path).read())
55
+
56
+ def findTests():
57
+ search_path = os.path.join(testsuite_path, '*.test')
58
+ return [
59
+ (os.path.splitext(os.path.basename(path))[0], path)
60
+ for path in glob.glob(search_path)]
61
+
62
+ def runTest(testName, testFile):
63
+ failed = ""
64
+
65
+ output, exception_info = runFile(testFile)
66
+
67
+ baseline = open(testFile.replace('.test', '.out')).read()
68
+
69
+ if testName == 'misc':
70
+ # Last line is about open function which displays
71
+ # differently on different sytems, e.g., something like
72
+ # <boost.python.function at 0x34534345345>
73
+ output = '\n'.join( output.split('\n')[:-2])
74
+ baseline = '\n'.join(baseline.split('\n')[:-2])
75
+
76
+ if testName == 'docstrings':
77
+ output = re.subn(r'(\s*)__pybind11_module_local_([a-zA-Z0-9_-]+) = <capsule.*\.\.\.',
78
+ r'\1__pybind11_module_local__ = ...', output)[0]
79
+ output = re.subn(r'(\s*)Methods( inherited from pybind11_object:)',
80
+ r'\1Static methods\2', output)[0]
81
+ output = re.subn(r'__new__\(\*args, \*\*kwargs\) class method of pybind11_builtins.pybind11_object',
82
+ r'__new__(*args, **kwargs) from pybind11_builtins.pybind11_type',
83
+ output)[0]
84
+
85
+ # For Python 3.12, there are trailing whitespace issues, so we
86
+ # normalize.
87
+ baseline = [line.strip() for line in baseline.split('\n')]
88
+ output = [line.strip() for line in output.split('\n')]
89
+ if output != baseline:
90
+ failed += "Difference between baseline and output:\n"
91
+ failed += '\n'.join(
92
+ difflib.context_diff(
93
+ baseline,
94
+ output,
95
+ fromfile = os.path.basename(testFile),
96
+ tofile = 'OUTPUT'))
97
+
98
+ if exception_info:
99
+ exception_type, exception, traceback_object = (
100
+ exception_info)
101
+ failed += "Raised exception: %s\n" % exception_type
102
+ failed += "Exception detail: %s\n" % exception
103
+ failed += "Trace:\n %s\n" % traceback.format_tb(traceback_object)
104
+
105
+ return failed
106
+
107
+ def runTests():
108
+ print("Testing Regina " + version)
109
+ failedTests = []
110
+
111
+ for testName, testFile in findTests():
112
+ print("Running test %s:" % (testName + (20 - len(testName)) * " "),
113
+ end = ' ')
114
+ sys.stdout.flush()
115
+
116
+ failureOutput = runTest(testName, testFile)
117
+
118
+ if failureOutput:
119
+ failedTests.append(testName)
120
+ print("FAILED!!!")
121
+ print(failureOutput)
122
+ else:
123
+ print("ok")
124
+
125
+ if failedTests:
126
+ print("The following %d test(s) failed: %s" % (
127
+ len(failedTests), ', '.join(failedTests)))
128
+ else:
129
+ print("All tests passed for Regina " + version)
130
+
131
+ return not failedTests
132
+
@@ -0,0 +1,60 @@
1
+
2
+ CONFIGURE_FILE(
3
+ testall.in
4
+ "${PROJECT_BINARY_DIR}/python/testsuite/testall"
5
+ @ONLY
6
+ )
7
+ CONFIGURE_FILE(
8
+ testbasic.in
9
+ "${PROJECT_BINARY_DIR}/python/testsuite/testbasic"
10
+ @ONLY
11
+ )
12
+ CONFIGURE_FILE(
13
+ testsub.in
14
+ "${PROJECT_BINARY_DIR}/python/testsuite/testsub"
15
+ @ONLY
16
+ )
17
+ CONFIGURE_FILE(
18
+ testcallback.in
19
+ "${PROJECT_BINARY_DIR}/python/testsuite/testcallback"
20
+ @ONLY
21
+ )
22
+
23
+ # A very basic interpreter (and related code) to use for testing:
24
+ INCLUDE_DIRECTORIES(${Python_INCLUDE_DIRS} ${ENGINE_INCLUDES} "${PROJECT_BINARY_DIR}/engine")
25
+ ADD_COMPILE_DEFINITIONS(REGINA_PYTHON_USE_PYTHONPATH=1)
26
+ ADD_LINK_OPTIONS(${Python_LINK_OPTIONS})
27
+ add_executable(basic
28
+ basic.cpp
29
+ ../gui/pythoninterpreter.cpp
30
+ ../gui/pythonoutputstream.cpp)
31
+ target_link_libraries(basic ${ENGINE_LIBRARY} ${Python_LIBRARIES})
32
+ add_executable(basic_alltypes
33
+ basic_alltypes.cpp
34
+ ../gui/pythoninterpreter.cpp
35
+ ../gui/pythonoutputstream.cpp)
36
+ target_link_libraries(basic_alltypes ${ENGINE_LIBRARY} ${Python_LIBRARIES})
37
+ add_executable(basic_sub
38
+ basic_sub.cpp
39
+ ../gui/pythoninterpreter.cpp
40
+ ../gui/pythonoutputstream.cpp)
41
+ target_link_libraries(basic_sub ${ENGINE_LIBRARY} ${Python_LIBRARIES})
42
+ add_executable(basic_callback
43
+ basic_callback.cpp
44
+ ../gui/pythoninterpreter.cpp
45
+ ../gui/pythonoutputstream.cpp)
46
+ target_link_libraries(basic_callback ${ENGINE_LIBRARY} ${Python_LIBRARIES})
47
+
48
+ IF (WIN32)
49
+ ADD_TEST(python-test bash testall)
50
+ ADD_TEST(python-basic bash testbasic)
51
+ ADD_TEST(python-sub bash testsub)
52
+ ADD_TEST(python-callback bash testcallback)
53
+ # We do not need to add the engine DLL location to the path, since
54
+ # regina-python (used in testall) and testbasic (directly) do this for us.
55
+ ELSE (WIN32)
56
+ ADD_TEST(python-test ./testall)
57
+ ADD_TEST(python-basic ./testbasic)
58
+ ADD_TEST(python-sub ./testsub)
59
+ ADD_TEST(python-callback ./testcallback)
60
+ ENDIF (WIN32)
@@ -0,0 +1,15 @@
1
+ <?xml version="1.0"?>
2
+ <reginadata engine="4.5">
3
+ <packet label="Container"
4
+ type="Container" typeid="1"
5
+ parent="">
6
+ <packet label="O2₁"
7
+ type="Triangulation" typeid="3"
8
+ parent="Container">
9
+ <tetrahedra ntet="2">
10
+ <tet desc=""> 1 180 1 30 1 39 1 114 </tet>
11
+ <tet desc=""> 0 180 0 141 0 39 0 75 </tet>
12
+ </tetrahedra>
13
+ </packet> <!-- O2₁ (Triangulation) -->
14
+ </packet> <!-- Container (Container) -->
15
+ </reginadata>