FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Updated readme.html · pythonnet/pythonnet@de6f4cc · GitHub

Commit de6f4cc

Browse files
committed
Updated readme.html
Added code for Python 2.3 (not officially supported) Changed clr.preload to clr.setPreload() and clr.getPreload(). I know that setters and getters are old school but even Python doesn't support module properties :(
1 parent 1429b9f commit de6f4cc

9 files changed

Lines changed: 73 additions & 86 deletions

File tree

‎pythonnet/doc/changes.txt‎

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,7 @@ Python for .NET Changes
1919
- Fixed exception bugs for Python 2.5+. When compiled for Python 2.5+ all
2020
managed exceptions are based on Python's exceptions.Exception class.
2121
[tiran]
22-
23-
- Implemented a preload switch. Automatic preloading can be enabled by
24-
setting clr.preload to true. Preloading is automatically enabled for
25-
interactive Python shells and disabled in all other cases. [tiran]
26-
22+
2723
- Added deprecation warnings for importing from CLR.* and the CLR module.
2824
[tiran]
2925

@@ -34,8 +30,10 @@ Python for .NET Changes
3430
fixing a some ref counter bugs and creating a new makefile.mono.
3531
[tiran]
3632

37-
- Added a standard python extension to load the clr environment
38-
(src/monoclr). XXX DOES NOT WORK
33+
- Added a standard python extension to load the clr environment.
34+
The src/monoclr/ directory contains additional sample code like a
35+
Python binary linked against libpython2.x.so and some example code
36+
how to embed Mono and PythonNet in a C application.
3937
[tiran]
4038

4139
- Added yet another python prompt. This time it's a C application that
@@ -46,11 +44,17 @@ Python for .NET Changes
4644
The latter is required for module functions which invoke Python methods.
4745
[tiran]
4846

49-
- Added clr.AddReference("assembly name"), clr.FindAssembly("name") and
50-
clr.ListAssemblies(verbose). [tiran]
47+
- Added clr.setPreload(), clr.getPreload(), clr.AddReference("assembly name"),
48+
clr.FindAssembly("name") and clr.ListAssemblies(verbose). Automatic
49+
preloading can be enabled with clr.setPreload/True). Preloading is
50+
automatically enabled for interactive Python shells and disabled in all
51+
other cases. [tiran]
5152

5253
- New Makefile that works for Windows and Mono and autodetects the Python
53-
version and UCS 2/4 setting.
54+
version and UCS 2/4 setting. [tiran]
55+
56+
- Added code for Python 2.3. PythonNet can be build for Python 2.3 again
57+
but it is not fully supported. [tiran]
5458

5559
PythonNet 2.0 alpha 1
5660
---------------------------------------------------------------------------

‎pythonnet/doc/mono_config.txt‎

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,13 @@ configuration file /etc/mono/config
55
-->
66

77
<configuration>
8-
<dllmap dll="python24" target="libpython2.4.so.1" os="!windows" />
9-
<dllmap dll="python25" target="libpython2.5.so.1" os="!windows" />
10-
<dllmap dll="python26" target="libpython2.6.so.1" os="!windows" />
11-
<dllmap dll="python24.dll" target="libpython2.4.so.1" os="!windows" />
12-
<dllmap dll="python25.dll" target="libpython2.5.so.1" os="!windows" />
13-
<dllmap dll="python26.dll" target="libpython2.6.so.1" os="!windows" />
8+
<dllmap dll="python23" target="libpython2.3.so" os="!windows" />
9+
<dllmap dll="python24" target="libpython2.4.so" os="!windows" />
10+
<dllmap dll="python25" target="libpython2.5.so" os="!windows" />
11+
<dllmap dll="python26" target="libpython2.6.so" os="!windows" />
12+
<dllmap dll="python23.dll" target="libpython2.3.so" os="!windows" />
13+
<dllmap dll="python24.dll" target="libpython2.4.so" os="!windows" />
14+
<dllmap dll="python25.dll" target="libpython2.5.so" os="!windows" />
15+
<dllmap dll="python26.dll" target="libpython2.6.so" os="!windows" />
1416
</configuration>
1517

‎pythonnet/doc/readme.html‎

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -197,9 +197,11 @@ <h2>Installation</h2>
197197
<strong>Running on Linux/Mono:</strong> Preliminary testing shows that
198198
PythonNet runs under <a href="http://www.go-mono.com">Mono</a> without
199199
major issues, though the Mono runtime is not yet complete so there
200-
still may be problems. The Python for .NET integration layer is 100%
201-
managed code, so there should be no long-term issues under Mono - it
202-
should work better and better as the Mono platform matures.
200+
still may be problems. The only known issues with Mono are related to
201+
generic methods. Some edge cases aren't working properly and the bugs
202+
are already been worked on. However the Python for .NET integration layer
203+
is 100% managed code, so there should be no long-term issues under Mono
204+
- it should work better and better as the Mono platform matures.
203205
</p>
204206

205207
<p>
@@ -236,22 +238,24 @@ <h2>Installation</h2>
236238
when the interpreter is not build with --enable-shared (Debian, Ubuntu)
237239
or libpython2.?.so isn't available. You <strong>must</strong> use a
238240
Python binary that is linked dynamically against libpython2.?.so.
239-
<pre>ldd /usr/bin/python2.?</pre> has to list libpython2.?.so. When your
240-
Python interpreter isn't linked against libpython2.?.so but the shared
241-
lib
241+
<code>ldd /usr/bin/python2.?</code> has to list <code>libpython2.?.so</code>. When your
242+
Python interpreter isn't linked against libpython2.?.so you can't load
243+
the clr.so module. The src/monoclr/ directory contains a dynamically linked
244+
Python binary and a clrpython2.x which automatically loads Mono and PythonNet
245+
on startup.
242246
</p>
243247

244248
<pre>
245-
&lt;dllmap dll=&quote;python25&quote; target=&quote;libpython2.5.so&quote; os=&quote;!wi
246-
ndows&quote; /&gt;
249+
&lt;dllmap dll="python25" target="libpython2.5.so" os="!windows" /&gt;
247250
</pre>
248251

249252
<a name="monoclr_libpython"><a/>
250253
<p>
251254
PythonNet uses compiler symbols in order to build PythonNet for different
252255
versions and flavors of Python.
253256
<table>
254-
<th><td>symbol</td><td>explenetion</td></th>
257+
<tr><th>symbol</th><th>explenetion</th></tr>
258+
<tr><td>PYTHON23</td><td>build for Python 2.3</td></tr>
255259
<tr><td>PYTHON24</td><td>build for Python 2.4</td></tr>
256260
<tr><td>PYTHON25</td><td>build for Python 2.5</td></tr>
257261
<tr><td>PYTHON26</td><td>build for Python 2.6</td></tr>
@@ -348,9 +352,19 @@ <h2>Importing Modules</h2>
348352
Python for .NET uses the PYTHONPATH (sys.path) to look for assemblies
349353
to load, in addition to the usual application base and the GAC. To
350354
ensure that you can implicitly import an assembly, put the directory
351-
containing the assembly in <code>sys.path</code>.
355+
containing the assembly in <code>sys.path</code>. However the
356+
<code>Python.Runtime.dll</code> is not loaded from <code>sys.path</code>.
357+
It must either live in the GAC or somewhere else were it can be loaded.
352358
</p>
353359

360+
<p>
361+
The clr module contains some additional methods like <code>setPreload(bool)</code>,
362+
<code>getPreload()</code>, <code>ListAssemblies(verbosity)</code> and
363+
<code>FindAssembly(name)</code>. set/getPreload tune the preload flag. For performance
364+
reasons PythonNet only creates wrappers for classes that are imported. It nakes
365+
important a bit faster but makes introspection impossible. Interactive Python shells
366+
have a default of True.
367+
</p>
354368

355369
<a name="classes"></a>
356370

‎pythonnet/src/runtime/assemblyinfo.cs‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@
2626
[assembly: AssemblyFileVersionAttribute("2.0.0.2")]
2727
[assembly: NeutralResourcesLanguageAttribute("en")]
2828

29+
#if (PYTHON23)
30+
[assembly: AssemblyTitleAttribute("Python.Runtime for Python 2.3")]
31+
[assembly: AssemblyDescriptionAttribute("Python Runtime for Python 2.3")]
32+
#endif
2933
#if (PYTHON24)
3034
[assembly: AssemblyTitleAttribute("Python.Runtime for Python 2.4")]
3135
[assembly: AssemblyDescriptionAttribute("Python Runtime for Python 2.4")]

‎pythonnet/src/runtime/exceptions.cs‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,9 +214,10 @@ internal static void SetupExceptionHack() {
214214
" _class = None\n" +
215215
" _inner = None\n" +
216216
" \n" +
217-
" @property\n" +
217+
" #@property\n" +
218218
" def message(self):\n" +
219219
" return self.Message\n" +
220+
" message = property(message)\n" +
220221
" \n" +
221222
" def __init__(self, *args, **kw):\n" +
222223
" inst = self.__class__._class(*args, **kw)\n" +
@@ -264,7 +265,9 @@ internal static void SetupExceptionHack() {
264265
Runtime.PyDict_SetItemString(dict, "__doc__", Runtime.PyNone);
265266

266267
IntPtr flag = Runtime.Py_file_input;
267-
Runtime.PyRun_String(code, flag, dict, dict);
268+
IntPtr result = Runtime.PyRun_String(code, flag, dict, dict);
269+
Exceptions.ErrorCheck(result);
270+
Runtime.Decref(result);
268271

269272
os_exc = Runtime.PyDict_GetItemString(dict, "Exception");
270273
Runtime.PyObject_SetAttrString(os_exc, "_class", ns_exc);

‎pythonnet/src/runtime/importhook.cs‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,6 @@ public static IntPtr __import__(IntPtr self, IntPtr args, IntPtr kw) {
169169
ModuleObject head = (mod_name == realname) ? null : root;
170170
ModuleObject tail = root;
171171
root.InitializePreload();
172-
bool preload = root.preload;
173172

174173
for (int i = 0; i < names.Length; i++) {
175174
string name = names[i];
@@ -183,7 +182,7 @@ public static IntPtr __import__(IntPtr self, IntPtr args, IntPtr kw) {
183182
head = (ModuleObject)mt;
184183
}
185184
tail = (ModuleObject) mt;
186-
if (preload) {
185+
if (CLRModule.preload) {
187186
tail.LoadNames();
188187
}
189188
Runtime.PyDict_SetItemString(modules, tail.moduleName,
@@ -195,7 +194,7 @@ public static IntPtr __import__(IntPtr self, IntPtr args, IntPtr kw) {
195194

196195
if (fromlist && Runtime.PySequence_Size(fromList) == 1) {
197196
IntPtr fp = Runtime.PySequence_GetItem(fromList, 0);
198-
if ((!preload) && Runtime.GetManagedString(fp) == "*") {
197+
if ((!CLRModule.preload) && Runtime.GetManagedString(fp) == "*") {
199198
mod.LoadNames();
200199
}
201200
Runtime.Decref(fp);

‎pythonnet/src/runtime/moduleobject.cs‎

Lines changed: 8 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -305,32 +305,7 @@ internal class CLRModule : ModuleObject
305305
{
306306
protected static bool hacked = false;
307307
protected static bool interactive_preload = true;
308-
309-
public bool preload {
310-
get {
311-
IntPtr pybool = Runtime.PyDict_GetItemString(dict, "preload");
312-
if (pybool == IntPtr.Zero) {
313-
Exceptions.Clear();
314-
return false;
315-
}
316-
return (Runtime.PyObject_IsTrue(pybool) == 1);
317-
}
318-
set {
319-
IntPtr pybool;
320-
if (value) {
321-
pybool = Runtime.PyTrue;
322-
} else {
323-
pybool = Runtime.PyFalse;
324-
}
325-
IntPtr oldval = Runtime.PyDict_GetItemString(dict, "preload");
326-
if (oldval != IntPtr.Zero) {
327-
Runtime.Decref(oldval);
328-
}
329-
Runtime.Incref(pybool);
330-
Runtime.PyDict_SetItemString(dict, "preload", pybool);
331-
}
332-
333-
}
308+
internal static bool preload;
334309

335310
public CLRModule() : base("clr") {
336311
_namespace = String.Empty;
@@ -367,34 +342,15 @@ internal void InitializePreload() {
367342
}
368343
}
369344

370-
//====================================================================
371-
// Type __setattr__ implementation.
372-
//====================================================================
373-
public static new int tp_setattro(IntPtr ob, IntPtr key, IntPtr val)
374-
{
375-
string name = Runtime.GetManagedString(key);
376-
if (name != "preload") {
377-
return ExtensionType.tp_setattro(ob, key, val);
378-
} else {
379-
IntPtr dict = Runtime.PyModule_GetDict(ob);
380-
Exceptions.ErrorCheck(dict);
381-
382-
IntPtr oldval = Runtime.PyDict_GetItemString(dict, "preload");
383-
Runtime.Decref(oldval);
384-
385-
IntPtr newval;
386-
if ((val != IntPtr.Zero) && (Runtime.PyObject_IsTrue(val) == 1)) {
387-
newval = Runtime.PyTrue;
388-
} else {
389-
newval = Runtime.PyFalse;
390-
}
391-
Runtime.PyDict_SetItemString(dict, "preload", newval);
392-
return 0;
393-
}
345+
[ModuleFunctionAttribute()]
346+
public static bool getPreload() {
347+
return preload;
394348
}
395349

396-
public static int AddAssembly(string name) {
397-
return 1;
350+
[ModuleFunctionAttribute()]
351+
public static void setPreload(bool preloadFlag)
352+
{
353+
preload = preloadFlag;
398354
}
399355

400356
[ModuleFunctionAttribute()]

‎pythonnet/src/runtime/runtime.cs‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,11 @@ public class Runtime {
3636
#error You must define either UCS2 or UCS4!
3737
#endif
3838

39+
#if (PYTHON23)
40+
public const string dll = "python23";
41+
public const string pyversion = "2.3";
42+
public const int pyversionnumber = 23;
43+
#endif
3944
#if (PYTHON24)
4045
public const string dll = "python24";
4146
public const string pyversion = "2.4";
@@ -51,8 +56,8 @@ public class Runtime {
5156
public const string pyversion = "2.6";
5257
public const int pyversionnumber = 26;
5358
#endif
54-
#if ! (PYTHON24 || PYTHON25 || PYTHON26)
55-
#error You must define either PYTHON24, PYTHON25 or PYTHON26!
59+
#if ! (PYTHON23 || PYTHON24 || PYTHON25 || PYTHON26)
60+
#error You must define one of PYTHON23 to PYTHON26
5661
#endif
5762
internal static bool wrap_exceptions;
5863
internal static bool is32bit;

‎pythonnet/src/tests/runtests.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def main(verbosity=1):
5555

5656
for name in test_modules:
5757
module = __import__(name)
58-
suite.addTests(module.test_suite())
58+
suite.addTests((module.test_suite(),))
5959

6060
unittest.TextTestRunner(verbosity=verbosity).run(suite)
6161

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL