diff --git a/.travis.yml b/.travis.yml index 190a89447..3cb826c98 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,7 +2,7 @@ sudo: required language: python python: - 2.7 - - 3.2 + - 3.3 - 3.4 - 3.5 - 3.6 diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 000000000..a9a0ab58f --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,446 @@ +# Changelog + +All notable changes to Python for .NET will be documented in this file. +This project adheres to [Semantic Versioning][]. + +This document follows the conventions laid out in [Keep a CHANGELOG][]. + +## [Unreleased][] + +### Added + +- Python 3.6 support. +- Added `__version__` to module. + +## [2.2.0-dev1][] - 2016-09-19 + +- Switch to C# 6.0 (#219) +- Relative imports (#219) +- Recursive types (#250) +- Demo fix - stream reading (#225) +- setup.py improvements for locating build tools (#208) +- unmanaged exports updated (#206) +- Mono update pinned to 4.2.4.4 (#233) + +## [2.1.0][] - 2016-04-12 + +### Added + +- Added Python 3.x support. + +### Removed + +- Implicit Type Casting. + +## [2.0.0][] - 2015-06-26 + + Release + +## 2.0.0-alpha.2 + +### Changed + +- First work on Python 2.5 compatibility. The destination version can be + set by defining PYTHON24 or PYTHON25. Python 2.6 compatibility is in + work. + +- Added VS 2005 solution and project files including a UnitTest + configuration which runs the unit test suite. + +- Enhanced unit test suite. All test cases are combined in a single + test suite now. + +- Fixed bugs in generics support for all Python versions. + +- Fixed exception bugs for Python 2.5+. When compiled for Python 2.5+ all + managed exceptions are based on Python's `exceptions.Exception` class. + +- Added deprecation warnings for importing from `CLR.*` and the CLR module. + +- Implemented support for methods with variable arguments + `spam(params object[] egg)` + +- Fixed Mono support by adding a custom marshaler for UCS-4 unicode, + fixing a some ref counter bugs and creating a new makefile.mono. + +- Added a standard python extension to load the clr environment. + The `src/monoclr/` directory contains additional sample code like a + Python binary linked against `libpython2.x.so` and some example code + how to embed Mono and PythonNet in a C application. + +- Added yet another python prompt. This time it's a C application that + embedds both Python and Mono. It may be useful as an example app for + others and I need it to debug a nasty bug. + +- Implemented `ModuleFunctionAttribute` and added + `ForbidPythonThreadsAttribute`. The latter is required for module + functions which invoke Python methods. + +- Added `clr.setPreload()`, `clr.getPreload()`, + `clr.AddReference("assembly name")`, `clr.FindAssembly("name")` + and `clr.ListAssemblies(verbose)`. Automatic preloading can be enabled + with clr.setPreload/True). Preloading is automatically enabled for + interactive Python shells and disabled in all other cases. + +- New Makefile that works for Windows and Mono and autodetects the Python + version and UCS 2/4 setting. + +- Added code for Python 2.3. PythonNet can be build for Python 2.3 again + but it is not fully supported. + +- Changed the PythonException.Message value so it displays the name of + the exception class `Exception` instead of its representation + ``. + +- Added `Python.Runtime.dll.config`. + +## 2.0.0-alpha.1 + +### Changed + +- Moved the Python for .NET project to Sourceforge and moved version + control to Subversion. + +- Removed `CallConvCdecl` attributes and the IL hack that they supported. + .NET 2.x now supports `UnmanagedFunctionPointer`, which does the right + thing without the hackery required in 1.x. This removes a dependency + on ILASM to build the package and better supports Mono (in theory). + +- Refactored import and assembly management machinery. The old `CLR.` + syntax for import is deprecated, but still supported until 3.x. The + recommended style now is to use `from System import xxx`, etc. We + also now support `from X import *` correctly. + +- Implemented a (lowercase) `clr` module to match IronPython for code + compatibility. Methods of this module should be used to explicitly + load assemblies. Implicit (name-based) assembly loading will still + work until 3.x, but it is deprecated. + +- Implemented support for generic types and generic methods using the + same patterns and syntax as IronPython. See the documentation for + usage details. + +- Many small and large performance improvements, switched to generic + collections for some internals, better algorithms for assembly + scanning, etc. + +- Fixed an unboxing issue in generated delegate implementation code + that affected delegates that return value types. + +## [1.0.0][] - 2006-04-08 + +### Changed + +- Backported the refactored import and assembly management from the 2.x + line, mainly to improve the possibility of code-compatibility with + IronPython. + +## 1.0.0-rc.2 + +### Changed + +- Changed some uses of Finalize as a static method name that confused the + Mono compiler and people reading the code. Note that this may be a + breaking change if anyone was calling `PythonEngine.Finalize()`. If so, + you should now use `PythonEngine.Shutdown()`. + +- Tweaked assembly lookup to ensure that assemblies can be found in the + current working directory, even after changing directories using things + like `os.chdir()` from Python. + +- Fixed some incorrect finalizers (thanks to Greg Chapman for the report) + that may have caused some threading oddities. + +- Tweaked support for out and ref parameters. If a method has a return + type of void and a single ref or out parameter, that parameter will be + returned as the result of the method. This matches the current behavior + of IronPython and makes it more likely that code can be moved between + Python for .NET and IP in the future. + +- Refactored part of the assembly manager to remove a potential case of + thread-deadlock in multi-threaded applications. + +- Added a `__str__` method to managed exceptions that returns the Message + attribute of the exception and the StackTrace (if available). + +## 1.0.0-rc.1 + +### Changed + +- Implemented a workaround for the fact that exceptions cannot be new-style + classes in the CPython interpreter. Managed exceptions can now be raised + and caught naturally from Python (hooray!) + +- Implemented support for invoking methods with out and ref parameters. + Because there is no real equivalent to these in Python, methods that + have out or ref parameters will return a tuple. The tuple will contain + the result of the method as its first item, followed by out parameter + values in the order of their declaration in the method signature. + +- Fixed a refcount problem that caused a crash when CLR was imported in + an existing installed Python interpreter. + +- Added an automatic conversion from Python strings to `byte[]`. This makes + it easier to pass `byte[]` data to managed methods (or set properties, + etc.) as a Python string without having to write explicit conversion + code. Also works for sbyte arrays. Note that `byte` and `sbyte` arrays + returned from managed methods or obtained from properties or fields + do _not_ get converted to Python strings - they remain instances of + `Byte[]` or `SByte[]`. + +- Added conversion of generic Python sequences to object arrays when + appropriate (thanks to Mackenzie Straight for the patch). + +- Added a bit of cautionary documentation for embedders, focused on + correct handling of the Python global interpreter lock from managed + code for code that calls into Python. + +- `PyObject.FromManagedObject` now correctly returns the Python None object + if the input is a null reference. Also added a new `AsManagedObject` + method to `PyObject`, making it easier to convert a Python-wrapped managed + object to the real managed object. + +- Created a simple installer for windows platforms. + +## 1.0.0-beta.5 + +### Changed + +- Refactored and fixed threading and global interpreter lock handling, + which was badly broken before. Also added a number of threading and + GIL-handling tests. + +- Related to the GIL fixes, added a note to embedders in the README + about using the AcquireLock and ReleaseLock methods of the PythonEngine + class to manage the GIL. + +- Fixed a problem in `Single <--> float` conversion for cultures that use + different decimal symbols than Python. + +- Added a new `ReloadModule` method to the `PythonEngine` class that hooks + Python module reloading (`PyImport_ReloadModule`). + +- Added a new `StringAsModule` method to the PythonEngine class that can + create a module from a managed string of code. + +- Added a default `__str__` implementation for Python wrappers of managed + objects that calls the `ToString` method of the managed object. + +## 1.0.0-beta.4 + +### Changed + +- Fixed a problem that made it impossible to override "special" methods + like `__getitem__` in subclasses of managed classes. Now the tests all + pass, and there is much rejoicing. + +- Managed classes reflected to Python now have an `__doc__` attribute that + contains a listing of the class constructor signatures. + +- Fixed a problem that prevented passing null (None) for array arguments. + +- Added a number of new argument conversion tests. Thanks to Laurent + Caumont for giving Python for .NET a good workout with managed DirectX. + +- Updated the bundled C Python runtime and libraries to Python 2.4. The + current release is known to also run with Python 2.3. It is known + _not_ to work with older versions due to changes in CPython type + object structure. + +- Mostly fixed the differences in the way that import works depending + on whether you are using the bundled interpreter or an existing Python + interpreter. The hack I used makes import work uniformly for imports + done in Python modules. Unfortunately, there is still a limitation + when using the interpreter interactively: you need to do `import CLR` + first before importing any sub-names when running with an existing + Python interpreter. + + The reason is that the first import of `CLR` installs the CLR import + hook, but for an existing interpreter the standard importer is still + in control for the duration of that first import, so sub-names won't + be found until the next import, which will use the now-installed hook. + +- Added support to directly iterate over objects that support IEnumerator + (as well as IEnumerable). Thanks to Greg Chapman for prodding me ;) + +- Added a section to the README dealing with rebuilding Python for .NET + against other CPython versions. + +- Fixed a problem with accessing properties when only the interface for + an object is known. For example, `ICollection(ob).Count` failed because + Python for .NET mistakenly decided that Count was abstract. + +- Fixed some problems with how COM-based objects are exposed and how + members of inherited interfaces are exposed. Thanks to Bruce Dodson + for patches on this. + +- Changed the Runtime class to use a const string to target the + appropriate CPython dll in DllImport attributes. Now you only + have to change one line to target a new Python version. + +## 1.0.0-beta.3 + +### Changed + +- A dumb bug that could cause a crash on startup on some platforms was + fixed. Decided to update the beta for this, as a number of people + were running into the problem. + +## 1.0.0-beta.2 + +### Changed + +- Exceptions raised as a result of getting or setting properties were + not very helpful (target invokation exception). This has been changed + to pass through the inner exception the way that methods do, which is + much more likely to be the real exception that caused the problem. + +- Events were refactored as the implementation was based on some bad + assumptions. As a result, subscription and unsubscription now works + correctly. A change from beta 1 is that event objects are no longer + directly callable - this was not appropriate, since the internal + implementation of an event is private and cant work reliably. Instead, + you should the appropriate `OnSomeEvent` method published by a class + to fire an event. + +- The distribution did not include the key file, making it a pain for + people to build from source. Added the key file to the distribution + buildout for beta 2. + +- Assemblies can now be found and loaded if they are on the PYTHONPATH. + Previously only the appbase and the GAC were checked. The system now + checks PYTHONPATH first, then the appbase, then the GAC. + +- Fixed a bug in constructor invokation during object instantiation. + +## 1.0.0-beta.1 + +### Changed + +- Added the baseline of the managed embedding API. Some of the details + are still subject to change based on some real-world use and feedback. + + The embedding API is based on the `PyObject` class, along with a number + of specific `PyDict`, `PyList`, (etc.) classes that expose the respective + interfaces of the built-in Python types. The basic structure and usage + is intended be familar to anyone who has used Python / C++ wrapper + libraries like CXX or Boost. + +- Started integrating NUnit2 to support unit tests for the embedding + layer - still need to add the embedding tests (many already exist, + but were written for an older version of NUnit). + +- Added Python iteration protocol support for arrays and managed objects + that implement IEnumerable. This means that you can now use the Python + idiom `for item in object:` on any array or IEnumerable object. + +- Added automatic conversion from Python sequence types to managed array + types. This means, for example, that you can now call a managed method + like AddRange that expects an array with any Python object that supports + the Python sequence protocol, provided the items of the sequence are + convertible to the item type of the managed array. + +- Added new demo scripts, mostly more substantial winforms examples. + +- Finished the unit tests for event support, and fixed lots of problems + with events and delegates as a result. This is one of the trickier + parts of the integration layer, and there is good coverage of these + in the unit tests now. + +- Did a fair amount of profiling with an eval version of ANTS (which is + quite nice, BTW) and made a few changes as a result. + +- Type management was refactored, fixing the issue that caused segfaults + when GC was enabled. Unit tests, stress tests and demo apps now all run + nicely with Python GC enabled. There are one or two things left to fix, + but the fixes should not have any user impact. + +- Changed to base PythonNet on Python 2.3.2. This is considered the most + stable release, and a good 25 - 30% faster as well. + +- Added a new `CLR.dll` that acts as an extension module that allows an + existing unmodified Python 2.3 installation to simply `import CLR` to + bootstrap the managed integration layer. + +- A bug was causing managed methods to only expose overloads declared in + a particular class, hiding inherited overloads of the same name. Fixed + the bug and added some unit tests. + +- Added a virtual `__doc__` attribute to managed methods that contains + the signature of the method. This also means that the Python `help` + function now provides signature info when used on a managed class. + +- Calling managed methods and events `unbound` (passing the instance as + the first argument) now works. There is a caveat for methods - if a + class declares both static and instance methods with the same name, + it is not possible to call that instance method unbound (the static + method will always be called). + +- Overload selection for overloaded methods is now much better and uses + a method resolution algorithm similar to that used by Jython. + +- Changed the managed python.exe wrapper to run as an STA thread, which + seems to be more compatible with winforms apps. This needs a better + solution long-term. One possibility would be a command line switch + so that -sta or -mta could control the python.exe apartment state. + +- Added support for the Python boolean type (True, False). Bool values + now appear as True or False to Python. + +## 1.0.0-alpha.2 + +### Changed + +- Added a Mono makefile. Thanks to Camilo Uribe for help in testing and + working out problems on Mono. Note that it not currently possible to + build PythonNet using mono, due to the use of some IL attributes that + the mono assembler / disassembler doesn't support yet. + +- Preliminary tests show that PythonNet _does_ actually run under mono, + though the test suite bombs out before the end with an "out of memory" + error from the mono runtime. It's just a guess at this point, but I + suspect there may be a limited pool for allocating certain reflection + structures, and Python uses the reflection infrastructure quite heavily. + +- Removed decoys like the non-working embedding APIs; lots of internal + refactoring. + +- Implemented indexer support. Managed instances that implement indexers + can now be used naturally from Python (e.g. `someobject[0]`). + +- Implemented sequence protocol support for managed arrays. + +- Implemented basic thread state management; calls to managed methods + no longer block Python. I won't go so far as to say the thread + choreography is "finished", as I don't have a comprehensive set of + tests to back that up yet (and it will take some work to write a + sufficiently large and evil set of tests). + +- Fixed a bug that caused conversions of managed strings to PyUnicode to + produce mangled values in certain situations. + +- Fixed a number of problems related to subclassing a managed class, + including the fact that it didn't work :) + +- Fixed all of the bugs that were causing tests to fail. This release + contains all new bugs and new failing tests. Progress! :) + +## 1.0.0-alpha.1 + +### Added + +- Initial (mostly) working experimental release. + +[keep a changelog]: http://keepachangelog.com/ + +[semantic versioning]: http://semver.org/ + +[unreleased]: ../../compare/v2.2.0-dev1...HEAD + +[2.2.0-dev1]: ../../compare/v2.1.0...v2.2.0-dev1 + +[2.1.0]: ../../compare/v2.0.0...v2.1.0 + +[2.0.0]: ../../compare/1.0...v2.0.0 + +[1.0.0]: https://github.com/pythonnet/pythonnet/releases/tag/1.0 diff --git a/VS_README.txt b/VS_README.txt deleted file mode 100644 index d66cbc379..000000000 --- a/VS_README.txt +++ /dev/null @@ -1,43 +0,0 @@ -Visual Studio 2005 -================== - -pythonnet contains a new solution file for Visual Studio 2005: pythonnet.sln -It should make development under Windows much easier since you don't have to -install MSys or Cygwin to run the makefile. - -The solution file should work with the free VS .NET Express Edition. - -Available configurations ------------------------- - -Every configuration copies the dll, pdf and exe files to the root directory -of the project. - - * Release - Builds Python.Runtime, Python.Tests, clr.pyd and python.exe. The console - project starts a Python console - - * Debug - Same as Release but creates a build with debug symbols - - * UnitTest - Builds a Debug build. The console project invokes runtests.py instead of - opening a Python shell. - - * EmbeddingTest - Builds Python.EmbeddingTests and its dependencies. The configuration - requires the NUunit framework. - -Python version --------------- - -You can switch the destination version by defining either PYTHON24 or PYTHON25 -inside the Python.Runtime project. - - ** Don't forget to force a rebuild after you have altered the setting! ** - -MS VS doesn't take changes to define into account. - -Thanks to Virgil Duprasfor his original VS howto! - -Christian 'Tiran' Heimes diff --git a/doc/Python.Runtime.dll.config b/doc/Python.Runtime.dll.config deleted file mode 100644 index 3cfe2735a..000000000 --- a/doc/Python.Runtime.dll.config +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - - - - - - - - diff --git a/doc/TODO.txt b/doc/TODO.txt deleted file mode 100644 index b13cf1024..000000000 --- a/doc/TODO.txt +++ /dev/null @@ -1,34 +0,0 @@ -TODO list -========= - -For PythonNet 2.0 ------------------ - - * Implement support for ModulePropertyAttribute. - - * Replace CLRModule.preload code with ModulePropertyAttribute specific code. - - * Deprecate implicit loading of assemblies - - * Debug failing unit tests under Mono and report them if they are caused - by incompatibilities in Mono. - -Future and nice-to-have features --------------------------------- - - * Add support for Python's debug builds. Debug builds have additional fields - in the struct, extensive self testing and C assert() are enabled. Py_DEBUG - implies Py_TRACE_REFS and Py_REF_DEBUG which enlarge the PyObject and - PyVarObject based structs. The Py_INCREF and Py_DECREF macros have a larger - payload as well. They keep track of the absolute number of references and - do tests when an object is GCed. - I've taken care of most of the incompatibilities but the Py_DEBUG build - is still broken. Somehow tp_mro of wrapper_descriptor isn't a tuple. - - * Support Python 2.6. The most important feature I was able to isolate is the - PyType_FastSubclass macro and related TypeFlags in interops.cs. - - * Let's talk to the Debian and Ubuntu maintainers for Python in order to convince - them to build Python with --enable-shared. Ubuntu's Python is semi static and not - linked against libpython2.x.so. This causes trouble with clr.so. - diff --git a/doc/changes.txt b/doc/changes.txt deleted file mode 100644 index 7e577d96c..000000000 --- a/doc/changes.txt +++ /dev/null @@ -1,400 +0,0 @@ -Python for .NET Changes ------------------------ - - PythonNet 2.0 alpha 2 - --------------------------------------------------------------------------- - - - First work on Python 2.5 compatibility. The destination version can be - set by defining PYTHON24 or PYTHON25. Python 2.6 compatibility is in - work. [tiran] - - - Added VS 2005 solution and project files including a UnitTest - configuration which runs the unit test suite. [tiran] - - - Enhanced unit test suite. All test cases are combined in a single - test suite now. [tiran] - - - Fixed bugs in generics support for all Python versions. [tiran] - - - Fixed exception bugs for Python 2.5+. When compiled for Python 2.5+ all - managed exceptions are based on Python's exceptions.Exception class. - [tiran] - - - Added deprecation warnings for importing from CLR.* and the CLR module. - [tiran] - - - Implemented support for methods with variable arguments - spam(params object[] egg) [tiran] - - - Fixed Mono support by adding a custom marshaler for UCS-4 unicode, - fixing a some ref counter bugs and creating a new makefile.mono. - [tiran] - - - Added a standard python extension to load the clr environment. - The src/monoclr/ directory contains additional sample code like a - Python binary linked against libpython2.x.so and some example code - how to embed Mono and PythonNet in a C application. - [tiran] - - - Added yet another python prompt. This time it's a C application that - embedds both Python and Mono. It may be useful as an example app for - others and I need it to debug a nasty bug. [tiran] - - - Implemented ModuleFunctionAttribute and added ForbidPythonThreadsAttribute. - The latter is required for module functions which invoke Python methods. - [tiran] - - - Added clr.setPreload(), clr.getPreload(), clr.AddReference("assembly name"), - clr.FindAssembly("name") and clr.ListAssemblies(verbose). Automatic - preloading can be enabled with clr.setPreload/True). Preloading is - automatically enabled for interactive Python shells and disabled in all - other cases. [tiran] - - - New Makefile that works for Windows and Mono and autodetects the Python - version and UCS 2/4 setting. [tiran] - - - Added code for Python 2.3. PythonNet can be build for Python 2.3 again - but it is not fully supported. [tiran] - - - Changed the PythonException.Message value so it displays the name of - the exception class ("Exception") instead of its representation - (""). - - - Added Python.Runtime.dll.config - - - PythonNet 2.0 alpha 1 - --------------------------------------------------------------------------- - - - Moved the Python for .NET project to Sourceforge and moved version - control to Subversion. - - - Removed CallConvCdecl attributes and the IL hack that they supported. - .NET 2.x now supports UnmanagedFunctionPointer, which does the right - thing without the hackery required in 1.x. This removes a dependency - on ILASM to build the package and better supports Mono (in theory). - - - Refactored import and assembly management machinery. The old 'CLR.' - syntax for import is deprecated, but still supported until 3.x. The - recommended style now is to use 'from System import xxx', etc. We - also now support 'from X import *' correctly. - - - Implemented a (lowercase) 'clr' module to match IronPython for code - compatibility. Methods of this module should be used to explicitly - load assemblies. Implicit (name-based) assembly loading will still - work until 3.x, but it is deprecated. - - - Implemented support for generic types and generic methods using the - same patterns and syntax as IronPython. See the documentation for - usage details. - - - Many small and large performance improvements, switched to generic - collections for some internals, better algorithms for assembly - scanning, etc. - - - Fixed an unboxing issue in generated delegate implementation code - that affected delegates that return value types. - - - PythonNet 1.0 final - --------------------------------------------------------------------------- - - - Backported the refactored import and assembly management from the 2.x - line, mainly to improve the possibility of code-compatibility with - IronPython. - - - PythonNet 1.0 release candidate 2 - --------------------------------------------------------------------------- - - - Changed some uses of Finalize as a static method name that confused the - Mono compiler and people reading the code. Note that this may be a - breaking change if anyone was calling PythonEngine.Finalize(). If so, - you should now use PythonEngine.Shutdown(). - - - Tweaked assembly lookup to ensure that assemblies can be found in the - current working directory, even after changing directories using things - like os.chdir() from Python. - - - Fixed some incorrect finalizers (thanks to Greg Chapman for the report) - that may have caused some threading oddities. - - - Tweaked support for out and ref parameters. If a method has a return - type of void and a single ref or out parameter, that parameter will be - returned as the result of the method. This matches the current behavior - of IronPython and makes it more likely that code can be moved between - Python for .NET and IP in the future. - - - Refactored part of the assembly manager to remove a potential case of - thread-deadlock in multi-threaded applications. - - - Added a __str__ method to managed exceptions that returns the Message - attribute of the exception and the StackTrace (if available). - - - PythonNet 1.0 release candidate 1 - --------------------------------------------------------------------------- - - - Implemented a workaround for the fact that exceptions cannot be new-style - classes in the CPython interpreter. Managed exceptions can now be raised - and caught naturally from Python (hooray!) - - - Implemented support for invoking methods with out and ref parameters. - Because there is no real equivalent to these in Python, methods that - have out or ref parameters will return a tuple. The tuple will contain - the result of the method as its first item, followed by out parameter - values in the order of their declaration in the method signature. - - - Fixed a refcount problem that caused a crash when CLR was imported in - an existing installed Python interpreter. - - - Added an automatic conversion from Python strings to byte[]. This makes - it easier to pass byte[] data to managed methods (or set properties, - etc.) as a Python string without having to write explicit conversion - code. Also works for sbyte arrays. Note that byte and sbyte arrays - returned from managed methods or obtained from properties or fields - do *not* get converted to Python strings - they remain instances of - Byte[] or SByte[]. - - - Added conversion of generic Python sequences to object arrays when - appropriate (thanks to Mackenzie Straight for the patch). - - - Added a bit of cautionary documentation for embedders, focused on - correct handling of the Python global interpreter lock from managed - code for code that calls into Python. - - - PyObject.FromManagedObject now correctly returns the Python None object - if the input is a null reference. Also added a new AsManagedObject - method to PyObject, making it easier to convert a Python-wrapped managed - object to the real managed object. - - - Created a simple installer for windows platforms. - - - PythonNet 1.0 beta 5 - --------------------------------------------------------------------------- - - - Refactored and fixed threading and global interpreter lock handling, - which was badly broken before. Also added a number of threading and - GIL-handling tests. - - - Related to the GIL fixes, added a note to embedders in the README - about using the AcquireLock and ReleaseLock methods of the PythonEngine - class to manage the GIL. - - - Fixed a problem in Single <--> float conversion for cultures that use - different decimal symbols than Python. - - - Added a new ReloadModule method to the PythonEngine class that hooks - Python module reloading (PyImport_ReloadModule). - - - Added a new StringAsModule method to the PythonEngine class that can - create a module from a managed string of code. - - - Added a default __str__ implementation for Python wrappers of managed - objects that calls the ToString method of the managed object. - - - PythonNet 1.0 beta 4 - --------------------------------------------------------------------------- - - - Fixed a problem that made it impossible to override "special" methods - like __getitem__ in subclasses of managed classes. Now the tests all - pass, and there is much rejoicing. - - - Managed classes reflected to Python now have an __doc__ attribute that - contains a listing of the class constructor signatures. - - - Fixed a problem that prevented passing null (None) for array arguments. - - - Added a number of new argument conversion tests. Thanks to Laurent - Caumont for giving Python for .NET a good workout with managed DirectX. - - - Updated the bundled C Python runtime and libraries to Python 2.4. The - current release is known to also run with Python 2.3. It is known - *not* to work with older versions due to changes in CPython type - object structure. - - - Mostly fixed the differences in the way that import works depending - on whether you are using the bundled interpreter or an existing Python - interpreter. The hack I used makes import work uniformly for imports - done in Python modules. Unfortunately, there is still a limitation - when using the interpreter interactively: you need to do 'import CLR' - first before importing any sub-names when running with an existing - Python interpreter. - - The reason is that the first import of 'CLR' installs the CLR import - hook, but for an existing interpreter the standard importer is still - in control for the duration of that first import, so sub-names won't - be found until the next import, which will use the now-installed hook. - - - Added support to directly iterate over objects that support IEnumerator - (as well as IEnumerable). Thanks to Greg Chapman for prodding me ;) - - - Added a section to the README dealing with rebuilding Python for .NET - against other CPython versions. - - - Fixed a problem with accessing properties when only the interface for - an object is known. For example, ICollection(ob).Count failed because - Python for .NET mistakenly decided that Count was abstract. - - - Fixed some problems with how COM-based objects are exposed and how - members of inherited interfaces are exposed. Thanks to Bruce Dodson - for patches on this. - - - Changed the Runtime class to use a const string to target the - appropriate CPython dll in DllImport attributes. Now you only - have to change one line to target a new Python version. - - - PythonNet 1.0 beta 3 - --------------------------------------------------------------------------- - - - A dumb bug that could cause a crash on startup on some platforms was - fixed. Decided to update the beta for this, as a number of people - were running into the problem. - - - PythonNet 1.0 beta 2 - --------------------------------------------------------------------------- - - - Exceptions raised as a result of getting or setting properties were - not very helpful (target invokation exception). This has been changed - to pass through the inner exception the way that methods do, which is - much more likely to be the real exception that caused the problem. - - - Events were refactored as the implementation was based on some bad - assumptions. As a result, subscription and unsubscription now works - correctly. A change from beta 1 is that event objects are no longer - directly callable - this was not appropriate, since the internal - implementation of an event is private and cant work reliably. Instead, - you should the appropriate OnSomeEvent method published by a class - to fire an event. - - - The distribution did not include the key file, making it a pain for - people to build from source. Added the key file to the distribution - buildout for beta 2. - - - Assemblies can now be found and loaded if they are on the PYTHONPATH. - Previously only the appbase and the GAC were checked. The system now - checks PYTHONPATH first, then the appbase, then the GAC. - - - Fixed a bug in constructor invokation during object instantiation. - - - PythonNet 1.0 beta 1 - --------------------------------------------------------------------------- - - - Added the baseline of the managed embedding API. Some of the details - are still subject to change based on some real-world use and feedback. - - The embedding API is based on the PyObject class, along with a number - of specific PyDict, PyList, (etc.) classes that expose the respective - interfaces of the built-in Python types. The basic structure and usage - is intended be familar to anyone who has used Python / C++ wrapper - libraries like CXX or Boost. - - - Started integrating NUnit2 to support unit tests for the embedding - layer - still need to add the embedding tests (many already exist, - but were written for an older version of NUnit). - - - Added Python iteration protocol support for arrays and managed objects - that implement IEnumerable. This means that you can now use the Python - idiom 'for item in object:' on any array or IEnumerable object. - - - Added automatic conversion from Python sequence types to managed array - types. This means, for example, that you can now call a managed method - like AddRange that expects an array with any Python object that supports - the Python sequence protocol, provided the items of the sequence are - convertible to the item type of the managed array. - - - Added new demo scripts, mostly more substantial winforms examples. - - - Finished the unit tests for event support, and fixed lots of problems - with events and delegates as a result. This is one of the trickier - parts of the integration layer, and there is good coverage of these - in the unit tests now. - - - Did a fair amount of profiling with an eval version of ANTS (which is - quite nice, BTW) and made a few changes as a result. - - - Type management was refactored, fixing the issue that caused segfaults - when GC was enabled. Unit tests, stress tests and demo apps now all run - nicely with Python GC enabled. There are one or two things left to fix, - but the fixes should not have any user impact. - - - Changed to base PythonNet on Python 2.3.2. This is considered the most - stable release, and a good 25 - 30% faster as well. - - - Added a new 'CLR.dll' that acts as an extension module that allows an - existing unmodified Python 2.3 installation to simply 'import CLR' to - bootstrap the managed integration layer. - - - A bug was causing managed methods to only expose overloads declared in - a particular class, hiding inherited overloads of the same name. Fixed - the bug and added some unit tests. - - - Added a virtual '__doc__' attribute to managed methods that contains - the signature of the method. This also means that the Python 'help' - function now provides signature info when used on a managed class. - - - Calling managed methods and events 'unbound' (passing the instance as - the first argument) now works. There is a caveat for methods - if a - class declares both static and instance methods with the same name, - it is not possible to call that instance method unbound (the static - method will always be called). - - - Overload selection for overloaded methods is now much better and uses - a method resolution algorithm similar to that used by Jython. - - - Changed the managed python.exe wrapper to run as an STA thread, which - seems to be more compatible with winforms apps. This needs a better - solution long-term. One possibility would be a command line switch - so that -sta or -mta could control the python.exe apartment state. - - - Added support for the Python boolean type (True, False). Bool values - now appear as True or False to Python. - - - PythonNet Preview 2 - --------------------------------------------------------------------------- - - - Added a Mono makefile. Thanks to Camilo Uribe for help in testing and - working out problems on Mono. Note that it not currently possible to - build PythonNet using mono, due to the use of some IL attributes that - the mono assembler / disassembler doesn't support yet. - - - Preliminary tests show that PythonNet *does* actually run under mono, - though the test suite bombs out before the end with an "out of memory" - error from the mono runtime. It's just a guess at this point, but I - suspect there may be a limited pool for allocating certain reflection - structures, and Python uses the reflection infrastructure quite heavily. - - - Removed decoys like the non-working embedding APIs; lots of internal - refactoring. - - - Implemented indexer support. Managed instances that implement indexers - can now be used naturally from Python ( e.g. someobject[0] ). - - - Implemented sequence protocol support for managed arrays. - - - Implemented basic thread state management; calls to managed methods - no longer block Python. I won't go so far as to say the thread - choreography is "finished", as I don't have a comprehensive set of - tests to back that up yet (and it will take some work to write a - sufficiently large and evil set of tests). - - - Fixed a bug that caused conversions of managed strings to PyUnicode to - produce mangled values in certain situations. - - - Fixed a number of problems related to subclassing a managed class, - including the fact that it didn't work :) - - - Fixed all of the bugs that were causing tests to fail. This release - contains all new bugs and new failing tests. Progress! :) - - - PythonNet Preview 1 - --------------------------------------------------------------------------- - - - Initial (mostly) working experimental release. diff --git a/doc/mono_config.txt b/doc/mono_config.txt deleted file mode 100644 index 2e62ad142..000000000 --- a/doc/mono_config.txt +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - - - - - - diff --git a/htdocs/index.html b/htdocs/index.html deleted file mode 100755 index a1c362770..000000000 --- a/htdocs/index.html +++ /dev/null @@ -1,149 +0,0 @@ - - - Codestin Search App - - - - - - - - - - -
-

Python for .NET

-

Python for .NET is a package that gives Python programmers - nearly seamless integration with the .NET Common Language Runtime - (CLR) and provides a powerful application scripting tool for .NET - developers. Using this package you can script .NET applications or - build entire applications in Python, using .NET services and - components written in any language that targets the CLR (Managed - C++, C#, VB, JScript).

-

Note that this package does not implement Python as a - first-class CLR language - it does not produce managed code (IL) - from Python code. Rather, it is an integration of the C Python - engine with the .NET runtime. This approach allows you to use use - CLR services and continue to use existing Python code and C-based - extensions while maintaining native execution speeds for Python - code. If you are interested in a pure managed-code implementation - of the Python language, you should check out the IronPython - project, which is in active development.

-

Python for .NET is currently compatible with Python releases 2.5 - and greater. To subscribe to the - Python for .NET mailing list or read the - online archives of the list, see the - mailing list information page. You can also send questions - or comments to me at brian.lloyd@revolution.com - or use the - Python for .NET issue tracker to report issues.

-

My blog site is - also (sometimes) a good source for more information on Python for - .NET ;)

-
    -
  • The README provides a detailed - overview of Python for .NET, as well as some basic usage - examples. Many other examples can be found in the demos and unit - tests for the package.
  • -
  • Checkout the PythonNet - code from Subversion..
  • -
  • - Download releases for various versions of Python and CLR. -
  • -
-
- - diff --git a/htdocs/license.txt b/htdocs/license.txt deleted file mode 100755 index ec12c9f2a..000000000 --- a/htdocs/license.txt +++ /dev/null @@ -1,61 +0,0 @@ -Zope Public License (ZPL) Version 2.0 ------------------------------------------------ - -This software is Copyright (c) Zope Corporation (tm) and -Contributors. All rights reserved. - -This license has been certified as open source. It has also -been designated as GPL compatible by the Free Software -Foundation (FSF). - -Redistribution and use in source and binary forms, with or -without modification, are permitted provided that the -following conditions are met: - -1. Redistributions in source code must retain the above - copyright notice, this list of conditions, and the following - disclaimer. - -2. Redistributions in binary form must reproduce the above - copyright notice, this list of conditions, and the following - disclaimer in the documentation and/or other materials - provided with the distribution. - -3. The name Zope Corporation (tm) must not be used to - endorse or promote products derived from this software - without prior written permission from Zope Corporation. - -4. The right to distribute this software or to use it for - any purpose does not give you the right to use Servicemarks - (sm) or Trademarks (tm) of Zope Corporation. Use of them is - covered in a separate agreement (see - http://www.zope.com/Marks). - -5. If any files are modified, you must cause the modified - files to carry prominent notices stating that you changed - the files and the date of any change. - -Disclaimer - - THIS SOFTWARE IS PROVIDED BY ZOPE CORPORATION ``AS IS'' - AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT - NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY - AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN - NO EVENT SHALL ZOPE CORPORATION OR ITS CONTRIBUTORS BE - LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH - DAMAGE. - - -This software consists of contributions made by Zope -Corporation and many individuals on behalf of Zope -Corporation. Specific attributions are listed in the -accompanying credits file. - - diff --git a/htdocs/readme.html b/htdocs/readme.html deleted file mode 100755 index d7ae26f04..000000000 --- a/htdocs/readme.html +++ /dev/null @@ -1,672 +0,0 @@ - - - Codestin Search App - - - - - - - - - - - -
-

Python for .NET is a package that gives Python programmers - nearly seamless integration with the .NET Common Language Runtime - (CLR) and provides a powerful application scripting tool for .NET - developers. Using this package you can script .NET applications or - build entire applications in Python, using .NET services and - components written in any language that targets the CLR (Managed - C++, C#, VB, JScript). -

-

Note that this package does not implement Python as a - first-class CLR language - it does not produce managed code (IL) - from Python code. Rather, it is an integration of the C Python - engine with the .NET runtime. This approach allows you to use use - CLR services and continue to use existing Python code and C-based - extensions while maintaining native execution speeds for Python - code. If you are interested in a pure managed-code implementation - of the Python language, you should check out the IronPython - project, which is in active development. -

-

Python for .NET is currently compatible with Python releases 2.3 - and greater. Current releases are available at the - Python for .NET website . To subscribe to the - Python for .NET mailing list or read the - online archives of the list, see the - mailing list information page.

- -

Installation

-

Python for .NET is available as a source release and as a - Windows installer for various versions of Python and the common - language runtime from the - Python for .NET website . On Windows platforms, you can - choose to install .NET-awareness into an existing Python - installation as well as install Python for .NET as a standalone - package. -

- -

The source release is a self-contained "private" assembly. Just - unzip the package wherever you want it, cd to that directory and - run python.exe to start using it. Note that the source release - does not include a copy of the CPython runtime, so you will need - to have installed Python on your machine before using the source - release. -

-

Running on Linux/Mono: preliminary testing - shows that PythonNet will run under Mono, - though the Mono runtime is not yet complete so there still may be - problems. The Python for .NET integration layer is 100% managed - code, so there should be no long-term issues under Mono - it - should work better and better as the Mono platform matures. -

-

Note that if you are running under Mono on a *nix system, you - will need to have a compatible version of Python installed. You - will also need to create a symbolic link to the copy of - libpython2.x.so (in your existing Python installation) in the - PythonNet directory. This is needed to ensure that the mono - interop dll loader will find it by name. For example: -

-
    ln -s /usr/lib/libpython2.4.so ./python24.so
-
- -

Getting Started

-

A key goal for this project has been that Python for .NET should - "work just the way you'd expect in Python", except for cases that - are .NET specific (in which case the goal is to work "just the way - you'd expect in C#"). In addition, with the IronPython project - gaining traction, it is my goal that code written for IronPython - run without modification under Python for .NET. -

-

If you already know Python, you can probably finish this readme - and then refer to .NET docs to figure out anything you need to do. - Conversely if you are familiar with C# or another .NET language, - you probably just need to pick up one of the many good Python - books or read the Python tutorial online to get started. -

-

A good way to start is to run python.exe and - follow along with the examples in this document. If you get stuck, - there are also a number of demos and unit tests located in the - source directory of the distribution that can be helpful as - examples. -

-

Note that if you have installed CLR support into your existing - Python installation (rather than using the included python.exe), - you will need to use the line: "'import clr" (lower-case!) to - initially load the clr extension module before trying the - following examples. -

- -

Importing Modules

-

Python for .NET allows CLR namespaces to be treated essentially - as Python packages.

-

-

-
    from System import String
-    from System.Collections import *
-
-

- Note that earlier releases of Python for .NET required you to - import modules through a special top-level package named CLR. - This is no longer required if you are starting python from the - managed python.exe from this distribution.
- CLR has been deprecated in favor of the more - pythonic clr, though the syntax is still supported - for backward compatibility. -
-

-

Types from any loaded assembly may be imported and used in this - manner. To load an assembly, use the "AddReference" function in - the "clr" module: -

-
-    import clr
-    clr.AddReference("System.Windows.Forms")
-    from System.Windows.Forms import Form
-
-
-

- Note that earlier releases of Python for .NET relied on - "implicit loading" to support automatic loading of assemblies - whose names corresponded to an imported namespace. Implicit - loading still works for backward compatibility, but will be - removed in a future release so it is recommended to use the - clr.AddReference method. - -

-

Python for .NET uses the PYTHONPATH (sys.path) to look for - assemblies to load, in addition to the usual application base and - the GAC. To ensure that you can implicitly import an assembly, put - the directory containing the assembly in sys.path. -

- -

Using Classes

-

Python for .NET allows you to use any non-private classes, - structs, interfaces, enums or delegates from Python. To create an - instance of a managed class, you use the standard instantiation - syntax, passing a set of arguments that match one of its public - constructors: -

-
    from System.Drawing import Point
-
-    p = Point(5, 5)
-
-

In most cases, Python for .NET can determine the correct - constructor to call automatically based on the arguments. In some - cases, it may be necessary to call a particular overloaded - constructor, which is supported by a special "__overloads__" - attribute, which will soon be deprecated in favor of iPy - compatible "Overloads", on a class: -

-
    from System import String, Char, Int32
-
-    s = String.Overloads[Char, Int32]('A', 10)
-    s = String.__overloads__[Char, Int32]('A', 10)
-
- -

Using Generics

-

When running under versions of the .NET runtime greater than - 2.0, you can use generic types. A generic type must be bound to - create a concrete type before it can be instantiated. Generic - types support the subscript syntax to create bound types: -

-
    from System.Collections.Generic import Dictionary
-    from System import *
-
-    dict1 = Dictionary[String, String]()
-    dict2 = Dictionary[String, Int32]()
-    dict3 = Dictionary[String, Type]()
-
-

When you pass a list of types using the subscript syntax, you - can also pass a subset of Python types that directly correspond to - .NET types: -

-
    dict1 = Dictionary[str, str]()
-    dict2 = Dictionary[str, int]()
-    dict3 = Dictionary[str, Decimal]()
-
-

This shorthand also works when explicitly selecting generic - methods or specific versions of overloaded methods and - constructors (explained later). -

-

You can also subclass managed classes in Python, though members - of the Python subclass are not visible to .NET code. See the helloform.py - file in the /demo directory of the distribution for - a simple Windows Forms example that demonstrates subclassing a - managed class. -

- -

Fields And Properties

-

You can get and set fields and properties of CLR objects just as - if they were regular attributes: -

-
    from System import Environment
-
-    name = Environment.MachineName
-    Environment.ExitCode = 1
-
- -

Using Indexers

-

If a managed object implements one or more indexers, you can - call the indexer using standard Python indexing syntax: -

-
    from System.Collections import Hashtable
-
-    table = Hashtable()
-    table["key 1"] = "value 1"
-
-

Overloaded indexers are supported, using the same notation one - would use in C#: -

-
    items[0, 2]
-
-    items[0, 2, 3]
-
- -

Using Methods

-

Methods of CLR objects behave generally like normal Python - methods. Static methods may be called either through the class or - through an instance of the class. All public and protected methods - of CLR objects are accessible to Python: -

-
    from System import Environment
-
-    drives = Environment.GetLogicalDrives()
-
-

It is also possible to call managed methods unbound - (passing the instance as the first argument) just as with Python - methods. This is most often used to explicitly call methods of a - base class. -

-

Note that there is one caveat related to calling unbound - methods: it is possible for a managed class to declare a static - method and an instance method with the same name. Since it is - not possible for the runtime to know the intent when such a - method is called unbound, the static method will always be - called. -

-

The docstring of CLR a method (__doc__) can be used to view the - signature of the method, including overloads if the CLR method is - overloaded. You can also use the Python help method - to inspect a managed class: -

-
    from System import Environment
-
-    print Environment.GetFolderPath.__doc__
-
-    help(Environment)
-
- -

Overloaded and Generic Methods

-

While Python for .NET will generally be able to figure out the - right version of an overloaded method to call automatically, there - are cases where it is desirable to select a particular method - overload explicitly. -

-

Methods of CLR objects have an "__overloads__", which will soon - be deprecated in favor of iPy compatible Overloads, attribute that - can be used for this purpose : -

-
    from System import Console
-
-    Console.WriteLine.Overloads[bool](true)
-    Console.WriteLine.Overloads[str]("true")
-    Console.WriteLine.__overloads__[int](42)
-
-

Similarly, generic methods may be bound at runtime using the - subscript syntax directly on the method: -

-
    someobject.SomeGenericMethod[int](10)
-    someobject.SomeGenericMethod[str]("10")
-
- -

Delegates And Events

-

Delegates defined in managed code can be implemented in Python. - A delegate type can be instantiated and passed a callable Python - object to get a delegate instance. The resulting delegate instance - is a true managed delegate that will invoke the given Python - callable when it is called: -

-
    def my_handler(source, args):
-        print 'my_handler called!'
-
-    # instantiate a delegate
-    d = AssemblyLoadEventHandler(my_handler)
-
-    # use it as an event handler
-    AppDomain.CurrentDomain.AssemblyLoad += d
-
-

Multicast delegates can be implemented by adding more callable - objects to a delegate instance: -

-
    d += self.method1
-    d += self.method2
-    d()
-
-

Events are treated as first-class objects in Python, and behave - in many ways like methods. Python callbacks can be registered with - event attributes, and an event can be called to fire the event. -

-

Note that events support a convenience spelling similar to that - used in C#. You do not need to pass an explicitly instantiated - delegate instance to an event (though you can if you want). Events - support the += and -= operators in a - way very similar to the C# idiom: -

-
    def handler(source, args):
-        print 'my_handler called!'
-
-    # register event handler
-    object.SomeEvent += handler
-
-    # unregister event handler
-    object.SomeEvent -= handler
-
-    # fire the event
-    result = object.SomeEvent(...)
-
- -

Exception Handling

-

You can raise and catch managed exceptions just the same as you - would pure-Python exceptions: -

-
    from System import NullReferenceException
-
-    try:
-        raise NullReferenceException("aiieee!")
-    except NullReferenceException, e:
-        print e.Message
-        print e.Source
-
-

- -

Using Arrays

-

The type System.Array supports the subscript - syntax in order to make it easy to create managed arrays from - Python: -

-
    from System import Array
-
-    myarray = Array[int](10)
-
-

Managed arrays support the standard Python sequence protocols: -

-
    items = SomeObject.GetArray()
-
-    # Get first item
-    v = items[0]
-    items[0] = v
-
-    # Get last item
-    v = items[-1]
-    items[-1] = v
-
-    # Get length
-    l = len(items)
-
-    # Containment test
-    test = v in items
-
-

Multidimensional arrays support indexing using the same notation - one would use in C#: -

-
    items[0, 2]
-
-    items[0, 2, 3]
-
- -

Using Collections

-

Managed arrays and managed objects that implement the - IEnumerable interface can be iterated over using the standard - iteration Python idioms: -

-
    domain = System.AppDomain.CurrentDomain
-
-    for item in domain.GetAssemblies():
-        name = item.GetName()
-
- -

Using COM Components

-

Using Microsoft-provided tools such as aximp.exe - and tlbimp.exe, it is possible to generate - managed wrappers for COM libraries. After generating such a - wrapper, you can use the libraries from Python just like any other - managed code. -

-

Note: currently you need to put the generated wrappers in the - GAC, in the PythonNet assembly directory or on the PYTHONPATH in - order to load them. -

- -

Type Conversion

-

Type conversion under Python for .NET is fairly straightforward - - most elemental Python types (string, int, long, etc.) convert - automatically to compatible managed equivalents (String, Int32, - etc.) and vice-versa. Note that all strings returned from the CLR - are returned as unicode. -

-

Types that do not have a logical equivalent in Python are - exposed as instances of managed classes or structs (System.Decimal - is an example). -

-

The .NET architecture makes a distinction between value - types and reference types. Reference types - are allocated on the heap, and value types are allocated either on - the stack or in-line within an object. -

-

A process called boxing is used in .NET to allow - code to treat a value type as if it were a reference type. Boxing - causes a separate copy of the value type object to be created on - the heap, which then has reference type semantics. -

-

Understanding boxing and the distinction between value types and - reference types can be important when using Python for .NET - because the Python language has no value type semantics or syntax - - in Python "everything is a reference". -

-

Here is a simple example that demonstrates an issue. If you are - an experienced C# programmer, you might write the following code: -

-
    items = System.Array.CreateInstance(Point, 3)
-    for i in range(3):
-        items[i] = Point(0, 0)
-
-    items[0].X = 1 # won't work!!
-
-

While the spelling of items[0].X = 1 is the same - in C# and Python, there is an important and subtle semantic - difference. In C# (and other compiled-to-IL languages), the - compiler knows that Point is a value type and can do the Right - Thing here, changing the value in place. -

-

In Python however, "everything's a reference", and there is - really no spelling or semantic to allow it to do the right thing - dynamically. The specific reason that items[0] - itself doesn't change is that when you say items[0], - that getitem operation creates a Python object that holds a - reference to the object at items[0] via a GCHandle. - That causes a ValueType (like Point) to be boxed, so the following - setattr (.X = 1) changes the state of the boxed - value, not the original unboxed value. -

-

The rule in Python is essentially: "the result of any attribute - or item access is a boxed value", and that can be important in how - you approach your code. -

-

Because there are no value type semantics or syntax in Python, - you may need to modify your approach. To revisit the previous - example, we can ensure that the changes we want to make to an - array item aren't "lost" by resetting an array member after making - changes to it: -

-
    items = System.Array.CreateInstance(Point, 3)
-    for i in range(3):
-        items[i] = Point(0, 0)
-
-    # This _will_ work. We get 'item' as a boxed copy of the Point
-    # object actually stored in the array. After making our changes
-    # we re-set the array item to update the bits in the array.
-
-    item = items[0]
-    item.X = 1
-    items[0] = item
-
-

This is not unlike some of the cases you can find in C# where - you have to know about boxing behavior to avoid similar kinds of lost - update problems (generally because an implicit boxing - happened that was not taken into account in the code). -

-

This is the same thing, just the manifestation is a little - different in Python. See the .NET documentation for more details - on boxing and the differences between value types and reference - types. -

- -

Embedding Python

-

Note: because Python code running under Python - for .NET is inherently unverifiable, it runs totally under the - radar of the security infrastructure of the CLR so you should - restrict use of the Python assembly to trusted code. -

-

The Python runtime assembly defines a number of public classes - that provide a subset of the functionality provided by the Python - C API. -

-

These classes include PyObject, PyList, PyDict, etc. The source - and the unit tests are currently the only API documentation.. The - rhythym is very similar to using Python C++ wrapper solutions such - as CXX. -

-

At a very high level, to embed Python in your application you - will need to: -

-
    -
  • Reference Python.Runtime.dll in your build environment
  • -
  • Call PythonEngine.Intialize() to initialize Python
  • -
  • Call PythonEngine.ImportModule(name) to import a module
  • -
-

The module you import can either start working with your managed - app environment at the time its imported, or you can explicitly - lookup and call objects in a module you import. -

-

For general-purpose information on embedding Python in - applications, use www.python.org or Google to find (C) examples. - Because Python for .NET is so closely integrated with the managed - environment, you will generally be better off importing a module - and deferring to Python code as early as possible rather than - writing a lot of managed embedding code. -

-

Important Note for embedders: Python is not - free-threaded and uses a global interpreter lock to allow - multi-threaded applications to interact safely with the Python - interpreter. Much more information about this is available in the - Python C API documentation on the www.python.org Website. -

-

When embedding Python in a managed application, you have to - manage the GIL in just the same way you would when embedding - Python in a C or C++ application. -

-

Before interacting with any of the objects or APIs provided by - the Python.Runtime namespace, calling code must have acquired the - Python global interpreter lock by calling the PythonEngine.AcquireLock - method. The only exception to this rule is the PythonEngine.Initialize - method, which may be called at startup without having acquired the - GIL. -

-

When finished using Python APIs, managed code must call a - corresponding PythonEngine.ReleaseLock to release - the GIL and allow other threads to use Python. -

-

The AcquireLock and ReleaseLock methods are thin wrappers over - the unmanaged PyGILState_Ensure and PyGILState_Release - functions from the Python API, and the documentation for those - APIs applies to the managed versions. -

- -

License

-
-

Python for .NET is released under the open - source Zope Public License (ZPL). A copy of the ZPL is included - in the distribution, or you can find a copy of the - ZPL online . Some distributions of this package include a - copy of the C Python dlls and standard library, which are covered - by the Python - license . -

-
- - diff --git a/installer/installer.iss b/installer/installer.iss deleted file mode 100644 index b0aa6ea2b..000000000 --- a/installer/installer.iss +++ /dev/null @@ -1,73 +0,0 @@ -; -------------------------------------------------------------------------------- -; Setup script for Python for .NET (based on InnoSetup 5.0.8) -; -------------------------------------------------------------------------------- - -[Setup] - -SourceDir=.. -OutputDir=release - -AppName=Python for .NET -AppVerName=Python for .NET 1.0 RC2 -AppPublisher=Brian Lloyd -AppCopyright=Copyright © 2005 Zope Corporation -DefaultDirName={pf}\PythonNet -DefaultGroupName=Python for .NET -LicenseFile=installer\license.txt -DisableProgramGroupPage=yes -WizardImageFile=installer\left.bmp -WizardSmallImageFile=installer\top.bmp -WizardImageStretch=no - - -[Tasks] - -Name: "existing"; Description: "Install .NET support in &existing python installation"; Flags: unchecked -Name: "icon"; Description: "Create a &desktop icon"; Flags: unchecked - - - -[Files] - -Source: "makefile"; DestDir: "{app}"; Excludes: ".svn*,~*,CVS*"; Flags: ignoreversion -Source: "python.exe"; DestDir: "{app}"; Excludes: ".svn*,~*,CVS*"; Flags: ignoreversion - -Source: "*.dll"; DestDir: "{app}"; Excludes: ".svn*,~*,CVS*"; Flags: ignoreversion -Source: "demo\*.*"; DestDir: "{app}\demo"; Excludes: ".svn*,~*,CVS*"; Flags: ignoreversion recursesubdirs -Source: "doc\*.*"; DestDir: "{app}\doc"; Excludes: ".svn*,~*,CVS*"; Flags: ignoreversion recursesubdirs -Source: "src\*.*"; DestDir: "{app}\src"; Excludes: ".svn*,~*,CVS*"; Flags: ignoreversion recursesubdirs -Source: "redist\2.3\*.*"; DestDir: "{app}"; Excludes: ".svn*,~*,CVS*"; Flags: ignoreversion recursesubdirs -Source: "doc/readme.html"; DestDir: "{app}/doc"; Excludes: ".svn*,~*,CVS*"; Flags: ignoreversion isreadme - -Source: "*Python.Runtime.dll"; DestDir: "{code:GetPythonDir}"; Excludes: ".svn*,~*,CVS*"; Flags: ignoreversion recursesubdirs; Check: UpdateExisting -Source: "CLR.dll"; DestDir: "{code:GetPythonDir}"; Excludes: ".svn*,~*,CVS*"; Flags: ignoreversion recursesubdirs; Check: UpdateExisting - -[Icons] - -Name: "{group}\Python for .NET"; Filename: "{app}\python.exe" -Name: "{userdesktop}\Python for .NET"; Filename: "{app}\python.exe"; Tasks: icon - - -[Code] - -function GetPythonDir(Default: String): string; -var - path : string; -begin - path := ''; - RegQueryStringValue(HKLM, 'Software\Python\PythonCore\2.3\InstallPath', '', path); - Result := path; -end; - -function UpdateExisting(): boolean; -var - temp: string; - res: boolean; -begin - temp := WizardSelectedTasks(False); - res := (Pos('existing', temp) <> 0); - temp := GetPythonDir(''); - Result := res and (Pos('Python', temp) <> 0); -end; - - diff --git a/installer/left.bmp b/installer/left.bmp deleted file mode 100644 index 424aae680..000000000 Binary files a/installer/left.bmp and /dev/null differ diff --git a/installer/license.txt b/installer/license.txt deleted file mode 100644 index 44e0648b3..000000000 --- a/installer/license.txt +++ /dev/null @@ -1,59 +0,0 @@ -Zope Public License (ZPL) Version 2.0 ------------------------------------------------ - -This software is Copyright (c) Zope Corporation (tm) and -Contributors. All rights reserved. - -This license has been certified as open source. It has also -been designated as GPL compatible by the Free Software -Foundation (FSF). - -Redistribution and use in source and binary forms, with or -without modification, are permitted provided that the -following conditions are met: - -1. Redistributions in source code must retain the above - copyright notice, this list of conditions, and the following - disclaimer. - -2. Redistributions in binary form must reproduce the above - copyright notice, this list of conditions, and the following - disclaimer in the documentation and/or other materials - provided with the distribution. - -3. The name Zope Corporation (tm) must not be used to - endorse or promote products derived from this software - without prior written permission from Zope Corporation. - -4. The right to distribute this software or to use it for - any purpose does not give you the right to use Servicemarks - (sm) or Trademarks (tm) of Zope Corporation. Use of them is - covered in a separate agreement (see - http://www.zope.com/Marks). - -5. If any files are modified, you must cause the modified - files to carry prominent notices stating that you changed - the files and the date of any change. - -Disclaimer - - THIS SOFTWARE IS PROVIDED BY ZOPE CORPORATION ``AS IS'' - AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT - NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY - AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN - NO EVENT SHALL ZOPE CORPORATION OR ITS CONTRIBUTORS BE - LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH - DAMAGE. - - -This software consists of contributions made by Zope -Corporation and many individuals on behalf of Zope -Corporation. Specific attributions are listed in the -accompanying credits file. diff --git a/installer/top.bmp b/installer/top.bmp deleted file mode 100644 index 370ff89ba..000000000 Binary files a/installer/top.bmp and /dev/null differ diff --git a/monopythonnet.mds b/monopythonnet.mds deleted file mode 100644 index 1d3dc000d..000000000 --- a/monopythonnet.mds +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/pythonnet.build b/pythonnet.build deleted file mode 100644 index 9d0d6584a..000000000 --- a/pythonnet.build +++ /dev/null @@ -1,74 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/pythonnet.sln b/pythonnet.sln index 64bf45fa2..0a4dbe1f7 100644 --- a/pythonnet.sln +++ b/pythonnet.sln @@ -1,4 +1,4 @@ - + Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 2013 VisualStudioVersion = 12.0.30110.0 @@ -89,10 +89,14 @@ Global {E29DCF0A-5114-4A98-B1DD-71264B6EA349}.ReleaseWin|x64.Build.0 = Release|x64 {E29DCF0A-5114-4A98-B1DD-71264B6EA349}.ReleaseWin|x86.ActiveCfg = Release|x86 {E29DCF0A-5114-4A98-B1DD-71264B6EA349}.ReleaseWin|x86.Build.0 = Release|x86 + {86E834DE-1139-4511-96CC-69636A56E7AC}.DebugMono|x64.ActiveCfg = DebugWin|x64 + {86E834DE-1139-4511-96CC-69636A56E7AC}.DebugMono|x86.ActiveCfg = DebugWin|x86 {86E834DE-1139-4511-96CC-69636A56E7AC}.DebugWin|x64.ActiveCfg = DebugWin|x64 {86E834DE-1139-4511-96CC-69636A56E7AC}.DebugWin|x64.Build.0 = DebugWin|x64 {86E834DE-1139-4511-96CC-69636A56E7AC}.DebugWin|x86.ActiveCfg = DebugWin|x86 {86E834DE-1139-4511-96CC-69636A56E7AC}.DebugWin|x86.Build.0 = DebugWin|x86 + {86E834DE-1139-4511-96CC-69636A56E7AC}.ReleaseMono|x64.ActiveCfg = ReleaseWin|x64 + {86E834DE-1139-4511-96CC-69636A56E7AC}.ReleaseMono|x86.ActiveCfg = ReleaseWin|x86 {86E834DE-1139-4511-96CC-69636A56E7AC}.ReleaseWin|x64.ActiveCfg = ReleaseWin|x64 {86E834DE-1139-4511-96CC-69636A56E7AC}.ReleaseWin|x64.Build.0 = ReleaseWin|x64 {86E834DE-1139-4511-96CC-69636A56E7AC}.ReleaseWin|x86.ActiveCfg = ReleaseWin|x86 diff --git a/pythonnet_8.sln b/pythonnet_8.sln deleted file mode 100644 index e30c01be0..000000000 --- a/pythonnet_8.sln +++ /dev/null @@ -1,86 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 9.00 -# Visual Studio 2005 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Python.Runtime", "src\runtime\Python.Runtime.csproj", "{097B4AC0-74E9-4C58-BCF8-C69746EC8271}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Python.Test", "src\testing\Python.Test.csproj", "{6F401A34-273B-450F-9A4C-13550BE0767B}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Python.EmbeddingTest", "src\embed_tests\Python.EmbeddingTest.csproj", "{4165C59D-2822-499F-A6DB-EACA4C331EB5}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Console", "src\console\Console.csproj", "{E29DCF0A-5114-4A98-B1DD-71264B6EA349}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Debug|x64 = Debug|x64 - EmbeddingTest|Any CPU = EmbeddingTest|Any CPU - EmbeddingTest|x64 = EmbeddingTest|x64 - Release|Any CPU = Release|Any CPU - Release|x64 = Release|x64 - UnitTests|Any CPU = UnitTests|Any CPU - UnitTests|x64 = UnitTests|x64 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {097B4AC0-74E9-4C58-BCF8-C69746EC8271}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {097B4AC0-74E9-4C58-BCF8-C69746EC8271}.Debug|Any CPU.Build.0 = Debug|Any CPU - {097B4AC0-74E9-4C58-BCF8-C69746EC8271}.Debug|x64.ActiveCfg = Debug|x64 - {097B4AC0-74E9-4C58-BCF8-C69746EC8271}.Debug|x64.Build.0 = Debug|x64 - {097B4AC0-74E9-4C58-BCF8-C69746EC8271}.EmbeddingTest|Any CPU.ActiveCfg = Debug|Any CPU - {097B4AC0-74E9-4C58-BCF8-C69746EC8271}.EmbeddingTest|Any CPU.Build.0 = Debug|Any CPU - {097B4AC0-74E9-4C58-BCF8-C69746EC8271}.EmbeddingTest|x64.ActiveCfg = Debug|x64 - {097B4AC0-74E9-4C58-BCF8-C69746EC8271}.EmbeddingTest|x64.Build.0 = Debug|x64 - {097B4AC0-74E9-4C58-BCF8-C69746EC8271}.Release|Any CPU.ActiveCfg = Release|Any CPU - {097B4AC0-74E9-4C58-BCF8-C69746EC8271}.Release|Any CPU.Build.0 = Release|Any CPU - {097B4AC0-74E9-4C58-BCF8-C69746EC8271}.Release|x64.ActiveCfg = Release|x64 - {097B4AC0-74E9-4C58-BCF8-C69746EC8271}.Release|x64.Build.0 = Release|x64 - {097B4AC0-74E9-4C58-BCF8-C69746EC8271}.UnitTests|Any CPU.ActiveCfg = Debug|Any CPU - {097B4AC0-74E9-4C58-BCF8-C69746EC8271}.UnitTests|Any CPU.Build.0 = Debug|Any CPU - {097B4AC0-74E9-4C58-BCF8-C69746EC8271}.UnitTests|x64.ActiveCfg = Debug|x64 - {097B4AC0-74E9-4C58-BCF8-C69746EC8271}.UnitTests|x64.Build.0 = Debug|x64 - {6F401A34-273B-450F-9A4C-13550BE0767B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {6F401A34-273B-450F-9A4C-13550BE0767B}.Debug|Any CPU.Build.0 = Debug|Any CPU - {6F401A34-273B-450F-9A4C-13550BE0767B}.Debug|x64.ActiveCfg = Debug|Any CPU - {6F401A34-273B-450F-9A4C-13550BE0767B}.Debug|x64.Build.0 = Debug|Any CPU - {6F401A34-273B-450F-9A4C-13550BE0767B}.EmbeddingTest|Any CPU.ActiveCfg = Debug|Any CPU - {6F401A34-273B-450F-9A4C-13550BE0767B}.EmbeddingTest|Any CPU.Build.0 = Debug|Any CPU - {6F401A34-273B-450F-9A4C-13550BE0767B}.EmbeddingTest|x64.ActiveCfg = Debug|Any CPU - {6F401A34-273B-450F-9A4C-13550BE0767B}.EmbeddingTest|x64.Build.0 = Debug|Any CPU - {6F401A34-273B-450F-9A4C-13550BE0767B}.Release|Any CPU.ActiveCfg = Release|Any CPU - {6F401A34-273B-450F-9A4C-13550BE0767B}.Release|Any CPU.Build.0 = Release|Any CPU - {6F401A34-273B-450F-9A4C-13550BE0767B}.Release|x64.ActiveCfg = Release|Any CPU - {6F401A34-273B-450F-9A4C-13550BE0767B}.Release|x64.Build.0 = Release|Any CPU - {6F401A34-273B-450F-9A4C-13550BE0767B}.UnitTests|Any CPU.ActiveCfg = Debug|Any CPU - {6F401A34-273B-450F-9A4C-13550BE0767B}.UnitTests|Any CPU.Build.0 = Debug|Any CPU - {6F401A34-273B-450F-9A4C-13550BE0767B}.UnitTests|x64.ActiveCfg = Debug|Any CPU - {6F401A34-273B-450F-9A4C-13550BE0767B}.UnitTests|x64.Build.0 = Debug|Any CPU - {4165C59D-2822-499F-A6DB-EACA4C331EB5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {4165C59D-2822-499F-A6DB-EACA4C331EB5}.Debug|x64.ActiveCfg = Debug|Any CPU - {4165C59D-2822-499F-A6DB-EACA4C331EB5}.EmbeddingTest|Any CPU.ActiveCfg = Release|Any CPU - {4165C59D-2822-499F-A6DB-EACA4C331EB5}.EmbeddingTest|Any CPU.Build.0 = Release|Any CPU - {4165C59D-2822-499F-A6DB-EACA4C331EB5}.EmbeddingTest|x64.ActiveCfg = Release|Any CPU - {4165C59D-2822-499F-A6DB-EACA4C331EB5}.EmbeddingTest|x64.Build.0 = Release|Any CPU - {4165C59D-2822-499F-A6DB-EACA4C331EB5}.Release|Any CPU.ActiveCfg = Release|Any CPU - {4165C59D-2822-499F-A6DB-EACA4C331EB5}.Release|x64.ActiveCfg = Release|Any CPU - {4165C59D-2822-499F-A6DB-EACA4C331EB5}.UnitTests|Any CPU.ActiveCfg = Debug|Any CPU - {4165C59D-2822-499F-A6DB-EACA4C331EB5}.UnitTests|x64.ActiveCfg = Debug|Any CPU - {E29DCF0A-5114-4A98-B1DD-71264B6EA349}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {E29DCF0A-5114-4A98-B1DD-71264B6EA349}.Debug|Any CPU.Build.0 = Debug|Any CPU - {E29DCF0A-5114-4A98-B1DD-71264B6EA349}.Debug|x64.ActiveCfg = Debug|Any CPU - {E29DCF0A-5114-4A98-B1DD-71264B6EA349}.Debug|x64.Build.0 = Debug|Any CPU - {E29DCF0A-5114-4A98-B1DD-71264B6EA349}.EmbeddingTest|Any CPU.ActiveCfg = EmbeddingTest|Any CPU - {E29DCF0A-5114-4A98-B1DD-71264B6EA349}.EmbeddingTest|Any CPU.Build.0 = EmbeddingTest|Any CPU - {E29DCF0A-5114-4A98-B1DD-71264B6EA349}.EmbeddingTest|x64.ActiveCfg = EmbeddingTest|Any CPU - {E29DCF0A-5114-4A98-B1DD-71264B6EA349}.EmbeddingTest|x64.Build.0 = EmbeddingTest|Any CPU - {E29DCF0A-5114-4A98-B1DD-71264B6EA349}.Release|Any CPU.ActiveCfg = Release|Any CPU - {E29DCF0A-5114-4A98-B1DD-71264B6EA349}.Release|Any CPU.Build.0 = Release|Any CPU - {E29DCF0A-5114-4A98-B1DD-71264B6EA349}.Release|x64.ActiveCfg = Release|Any CPU - {E29DCF0A-5114-4A98-B1DD-71264B6EA349}.Release|x64.Build.0 = Release|Any CPU - {E29DCF0A-5114-4A98-B1DD-71264B6EA349}.UnitTests|Any CPU.ActiveCfg = UnitTests|Any CPU - {E29DCF0A-5114-4A98-B1DD-71264B6EA349}.UnitTests|Any CPU.Build.0 = UnitTests|Any CPU - {E29DCF0A-5114-4A98-B1DD-71264B6EA349}.UnitTests|x64.ActiveCfg = UnitTests|Any CPU - {E29DCF0A-5114-4A98-B1DD-71264B6EA349}.UnitTests|x64.Build.0 = UnitTests|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/pythonnet_9.sln b/pythonnet_9.sln deleted file mode 100644 index 1d11d7fd8..000000000 --- a/pythonnet_9.sln +++ /dev/null @@ -1,87 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 10.00 -# Visual Studio 2008 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Python.Runtime", "src\runtime\Python.Runtime.csproj", "{097B4AC0-74E9-4C58-BCF8-C69746EC8271}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Python.Test", "src\testing\Python.Test.csproj", "{6F401A34-273B-450F-9A4C-13550BE0767B}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Python.EmbeddingTest", "src\embed_tests\Python.EmbeddingTest.csproj", "{4165C59D-2822-499F-A6DB-EACA4C331EB5}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Console", "src\console\Console.csproj", "{E29DCF0A-5114-4A98-B1DD-71264B6EA349}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Debug|x64 = Debug|x64 - EmbeddingTest|Any CPU = EmbeddingTest|Any CPU - EmbeddingTest|x64 = EmbeddingTest|x64 - Release|Any CPU = Release|Any CPU - Release|x64 = Release|x64 - UnitTests|Any CPU = UnitTests|Any CPU - UnitTests|x64 = UnitTests|x64 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {097B4AC0-74E9-4C58-BCF8-C69746EC8271}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {097B4AC0-74E9-4C58-BCF8-C69746EC8271}.Debug|Any CPU.Build.0 = Debug|Any CPU - {097B4AC0-74E9-4C58-BCF8-C69746EC8271}.Debug|x64.ActiveCfg = Debug|x64 - {097B4AC0-74E9-4C58-BCF8-C69746EC8271}.Debug|x64.Build.0 = Debug|x64 - {097B4AC0-74E9-4C58-BCF8-C69746EC8271}.EmbeddingTest|Any CPU.ActiveCfg = Debug|Any CPU - {097B4AC0-74E9-4C58-BCF8-C69746EC8271}.EmbeddingTest|Any CPU.Build.0 = Debug|Any CPU - {097B4AC0-74E9-4C58-BCF8-C69746EC8271}.EmbeddingTest|x64.ActiveCfg = Debug|x64 - {097B4AC0-74E9-4C58-BCF8-C69746EC8271}.EmbeddingTest|x64.Build.0 = Debug|x64 - {097B4AC0-74E9-4C58-BCF8-C69746EC8271}.Release|Any CPU.ActiveCfg = Release|Any CPU - {097B4AC0-74E9-4C58-BCF8-C69746EC8271}.Release|Any CPU.Build.0 = Release|Any CPU - {097B4AC0-74E9-4C58-BCF8-C69746EC8271}.Release|x64.ActiveCfg = Release|x64 - {097B4AC0-74E9-4C58-BCF8-C69746EC8271}.Release|x64.Build.0 = Release|x64 - {097B4AC0-74E9-4C58-BCF8-C69746EC8271}.UnitTests|Any CPU.ActiveCfg = Debug|Any CPU - {097B4AC0-74E9-4C58-BCF8-C69746EC8271}.UnitTests|Any CPU.Build.0 = Debug|Any CPU - {097B4AC0-74E9-4C58-BCF8-C69746EC8271}.UnitTests|x64.ActiveCfg = Debug|x64 - {097B4AC0-74E9-4C58-BCF8-C69746EC8271}.UnitTests|x64.Build.0 = Debug|x64 - {6F401A34-273B-450F-9A4C-13550BE0767B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {6F401A34-273B-450F-9A4C-13550BE0767B}.Debug|Any CPU.Build.0 = Debug|Any CPU - {6F401A34-273B-450F-9A4C-13550BE0767B}.Debug|x64.ActiveCfg = Debug|Any CPU - {6F401A34-273B-450F-9A4C-13550BE0767B}.Debug|x64.Build.0 = Debug|Any CPU - {6F401A34-273B-450F-9A4C-13550BE0767B}.EmbeddingTest|Any CPU.ActiveCfg = Debug|Any CPU - {6F401A34-273B-450F-9A4C-13550BE0767B}.EmbeddingTest|Any CPU.Build.0 = Debug|Any CPU - {6F401A34-273B-450F-9A4C-13550BE0767B}.EmbeddingTest|x64.ActiveCfg = Debug|Any CPU - {6F401A34-273B-450F-9A4C-13550BE0767B}.EmbeddingTest|x64.Build.0 = Debug|Any CPU - {6F401A34-273B-450F-9A4C-13550BE0767B}.Release|Any CPU.ActiveCfg = Release|Any CPU - {6F401A34-273B-450F-9A4C-13550BE0767B}.Release|Any CPU.Build.0 = Release|Any CPU - {6F401A34-273B-450F-9A4C-13550BE0767B}.Release|x64.ActiveCfg = Release|Any CPU - {6F401A34-273B-450F-9A4C-13550BE0767B}.Release|x64.Build.0 = Release|Any CPU - {6F401A34-273B-450F-9A4C-13550BE0767B}.UnitTests|Any CPU.ActiveCfg = Debug|Any CPU - {6F401A34-273B-450F-9A4C-13550BE0767B}.UnitTests|Any CPU.Build.0 = Debug|Any CPU - {6F401A34-273B-450F-9A4C-13550BE0767B}.UnitTests|x64.ActiveCfg = Debug|Any CPU - {6F401A34-273B-450F-9A4C-13550BE0767B}.UnitTests|x64.Build.0 = Debug|Any CPU - {4165C59D-2822-499F-A6DB-EACA4C331EB5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {4165C59D-2822-499F-A6DB-EACA4C331EB5}.Debug|Any CPU.Build.0 = Debug|Any CPU - {4165C59D-2822-499F-A6DB-EACA4C331EB5}.Debug|x64.ActiveCfg = Debug|Any CPU - {4165C59D-2822-499F-A6DB-EACA4C331EB5}.EmbeddingTest|Any CPU.ActiveCfg = Release|Any CPU - {4165C59D-2822-499F-A6DB-EACA4C331EB5}.EmbeddingTest|Any CPU.Build.0 = Release|Any CPU - {4165C59D-2822-499F-A6DB-EACA4C331EB5}.EmbeddingTest|x64.ActiveCfg = Release|Any CPU - {4165C59D-2822-499F-A6DB-EACA4C331EB5}.EmbeddingTest|x64.Build.0 = Release|Any CPU - {4165C59D-2822-499F-A6DB-EACA4C331EB5}.Release|Any CPU.ActiveCfg = Release|Any CPU - {4165C59D-2822-499F-A6DB-EACA4C331EB5}.Release|x64.ActiveCfg = Release|Any CPU - {4165C59D-2822-499F-A6DB-EACA4C331EB5}.UnitTests|Any CPU.ActiveCfg = Debug|Any CPU - {4165C59D-2822-499F-A6DB-EACA4C331EB5}.UnitTests|x64.ActiveCfg = Debug|Any CPU - {E29DCF0A-5114-4A98-B1DD-71264B6EA349}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {E29DCF0A-5114-4A98-B1DD-71264B6EA349}.Debug|Any CPU.Build.0 = Debug|Any CPU - {E29DCF0A-5114-4A98-B1DD-71264B6EA349}.Debug|x64.ActiveCfg = Debug|Any CPU - {E29DCF0A-5114-4A98-B1DD-71264B6EA349}.Debug|x64.Build.0 = Debug|Any CPU - {E29DCF0A-5114-4A98-B1DD-71264B6EA349}.EmbeddingTest|Any CPU.ActiveCfg = EmbeddingTest|Any CPU - {E29DCF0A-5114-4A98-B1DD-71264B6EA349}.EmbeddingTest|Any CPU.Build.0 = EmbeddingTest|Any CPU - {E29DCF0A-5114-4A98-B1DD-71264B6EA349}.EmbeddingTest|x64.ActiveCfg = EmbeddingTest|Any CPU - {E29DCF0A-5114-4A98-B1DD-71264B6EA349}.EmbeddingTest|x64.Build.0 = EmbeddingTest|Any CPU - {E29DCF0A-5114-4A98-B1DD-71264B6EA349}.Release|Any CPU.ActiveCfg = Release|Any CPU - {E29DCF0A-5114-4A98-B1DD-71264B6EA349}.Release|Any CPU.Build.0 = Release|Any CPU - {E29DCF0A-5114-4A98-B1DD-71264B6EA349}.Release|x64.ActiveCfg = Release|Any CPU - {E29DCF0A-5114-4A98-B1DD-71264B6EA349}.Release|x64.Build.0 = Release|Any CPU - {E29DCF0A-5114-4A98-B1DD-71264B6EA349}.UnitTests|Any CPU.ActiveCfg = UnitTests|Any CPU - {E29DCF0A-5114-4A98-B1DD-71264B6EA349}.UnitTests|Any CPU.Build.0 = UnitTests|Any CPU - {E29DCF0A-5114-4A98-B1DD-71264B6EA349}.UnitTests|x64.ActiveCfg = UnitTests|Any CPU - {E29DCF0A-5114-4A98-B1DD-71264B6EA349}.UnitTests|x64.Build.0 = UnitTests|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/setup.py b/setup.py index c5b00049d..cda322ccd 100644 --- a/setup.py +++ b/setup.py @@ -10,7 +10,7 @@ from distutils.spawn import find_executable from distutils import log from platform import architecture -from subprocess import Popen, CalledProcessError, PIPE, check_call, check_output +from subprocess import Popen, CalledProcessError, PIPE, check_call from glob import glob import fnmatch import sys @@ -155,8 +155,8 @@ def build_extension(self, ext): enable_shared = get_config_var("Py_ENABLE_SHARED") if enable_shared: # Double-check if libpython is linked dynamically with python - lddout = check_output(["ldd", sys.executable]) - if b'libpython' not in lddout: + lddout = _check_output(["ldd", sys.executable]) + if 'libpython' not in lddout: enable_shared = False if not enable_shared: @@ -339,11 +339,10 @@ def _get_interop_filename(): author="Python for .Net developers", classifiers=[ 'Programming Language :: Python :: 2.7', - 'Programming Language :: Python :: 3.2', 'Programming Language :: Python :: 3.3', 'Programming Language :: Python :: 3.4', 'Programming Language :: Python :: 3.5', - 'Programming Language :: Python :: 3.6', + 'Programming Language :: Python :: 3.6', 'Programming Language :: C#', 'License :: OSI Approved :: Zope Public License', 'Development Status :: 5 - Production/Stable', diff --git a/src/clrmodule/Properties/AssemblyInfo.cs b/src/clrmodule/AssemblyInfo.cs similarity index 97% rename from src/clrmodule/Properties/AssemblyInfo.cs rename to src/clrmodule/AssemblyInfo.cs index c9658c0b5..74a010d78 100644 --- a/src/clrmodule/Properties/AssemblyInfo.cs +++ b/src/clrmodule/AssemblyInfo.cs @@ -1,4 +1,4 @@ -using System.Reflection; +using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; diff --git a/src/clrmodule/ClrModule.cs b/src/clrmodule/ClrModule.cs index b90df485d..f6bf6690d 100644 --- a/src/clrmodule/ClrModule.cs +++ b/src/clrmodule/ClrModule.cs @@ -1,4 +1,4 @@ -//============================================================================ +//============================================================================ // This file replaces the hand-maintained stub that used to implement clr.dll. // This is a line-by-line port from IL back to C#. // We now use RGiesecke.DllExport on the required static init method so it can be @@ -112,4 +112,4 @@ public static void initclr() pythonEngineType.InvokeMember("InitExt", System.Reflection.BindingFlags.InvokeMethod, null, null, null); #endif } -} \ No newline at end of file +} diff --git a/src/clrmodule/clrmodule.csproj b/src/clrmodule/clrmodule.csproj index a062d3bf2..134f5997e 100644 --- a/src/clrmodule/clrmodule.csproj +++ b/src/clrmodule/clrmodule.csproj @@ -1,135 +1,134 @@ - - - - Debug - x86 - 8.0.30703 - 2.0 - {86E834DE-1139-4511-96CC-69636A56E7AC} - Library - Properties - clrmodule - clrmodule - v4.0 - 512 - ..\..\ - $(SolutionDir) - true - - - true - bin\x86\DebugMono\ - DEBUG;TRACE - full - x86 - prompt - true - true - false - - - true - bin\x64\DebugMono\ - DEBUG;TRACE - full - x64 - prompt - true - true - false - - - bin\x86\ReleaseMono\ - - - true - pdbonly - x86 - prompt - true - true - false - - - bin\x64\ReleaseMono\ - - - true - pdbonly - x64 - prompt - true - true - false - - - true - bin\x86\DebugWin\ - TRACE;DEBUG;DEBUG_PRINT - full - x86 - prompt - true - false - false - - - true - bin\x64\DebugWin\ - DEBUG;TRACE - full - x64 - prompt - true - true - false - - - bin\x86\ReleaseWin\ - - - true - pdbonly - x86 - prompt - true - true - false - - - bin\x64\ReleaseWin\ - - - true - pdbonly - x64 - prompt - true - true - false - - - - ..\..\packages\UnmanagedExports.1.2.7\lib\net\RGiesecke.DllExport.Metadata.dll - False - - - - - - - - - - - - - $(TargetPath) - $(TargetDir)$(TargetName).pdb - - - - - - - \ No newline at end of file + + + + Debug + x86 + 8.0.30703 + 2.0 + {86E834DE-1139-4511-96CC-69636A56E7AC} + Library + clrmodule + clrmodule + v4.0 + 512 + ..\..\ + $(SolutionDir) + true + + + true + bin\x86\DebugMono\ + DEBUG;TRACE + full + x86 + prompt + true + true + false + + + true + bin\x64\DebugMono\ + DEBUG;TRACE + full + x64 + prompt + true + true + false + + + bin\x86\ReleaseMono\ + + + true + pdbonly + x86 + prompt + true + true + false + + + bin\x64\ReleaseMono\ + + + true + pdbonly + x64 + prompt + true + true + false + + + true + bin\x86\DebugWin\ + TRACE;DEBUG;DEBUG_PRINT + full + x86 + prompt + true + false + false + + + true + bin\x64\DebugWin\ + DEBUG;TRACE + full + x64 + prompt + true + true + false + + + bin\x86\ReleaseWin\ + + + true + pdbonly + x86 + prompt + true + true + false + + + bin\x64\ReleaseWin\ + + + true + pdbonly + x64 + prompt + true + true + false + + + + ..\..\packages\UnmanagedExports.1.2.7\lib\net\RGiesecke.DllExport.Metadata.dll + False + + + + + + + + + + + + + $(TargetPath) + $(TargetDir)$(TargetName).pdb + + + + + + + diff --git a/src/clrmodule/packages.config b/src/clrmodule/packages.config index 03814de1e..01dd53f14 100644 --- a/src/clrmodule/packages.config +++ b/src/clrmodule/packages.config @@ -1,4 +1,4 @@ - + diff --git a/src/console/Console.csproj b/src/console/Console.csproj index 77406e6c5..bac59bcfa 100644 --- a/src/console/Console.csproj +++ b/src/console/Console.csproj @@ -1,4 +1,4 @@ - + Debug @@ -215,4 +215,4 @@ - \ No newline at end of file + diff --git a/src/console/Console.mdp b/src/console/Console.mdp deleted file mode 100644 index 45c23241d..000000000 --- a/src/console/Console.mdp +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/console/sourceforge-logo.png b/src/console/sourceforge-logo.png deleted file mode 100644 index 14c4143cc..000000000 Binary files a/src/console/sourceforge-logo.png and /dev/null differ diff --git a/src/embed_tests/Embeddingtest.VisualState.xml b/src/embed_tests/Embeddingtest.VisualState.xml deleted file mode 100644 index 4909bca42..000000000 --- a/src/embed_tests/Embeddingtest.VisualState.xml +++ /dev/null @@ -1,21 +0,0 @@ - - - [0-1000]C:\Users\Barton\Documents\Visual Studio 2008\Projects\PySharp\trunk\pythonnet\src\embed_tests\Embeddingtest.nunit - [0-1003]Python.EmbeddingTest.PyImportTest - false - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/embed_tests/Embeddingtest.nunit b/src/embed_tests/Embeddingtest.nunit index ab4a73f4e..57c999c1c 100644 --- a/src/embed_tests/Embeddingtest.nunit +++ b/src/embed_tests/Embeddingtest.nunit @@ -1,7 +1,7 @@ - + - \ No newline at end of file + diff --git a/src/embed_tests/Python.EmbeddingTest.csproj b/src/embed_tests/Python.EmbeddingTest.csproj index 80a4a9820..24645f1bd 100644 --- a/src/embed_tests/Python.EmbeddingTest.csproj +++ b/src/embed_tests/Python.EmbeddingTest.csproj @@ -1,4 +1,4 @@ - + Debug @@ -138,7 +138,7 @@ - + @@ -184,4 +184,4 @@ - \ No newline at end of file + diff --git a/src/embed_tests/packages.config b/src/embed_tests/packages.config index 163c6c929..fdc687a35 100644 --- a/src/embed_tests/packages.config +++ b/src/embed_tests/packages.config @@ -1,5 +1,5 @@ - + - \ No newline at end of file + diff --git a/src/runtime/Python.Runtime.csproj b/src/runtime/Python.Runtime.csproj index 1e54d2742..8b7cb30ef 100644 --- a/src/runtime/Python.Runtime.csproj +++ b/src/runtime/Python.Runtime.csproj @@ -1,212 +1,212 @@ - - - - Debug - x86 - {097B4AC0-74E9-4C58-BCF8-C69746EC8271} - Library - false - Python.Runtime - Python.Runtime - ..\..\ - $(SolutionDir) - - - bin\x86\ReleaseMono\ - PYTHON27, UCS4 - true - true - pdbonly - x86 - false - true - PYTHON27,UCS2 - - - bin\x64\ReleaseMono\ - PYTHON27, UCS4 - true - true - pdbonly - x64 - false - true - - - bin\x86\ReleaseWin\ - PYTHON27, UCS2 - true - true - pdbonly - x86 - false - true - - - bin\x64\ReleaseWin\ - PYTHON27, UCS2 - true - true - pdbonly - x64 - false - true - - - true - bin\x86\DebugMono\ - TRACE;DEBUG;PYTHON27,UCS4 - true - false - full - x86 - false - false - false - - - true - bin\x64\DebugMono\ - TRACE;DEBUG;PYTHON27,UCS4 - true - false - full - x64 - - - true - bin\x86\DebugWin\ - TRACE;DEBUG;PYTHON27,UCS2 - true - false - full - x86 - false - false - false - - - true - bin\x64\DebugWin\ - TRACE;DEBUG;PYTHON27,UCS2 - true - false - full - x64 - - - - - - False - ..\..\packages\MonoGAC\Mono.Posix\4.0.0.0__0738eb9f132ed756\Mono.Posix.dll - - - - - - - False - ..\..\packages\MonoGAC\Mono.Posix\4.0.0.0__0738eb9f132ed756\Mono.Posix.dll - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - clr.py - - - - - - - - $(TargetPath) - $(TargetDir)$(TargetName).pdb - - - - - - \ No newline at end of file + + + + Debug + x86 + {097B4AC0-74E9-4C58-BCF8-C69746EC8271} + Library + false + Python.Runtime + Python.Runtime + ..\..\ + $(SolutionDir) + + + bin\x86\ReleaseMono\ + PYTHON27, UCS4 + true + true + pdbonly + x86 + false + true + PYTHON27,UCS2 + + + bin\x64\ReleaseMono\ + PYTHON27, UCS4 + true + true + pdbonly + x64 + false + true + + + bin\x86\ReleaseWin\ + PYTHON27, UCS2 + true + true + pdbonly + x86 + false + true + + + bin\x64\ReleaseWin\ + PYTHON27, UCS2 + true + true + pdbonly + x64 + false + true + + + true + bin\x86\DebugMono\ + TRACE;DEBUG;PYTHON27,UCS4 + true + false + full + x86 + false + false + false + + + true + bin\x64\DebugMono\ + TRACE;DEBUG;PYTHON27,UCS4 + true + false + full + x64 + + + true + bin\x86\DebugWin\ + TRACE;DEBUG;PYTHON27,UCS2 + true + false + full + x86 + false + false + false + + + true + bin\x64\DebugWin\ + TRACE;DEBUG;PYTHON27,UCS2 + true + false + full + x64 + + + + + + False + ..\..\packages\MonoGAC\Mono.Posix\4.0.0.0__0738eb9f132ed756\Mono.Posix.dll + + + + + + + False + ..\..\packages\MonoGAC\Mono.Posix\4.0.0.0__0738eb9f132ed756\Mono.Posix.dll + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + clr.py + + + + + + + + $(TargetPath) + $(TargetDir)$(TargetName).pdb + + + + + + diff --git a/src/runtime/Python.Runtime.mdp b/src/runtime/Python.Runtime.mdp deleted file mode 100644 index 845407ec2..000000000 --- a/src/runtime/Python.Runtime.mdp +++ /dev/null @@ -1,78 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/runtime/buildclrmodule.bat b/src/runtime/buildclrmodule.bat deleted file mode 100644 index 549902d7f..000000000 --- a/src/runtime/buildclrmodule.bat +++ /dev/null @@ -1,36 +0,0 @@ -:: Call with buildclrmodule.bat - -@echo off - -set TARGET_PLATFORM=%1 -set INPUT_DIRECTORY=%~2 -set INPUT_PATH="%INPUT_DIRECTORY%\clrmodule.il" -set OUTPUT_PATH=%3 - -if %TARGET_PLATFORM%==x86 goto SETUP32 -if %TARGET_PLATFORM%==x64 goto SETUP64 -goto ERROR_BAD_PLATFORM - -:SETUP32 -set INCLUDE_PATH="%INPUT_DIRECTORY%\x86" -goto BUILD_CLR_MODULE - -:SETUP64 -set INCLUDE_PATH="%INPUT_DIRECTORY%\x64" -set ILASM_EXTRA_ARGS=/pe64 /x64 -goto BUILD_CLR_MODULE - -:ERROR_BAD_PLATFORM -echo Unknown target platform: %TARGET_PLATFORM% -exit /b 1 - -:ERROR_MISSING_INPUT -echo Can't find input file: %INPUT_PATH% -exit /b 1 - -:BUILD_CLR_MODULE -if not exist %INPUT_PATH% goto ERROR_MISSING_INPUT -%windir%\Microsoft.NET\Framework\v4.0.30319\ilasm /nologo /quiet /dll %ILASM_EXTRA_ARGS% /include=%INCLUDE_PATH% /output=%OUTPUT_PATH% %INPUT_PATH% - -::: 2.0 or 3.5 -:::%windir%\Microsoft.NET\Framework\v2.0.50727\ilasm /nologo /quiet /dll %ILASM_EXTRA_ARGS% /include=%INCLUDE_PATH% /output=%OUTPUT_PATH% %INPUT_PATH% diff --git a/src/runtime/classderived.cs b/src/runtime/classderived.cs index 6a35d5497..02d734c26 100644 --- a/src/runtime/classderived.cs +++ b/src/runtime/classderived.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.IO; using System.Reflection; using System.Reflection.Emit; @@ -860,4 +860,4 @@ public static void Finalize(IPythonDerivedType obj) }); } } -} \ No newline at end of file +} diff --git a/src/runtime/clrmodule.il b/src/runtime/clrmodule.il deleted file mode 100644 index fb312b1b5..000000000 --- a/src/runtime/clrmodule.il +++ /dev/null @@ -1,297 +0,0 @@ - -//============================================================================ -// This file is a hand-maintained stub - it implements clr.dll, which can be -// loaded by a standard CPython interpreter (on Windows) as an extension module. -// When it is loaded, it bootstraps the managed runtime integration layer and defers -// to it to do initialization and put the clr module into sys.modules, etc. - -// The "USE_PYTHON_RUNTIME_*" defines control what extra evidence is used -// to help the CLR find the appropriate Python.Runtime assembly. - -// If defined, the "pythonRuntimeVersionString" variable must be set to -// Python.Runtime's current version. -#define USE_PYTHON_RUNTIME_VERSION - -// If defined, the "PythonRuntimePublicKeyTokenData" data array must be -// set to Python.Runtime's public key token. (sn -T Python.Runtin.dll) -#define USE_PYTHON_RUNTIME_PUBLIC_KEY_TOKEN - -// If DEBUG_PRINT is defined, a few System.Console.WriteLine calls are made -// to indicate what's going on during the load... -//#define DEBUG_PRINT -//============================================================================ - -.assembly extern mscorlib -{ - .publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) - .ver 4:0:0:0 -} - -.assembly extern mscorlib -{ - .publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) - .ver 2:0:0:0 -} - -.assembly clr -{ - .hash algorithm 0x00008004 - .ver 4:0:0:1 -} - -.module clr.dll -.imagebase 0x00400000 -.subsystem 0x00000003 -.file alignment 512 - -#ifdef USE_PYTHON_RUNTIME_PUBLIC_KEY_TOKEN -.data PythonRuntimePublicKeyTokenData = bytearray (50 00 fe a6 cb a7 02 dd) -//.data PythonRuntimePublicKeyTokenData = bytearray (64 e1 4e 84 5a bf 2e 60) -#endif - -// This includes the platform-specific IL. The include search path -// is set depending on whether we're compiling 32 or 64 bit. -// This MUST come before any other .data directives! -// Why, oh why, can't ilasm support command line #defines? :( -// - -//#include "clrmodule-platform.il" - -// From the manifest as seen by ildasm -//%windir%\Microsoft.NET\Framework\v4.0.30319\ilasm /dll /pe64 /x64 clrmodule.il -//.corflags 0x00000000 -// Image base: 0x01550000 -// .vtfixup [1] int64 fromunmanaged at D_00004008 // 0000000006000002 - -//%windir%\Microsoft.NET\Framework\v4.0.30319\ilasm /dll clrmodule.il -// .vtfixup [1] int32 fromunmanaged at D_00004008 // 06000002 -//.corflags 0x00000002 // 32BITREQUIRED -// Image base: 0x015A0000 - -// With or without /pe64 /x64 switches. -//{ -// .vtentry 1 : 1 -// .export [1] as initclr -// ... } - - -.class public auto ansi beforefieldinit clrModule extends [mscorlib]System.Object -{ -#ifdef USE_PYTHON_RUNTIME_PUBLIC_KEY_TOKEN - .field static assembly int64 PythonRuntimePublicKeyToken at PythonRuntimePublicKeyTokenData -#endif - - .method public hidebysig specialname rtspecialname instance void - .ctor() cil managed - { - .maxstack 1 - ldarg.0 - call instance void [mscorlib]System.Object::.ctor() - ret - } - - .method public hidebysig static void modopt([mscorlib]System.Runtime.CompilerServices.CallConvCdecl) - initclr() cil managed - { -// .vtentry 1:1 - .export [1] as initclr - - .maxstack 6 - .locals init ( - class [mscorlib]System.Reflection.Assembly pythonRuntime, - class [mscorlib]System.Reflection.Assembly executingAssembly, - class [mscorlib]System.Reflection.AssemblyName pythonRuntimeName, - class [mscorlib]System.Type pythonEngineType, - int8[] publicKeyToken, - string assemblyDirectory, - string pythonRuntimeVersionString, - string pythonRuntimeDllPath) - - // pythonRuntime = null; - ldnull - stloc pythonRuntime - - .try - { -#ifdef DEBUG_PRINT - ldstr "Attempting to load Python.Runtime using standard binding rules... " - call void [mscorlib]System.Console::Write(string) -#endif - - // Attempt to find and load Python.Runtime using standard assembly binding rules. - // This roughly translates into looking in order: - // - GAC - // - ApplicationBase - // - A PrivateBinPath under ApplicationBase - // With an unsigned assembly, the GAC is skipped. - - // System.Reflection.AssemblyName pythonRuntimeName = new System.Reflection.AssemblyName(); - newobj instance void [mscorlib]System.Reflection.AssemblyName::.ctor() - stloc pythonRuntimeName - - // pythonRuntimeName.Name = "Python.Runtime"; - ldloc pythonRuntimeName - ldstr "Python.Runtime" - callvirt instance void [mscorlib]System.Reflection.AssemblyName::set_Name(string) - -#ifdef USE_PYTHON_RUNTIME_VERSION - // pythonRuntimeVersionString = "..."; - ldstr "4.0.0.1" - stloc pythonRuntimeVersionString - - // pythonRuntimeName.Version = new Version(pythonRuntimeVersionString); - ldloc pythonRuntimeName - ldloc pythonRuntimeVersionString - newobj instance void [mscorlib]System.Version::.ctor(string) - callvirt instance void [mscorlib]System.Reflection.AssemblyName::set_Version(class [mscorlib]System.Version) -#endif - -#ifdef USE_PYTHON_RUNTIME_PUBLIC_KEY_TOKEN - // publicKeyToken = new byte[] { ... }; - ldc.i4.8 - newarr [mscorlib]System.Byte - dup - ldtoken field int64 clrModule::PythonRuntimePublicKeyToken - call void [mscorlib]System.Runtime.CompilerServices.RuntimeHelpers::InitializeArray(class [mscorlib]System.Array, valuetype [mscorlib]System.RuntimeFieldHandle) - stloc publicKeyToken - - // pythonRuntimeName.SetPublicKeyToken(publicKeyToken); - ldloc pythonRuntimeName - ldloc publicKeyToken - callvirt instance void [mscorlib]System.Reflection.AssemblyName::SetPublicKeyToken(uint8[]) -#endif - - // pythonRuntimeName.CultureInfo = System.Globalization.CultureInfo.InvariantCulture; - ldloc pythonRuntimeName - call class [mscorlib]System.Globalization.CultureInfo [mscorlib]System.Globalization.CultureInfo::get_InvariantCulture() - callvirt instance void [mscorlib]System.Reflection.AssemblyName::set_CultureInfo(class [mscorlib]System.Globalization.CultureInfo) - - // return System.Reflection.Assembly.Load(pythonRuntimeName); - ldloc pythonRuntimeName - call class [mscorlib]System.Reflection.Assembly [mscorlib]System.Reflection.Assembly::Load(class [mscorlib]System.Reflection.AssemblyName) - stloc pythonRuntime - -#ifdef DEBUG_PRINT - ldstr "Success!" - call void [mscorlib]System.Console::WriteLine(string) -#endif - leave.s LOADED_PYTHON_RUNTIME - } - catch [mscorlib]System.Object - { -#ifdef DEBUG_PRINT - ldstr "Failed." - call void [mscorlib]System.Console::WriteLine(string) -#endif - leave.s EXIT_CLR_LOAD - } - EXIT_CLR_LOAD: nop - - .try - { - // If the above fails for any reason, we fallback to attempting to load "Python.Runtime.dll" - // from the directory this assembly is running in. "This assembly" is probably "clr.pyd", - // sitting somewhere in PYTHONPATH. This is using Assembly.LoadFrom, and inherits all the - // caveats of that call. See MSDN docs for details. - // Suzanne Cook's blog is also an excellent source of info on this: - // http://blogs.msdn.com/suzcook/ - // http://blogs.msdn.com/suzcook/archive/2003/05/29/57143.aspx - // http://blogs.msdn.com/suzcook/archive/2003/06/13/57180.aspx - // executingAssembly = System.Reflection.Assembly.GetExecutingAssembly(); - call class [mscorlib]System.Reflection.Assembly [mscorlib]System.Reflection.Assembly::GetExecutingAssembly() - stloc executingAssembly - - // assemblyDirectory = System.IO.Path.GetDirectoryName(executingAssembly.Location); - ldloc executingAssembly - callvirt instance string [mscorlib]System.Reflection.Assembly::get_Location() - call string [mscorlib]System.IO.Path::GetDirectoryName(string) - stloc assemblyDirectory - - // pythonRuntimeDllPath = System.IO.Path.Combine(assemblyDirectory, "Python.Runtime.dll"); - ldloc assemblyDirectory - ldstr "Python.Runtime.dll" - call string [mscorlib]System.IO.Path::Combine(string, string) - stloc pythonRuntimeDllPath - -#ifdef DEBUG_PRINT - ldstr "Attempting to load Python.Runtime from: '{0}'... " - ldloc pythonRuntimeDllPath - call void [mscorlib]System.Console::Write(string, object) -#endif - - // pythonRuntime = System.Reflection.Assembly.LoadFrom(pythonRuntimeDllPath); - ldloc pythonRuntimeDllPath - call class [mscorlib]System.Reflection.Assembly [mscorlib]System.Reflection.Assembly::LoadFrom(string) - stloc pythonRuntime - -#ifdef DEBUG_PRINT - ldstr "Success!" - call void [mscorlib]System.Console::WriteLine(string) - - ldloc pythonRuntime - callvirt instance string [mscorlib]System.Reflection.Assembly::get_CodeBase() - call void [mscorlib]System.Console::WriteLine(string) -#endif - leave.s LOADED_PYTHON_RUNTIME - } - catch [mscorlib]System.Object - { -#ifdef DEBUG_PRINT - ldstr "Failed." - call void [mscorlib]System.Console::WriteLine(string) -#endif - leave.s EXIT_PYTHONPATH_LOAD - } - EXIT_PYTHONPATH_LOAD: nop - - // If we get here, we haven't loaded Python.Runtime, so bail. -#ifdef DEBUG_PRINT - ldstr "Could not load Python.Runtime, so sad." - call void [mscorlib]System.Console::WriteLine(string) -#endif - ret; - - // Once here, we've successfully loaded SOME version of Python.Runtime - // So now we get the PythonEngine and execute the InitExt method on it. - LOADED_PYTHON_RUNTIME: nop - .try - { -#ifdef DEBUG_PRINT - ldstr "Running Python.Runtime.PythonEngine.InitExt()" - call void [mscorlib]System.Console::WriteLine(string) -#endif - // pythonEngineType = pythonRuntime.GetType("Python.Runtime.PythonEngine"); - ldloc pythonRuntime - ldstr "Python.Runtime.PythonEngine" - callvirt instance class [mscorlib]System.Type [mscorlib]System.Reflection.Assembly::GetType(string) - stloc pythonEngineType - - // pythonEngineType.InvokeMember("InitExt", System.Reflection.BindingFlags.InvokeMethod, null, null, null); - ldloc pythonEngineType - ldstr "InitExt" - ldc.i4 0x100 - ldnull - ldnull - ldnull - callvirt instance object [mscorlib]System.Type::InvokeMember( string, - valuetype [mscorlib]System.Reflection.BindingFlags, - class [mscorlib]System.Reflection.Binder, - object, - object[]) - pop - leave.s EXIT_TRY_INVOKE - } - catch [mscorlib]System.Object - { -#ifdef DEBUG_PRINT - ldstr "Error calling Python.Runtime.PythonEngine.InitExt()." - call void [mscorlib]System.Console::WriteLine(string) -#endif - leave.s EXIT_TRY_INVOKE - } - EXIT_TRY_INVOKE: nop - - ret - } -} - diff --git a/src/runtime/clrmodule.pp.il b/src/runtime/clrmodule.pp.il deleted file mode 100644 index 27eb78432..000000000 --- a/src/runtime/clrmodule.pp.il +++ /dev/null @@ -1,271 +0,0 @@ - -//============================================================================ -// This file is a hand-maintained stub - it implements clr.dll, which can be -// loaded by a standard CPython interpreter as an extension module. When it -// is loaded, it bootstraps the managed runtime integration layer and defers -// to it to do initialization and put the clr module into sys.modules, etc. - -// The "USE_PYTHON_RUNTIME_*" defines control what extra evidence is used -// to help the CLR find the appropriate Python.Runtime assembly. - -// If defined, the "pythonRuntimeVersionString" variable must be set to -// Python.Runtime's current version. -#define USE_PYTHON_RUNTIME_VERSION - -// If defined, the "PythonRuntimePublicKeyTokenData" data array must be -// set to Python.Runtime's public key token. -//#define USE_PYTHON_RUNTIME_PUBLIC_KEY_TOKEN - -// If DEBUG_PRINT is defined, a few System.Console.WriteLine calls are made -// to indicate what's going on during the load... -//#define DEBUG_PRINT -//============================================================================ - -.assembly extern mscorlib -{ - .publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) - .ver 2:0:0:0 -} - -.assembly clr -{ - .hash algorithm 0x00008004 - .ver 2:0:0:2 -} - -.module clr.dll -.imagebase 0x00400000 -.subsystem 0x00000003 -.file alignment 512 - -// This includes the platform-specific IL. The include search path -// is set depending on whether we're compiling 32 or 64 bit. -// This MUST come before any other .data directives! -// Why, oh why, can't ilasm support command line #defines? :( - -// Contributed by VIKAS DHIMAN - Handled by /home/barton/Projects/PyDotNet/pythonnet/makefile -// gcc -C -P -x c++ -I $(ARCH) clrmodule.pp.il -o clrmodule.il -// to copy the correct architecture to the clrModule. -// Nice formating, as well - Thanks, Vikas! -#include "clrmodule-platform.il" - -#ifdef USE_PYTHON_RUNTIME_PUBLIC_KEY_TOKEN -.data PythonRuntimePublicKeyTokenData = bytearray (64 e1 4e 84 5a bf 2e 60) -#endif - -.class public auto ansi beforefieldinit clrModule extends [mscorlib]System.Object -{ -#ifdef USE_PYTHON_RUNTIME_PUBLIC_KEY_TOKEN - .field static assembly int64 PythonRuntimePublicKeyToken at PythonRuntimePublicKeyTokenData -#endif - - .method public hidebysig specialname rtspecialname instance void - .ctor() cil managed - { - .maxstack 1 - ldarg.0 - call instance void [mscorlib]System.Object::.ctor() - ret - } - - .method public hidebysig static void modopt([mscorlib]System.Runtime.CompilerServices.CallConvCdecl) - initclr() cil managed - { - .vtentry 1:1 - .export [1] as initclr - - .maxstack 6 - .locals init ( - class [mscorlib]System.Reflection.Assembly pythonRuntime, - class [mscorlib]System.Reflection.Assembly executingAssembly, - class [mscorlib]System.Reflection.AssemblyName pythonRuntimeName, - class [mscorlib]System.Type pythonEngineType, - int8[] publicKeyToken, - string assemblyDirectory, - string pythonRuntimeVersionString, - string pythonRuntimeDllPath) - - // pythonRuntime = null; - ldnull - stloc pythonRuntime - - .try - { -#ifdef DEBUG_PRINT - ldstr "Attempting to load Python.Runtime using standard binding rules... " - call void [mscorlib]System.Console::Write(string) -#endif - - // Attempt to find and load Python.Runtime using standard assembly binding rules. - // This roughly translates into looking in order: - // - GAC - // - ApplicationBase - // - A PrivateBinPath under ApplicationBase - // With an unsigned assembly, the GAC is skipped. - - // System.Reflection.AssemblyName pythonRuntimeName = new System.Reflection.AssemblyName(); - newobj instance void [mscorlib]System.Reflection.AssemblyName::.ctor() - stloc pythonRuntimeName - - // pythonRuntimeName.Name = "Python.Runtime"; - ldloc pythonRuntimeName - ldstr "Python.Runtime" - callvirt instance void [mscorlib]System.Reflection.AssemblyName::set_Name(string) - -#ifdef USE_PYTHON_RUNTIME_VERSION - // pythonRuntimeVersionString = "..."; - ldstr "2.0.0.2" - stloc pythonRuntimeVersionString - - // pythonRuntimeName.Version = new Version(pythonRuntimeVersionString); - ldloc pythonRuntimeName - ldloc pythonRuntimeVersionString - newobj instance void [mscorlib]System.Version::.ctor(string) - callvirt instance void [mscorlib]System.Reflection.AssemblyName::set_Version(class [mscorlib]System.Version) -#endif - -#ifdef USE_PYTHON_RUNTIME_PUBLIC_KEY_TOKEN - // publicKeyToken = new byte[] { ... }; - ldc.i4.8 - newarr [mscorlib]System.Byte - dup - ldtoken field int64 clrModule::PythonRuntimePublicKeyToken - call void [mscorlib]System.Runtime.CompilerServices.RuntimeHelpers::InitializeArray(class [mscorlib]System.Array, valuetype [mscorlib]System.RuntimeFieldHandle) - stloc publicKeyToken - - // pythonRuntimeName.SetPublicKeyToken(publicKeyToken); - ldloc pythonRuntimeName - ldloc publicKeyToken - callvirt instance void [mscorlib]System.Reflection.AssemblyName::SetPublicKeyToken(uint8[]) -#endif - - // pythonRuntimeName.CultureInfo = System.Globalization.CultureInfo.InvariantCulture; - ldloc pythonRuntimeName - call class [mscorlib]System.Globalization.CultureInfo [mscorlib]System.Globalization.CultureInfo::get_InvariantCulture() - callvirt instance void [mscorlib]System.Reflection.AssemblyName::set_CultureInfo(class [mscorlib]System.Globalization.CultureInfo) - - // return System.Reflection.Assembly.Load(pythonRuntimeName); - ldloc pythonRuntimeName - call class [mscorlib]System.Reflection.Assembly [mscorlib]System.Reflection.Assembly::Load(class [mscorlib]System.Reflection.AssemblyName) - stloc pythonRuntime - -#ifdef DEBUG_PRINT - ldstr "Success!" - call void [mscorlib]System.Console::WriteLine(string) -#endif - leave.s LOADED_PYTHON_RUNTIME - } - catch [mscorlib]System.Object - { -#ifdef DEBUG_PRINT - ldstr "Failed." - call void [mscorlib]System.Console::WriteLine(string) -#endif - leave.s EXIT_CLR_LOAD - } - EXIT_CLR_LOAD: nop - - .try - { - // If the above fails for any reason, we fallback to attempting to load "Python.Runtime.dll" - // from the directory this assembly is running in. "This assembly" is probably "clr.pyd", - // sitting somewhere in PYTHONPATH. This is using Assembly.LoadFrom, and inherits all the - // caveats of that call. See MSDN docs for details. - // Suzanne Cook's blog is also an excellent source of info on this: - // http://blogs.msdn.com/suzcook/ - // http://blogs.msdn.com/suzcook/archive/2003/05/29/57143.aspx - // http://blogs.msdn.com/suzcook/archive/2003/06/13/57180.aspx - // executingAssembly = System.Reflection.Assembly.GetExecutingAssembly(); - call class [mscorlib]System.Reflection.Assembly [mscorlib]System.Reflection.Assembly::GetExecutingAssembly() - stloc executingAssembly - - // assemblyDirectory = System.IO.Path.GetDirectoryName(executingAssembly.Location); - ldloc executingAssembly - callvirt instance string [mscorlib]System.Reflection.Assembly::get_Location() - call string [mscorlib]System.IO.Path::GetDirectoryName(string) - stloc assemblyDirectory - - // pythonRuntimeDllPath = System.IO.Path.Combine(assemblyDirectory, "Python.Runtime.dll"); - ldloc assemblyDirectory - ldstr "Python.Runtime.dll" - call string [mscorlib]System.IO.Path::Combine(string, string) - stloc pythonRuntimeDllPath - -#ifdef DEBUG_PRINT - ldstr "Attempting to load Python.Runtime from: '{0}'... " - ldloc pythonRuntimeDllPath - call void [mscorlib]System.Console::Write(string, object) -#endif - - // pythonRuntime = System.Reflection.Assembly.LoadFrom(pythonRuntimeDllPath); - ldloc pythonRuntimeDllPath - call class [mscorlib]System.Reflection.Assembly [mscorlib]System.Reflection.Assembly::LoadFrom(string) - stloc pythonRuntime - -#ifdef DEBUG_PRINT - ldstr "Success!" - call void [mscorlib]System.Console::WriteLine(string) -#endif - leave.s LOADED_PYTHON_RUNTIME - } - catch [mscorlib]System.Object - { -#ifdef DEBUG_PRINT - ldstr "Failed." - call void [mscorlib]System.Console::WriteLine(string) -#endif - leave.s EXIT_PYTHONPATH_LOAD - } - EXIT_PYTHONPATH_LOAD: nop - - // If we get here, we haven't loaded Python.Runtime, so bail. -#ifdef DEBUG_PRINT - ldstr "Could not load Python.Runtime, so sad." - call void [mscorlib]System.Console::WriteLine(string) -#endif - ret - - // Once here, we've successfully loaded SOME version of Python.Runtime - // So now we get the PythonEngine and execute the InitExt method on it. - LOADED_PYTHON_RUNTIME: nop - .try - { -#ifdef DEBUG_PRINT - ldstr "Running Python.Runtime.PythonEngine.InitExt()" - call void [mscorlib]System.Console::WriteLine(string) -#endif - // pythonEngineType = pythonRuntime.GetType("Python.Runtime.PythonEngine"); - ldloc pythonRuntime - ldstr "Python.Runtime.PythonEngine" - callvirt instance class [mscorlib]System.Type [mscorlib]System.Reflection.Assembly::GetType(string) - stloc pythonEngineType - - // pythonEngineType.InvokeMember("InitExt", System.Reflection.BindingFlags.InvokeMethod, null, null, null); - ldloc pythonEngineType - ldstr "InitExt" - ldc.i4 0x100 - ldnull - ldnull - ldnull - callvirt instance object [mscorlib]System.Type::InvokeMember( string, - valuetype [mscorlib]System.Reflection.BindingFlags, - class [mscorlib]System.Reflection.Binder, - object, - object[]) - pop - leave.s EXIT_TRY_INVOKE - } - catch [mscorlib]System.Object - { -#ifdef DEBUG_PRINT - ldstr "Error calling Python.Runtime.PythonEngine.InitExt()." - call void [mscorlib]System.Console::WriteLine(string) -#endif - leave.s EXIT_TRY_INVOKE - } - EXIT_TRY_INVOKE: nop - - ret - } -} - diff --git a/src/runtime/constructorbinding.cs b/src/runtime/constructorbinding.cs index e2eda0685..8710f53bf 100644 --- a/src/runtime/constructorbinding.cs +++ b/src/runtime/constructorbinding.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Reflection; namespace Python.Runtime @@ -241,4 +241,4 @@ public static IntPtr tp_repr(IntPtr ob) ExtensionType.FinalizeObject(self); } } -} \ No newline at end of file +} diff --git a/src/runtime/interop33.cs b/src/runtime/interop33.cs index 88e9022e4..27a7fe982 100644 --- a/src/runtime/interop33.cs +++ b/src/runtime/interop33.cs @@ -2,6 +2,7 @@ // Auto-generated by geninterop.py. // DO NOT MODIFIY BY HAND. +#if (PYTHON33) using System; using System.Collections; using System.Collections.Specialized; @@ -135,3 +136,4 @@ public static int magic() { public static int members = 0; } } +#endif diff --git a/src/runtime/oldmodule.il b/src/runtime/oldmodule.il deleted file mode 100644 index b9e3883c9..000000000 --- a/src/runtime/oldmodule.il +++ /dev/null @@ -1,266 +0,0 @@ - -//============================================================================ -// This file is a hand-maintained stub - it implements clr.dll, which can be -// loaded by a standard CPython interpreter as an extension module. When it -// is loaded, it bootstraps the managed runtime integration layer and defers -// to it to do initialization and put the clr module into sys.modules, etc. - -// The "USE_PYTHON_RUNTIME_*" defines control what extra evidence is used -// to help the CLR find the appropriate Python.Runtime assembly. - -// If defined, the "pythonRuntimeVersionString" variable must be set to -// Python.Runtime's current version. -#define USE_PYTHON_RUNTIME_VERSION - -// If defined, the "PythonRuntimePublicKeyTokenData" data array must be -// set to Python.Runtime's public key token. -//#define USE_PYTHON_RUNTIME_PUBLIC_KEY_TOKEN - -// If DEBUG_PRINT is defined, a few System.Console.WriteLine calls are made -// to indicate what's going on during the load... -//#define DEBUG_PRINT -//============================================================================ - -.assembly extern mscorlib -{ - .publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) - .ver 2:0:0:0 -} - -.assembly clr -{ - .hash algorithm 0x00008004 - .ver 2:0:0:2 -} - -.module clr.dll -.imagebase 0x00400000 -.subsystem 0x00000003 -.file alignment 512 - -// This includes the platform-specific IL. The include search path -// is set depending on whether we're compiling 32 or 64 bit. -// This MUST come before any other .data directives! -// Why, oh why, can't ilasm support command line #defines? :( -#include "clrmodule-platform.il" - -#ifdef USE_PYTHON_RUNTIME_PUBLIC_KEY_TOKEN -.data PythonRuntimePublicKeyTokenData = bytearray (64 e1 4e 84 5a bf 2e 60) -#endif - -.class public auto ansi beforefieldinit clrModule extends [mscorlib]System.Object -{ -#ifdef USE_PYTHON_RUNTIME_PUBLIC_KEY_TOKEN - .field static assembly int64 PythonRuntimePublicKeyToken at PythonRuntimePublicKeyTokenData -#endif - - .method public hidebysig specialname rtspecialname instance void - .ctor() cil managed - { - .maxstack 1 - ldarg.0 - call instance void [mscorlib]System.Object::.ctor() - ret - } - - .method public hidebysig static void modopt([mscorlib]System.Runtime.CompilerServices.CallConvCdecl) - initclr() cil managed - { - .vtentry 1:1 - .export [1] as initclr - - .maxstack 6 - .locals init ( - class [mscorlib]System.Reflection.Assembly pythonRuntime, - class [mscorlib]System.Reflection.Assembly executingAssembly, - class [mscorlib]System.Reflection.AssemblyName pythonRuntimeName, - class [mscorlib]System.Type pythonEngineType, - int8[] publicKeyToken, - string assemblyDirectory, - string pythonRuntimeVersionString, - string pythonRuntimeDllPath) - - // pythonRuntime = null; - ldnull - stloc pythonRuntime - - .try - { -#ifdef DEBUG_PRINT - ldstr "Attempting to load Python.Runtime using standard binding rules... " - call void [mscorlib]System.Console::Write(string) -#endif - - // Attempt to find and load Python.Runtime using standard assembly binding rules. - // This roughly translates into looking in order: - // - GAC - // - ApplicationBase - // - A PrivateBinPath under ApplicationBase - // With an unsigned assembly, the GAC is skipped. - - // System.Reflection.AssemblyName pythonRuntimeName = new System.Reflection.AssemblyName(); - newobj instance void [mscorlib]System.Reflection.AssemblyName::.ctor() - stloc pythonRuntimeName - - // pythonRuntimeName.Name = "Python.Runtime"; - ldloc pythonRuntimeName - ldstr "Python.Runtime" - callvirt instance void [mscorlib]System.Reflection.AssemblyName::set_Name(string) - -#ifdef USE_PYTHON_RUNTIME_VERSION - // pythonRuntimeVersionString = "..."; - ldstr "2.0.0.2" - stloc pythonRuntimeVersionString - - // pythonRuntimeName.Version = new Version(pythonRuntimeVersionString); - ldloc pythonRuntimeName - ldloc pythonRuntimeVersionString - newobj instance void [mscorlib]System.Version::.ctor(string) - callvirt instance void [mscorlib]System.Reflection.AssemblyName::set_Version(class [mscorlib]System.Version) -#endif - -#ifdef USE_PYTHON_RUNTIME_PUBLIC_KEY_TOKEN - // publicKeyToken = new byte[] { ... }; - ldc.i4.8 - newarr [mscorlib]System.Byte - dup - ldtoken field int64 clrModule::PythonRuntimePublicKeyToken - call void [mscorlib]System.Runtime.CompilerServices.RuntimeHelpers::InitializeArray(class [mscorlib]System.Array, valuetype [mscorlib]System.RuntimeFieldHandle) - stloc publicKeyToken - - // pythonRuntimeName.SetPublicKeyToken(publicKeyToken); - ldloc pythonRuntimeName - ldloc publicKeyToken - callvirt instance void [mscorlib]System.Reflection.AssemblyName::SetPublicKeyToken(uint8[]) -#endif - - // pythonRuntimeName.CultureInfo = System.Globalization.CultureInfo.InvariantCulture; - ldloc pythonRuntimeName - call class [mscorlib]System.Globalization.CultureInfo [mscorlib]System.Globalization.CultureInfo::get_InvariantCulture() - callvirt instance void [mscorlib]System.Reflection.AssemblyName::set_CultureInfo(class [mscorlib]System.Globalization.CultureInfo) - - // return System.Reflection.Assembly.Load(pythonRuntimeName); - ldloc pythonRuntimeName - call class [mscorlib]System.Reflection.Assembly [mscorlib]System.Reflection.Assembly::Load(class [mscorlib]System.Reflection.AssemblyName) - stloc pythonRuntime - -#ifdef DEBUG_PRINT - ldstr "Success!" - call void [mscorlib]System.Console::WriteLine(string) -#endif - leave.s LOADED_PYTHON_RUNTIME - } - catch [mscorlib]System.Object - { -#ifdef DEBUG_PRINT - ldstr "Failed." - call void [mscorlib]System.Console::WriteLine(string) -#endif - leave.s EXIT_CLR_LOAD - } - EXIT_CLR_LOAD: nop - - .try - { - // If the above fails for any reason, we fallback to attempting to load "Python.Runtime.dll" - // from the directory this assembly is running in. "This assembly" is probably "clr.pyd", - // sitting somewhere in PYTHONPATH. This is using Assembly.LoadFrom, and inherits all the - // caveats of that call. See MSDN docs for details. - // Suzanne Cook's blog is also an excellent source of info on this: - // http://blogs.msdn.com/suzcook/ - // http://blogs.msdn.com/suzcook/archive/2003/05/29/57143.aspx - // http://blogs.msdn.com/suzcook/archive/2003/06/13/57180.aspx - // executingAssembly = System.Reflection.Assembly.GetExecutingAssembly(); - call class [mscorlib]System.Reflection.Assembly [mscorlib]System.Reflection.Assembly::GetExecutingAssembly() - stloc executingAssembly - - // assemblyDirectory = System.IO.Path.GetDirectoryName(executingAssembly.Location); - ldloc executingAssembly - callvirt instance string [mscorlib]System.Reflection.Assembly::get_Location() - call string [mscorlib]System.IO.Path::GetDirectoryName(string) - stloc assemblyDirectory - - // pythonRuntimeDllPath = System.IO.Path.Combine(assemblyDirectory, "Python.Runtime.dll"); - ldloc assemblyDirectory - ldstr "Python.Runtime.dll" - call string [mscorlib]System.IO.Path::Combine(string, string) - stloc pythonRuntimeDllPath - -#ifdef DEBUG_PRINT - ldstr "Attempting to load Python.Runtime from: '{0}'... " - ldloc pythonRuntimeDllPath - call void [mscorlib]System.Console::Write(string, object) -#endif - - // pythonRuntime = System.Reflection.Assembly.LoadFrom(pythonRuntimeDllPath); - ldloc pythonRuntimeDllPath - call class [mscorlib]System.Reflection.Assembly [mscorlib]System.Reflection.Assembly::LoadFrom(string) - stloc pythonRuntime - -#ifdef DEBUG_PRINT - ldstr "Success!" - call void [mscorlib]System.Console::WriteLine(string) -#endif - leave.s LOADED_PYTHON_RUNTIME - } - catch [mscorlib]System.Object - { -#ifdef DEBUG_PRINT - ldstr "Failed." - call void [mscorlib]System.Console::WriteLine(string) -#endif - leave.s EXIT_PYTHONPATH_LOAD - } - EXIT_PYTHONPATH_LOAD: nop - - // If we get here, we haven't loaded Python.Runtime, so bail. -#ifdef DEBUG_PRINT - ldstr "Could not load Python.Runtime, so sad." - call void [mscorlib]System.Console::WriteLine(string) -#endif - ret; - - // Once here, we've successfully loaded SOME version of Python.Runtime - // So now we get the PythonEngine and execute the InitExt method on it. - LOADED_PYTHON_RUNTIME: nop - .try - { -#ifdef DEBUG_PRINT - ldstr "Running Python.Runtime.PythonEngine.InitExt()" - call void [mscorlib]System.Console::WriteLine(string) -#endif - // pythonEngineType = pythonRuntime.GetType("Python.Runtime.PythonEngine"); - ldloc pythonRuntime - ldstr "Python.Runtime.PythonEngine" - callvirt instance class [mscorlib]System.Type [mscorlib]System.Reflection.Assembly::GetType(string) - stloc pythonEngineType - - // pythonEngineType.InvokeMember("InitExt", System.Reflection.BindingFlags.InvokeMethod, null, null, null); - ldloc pythonEngineType - ldstr "InitExt" - ldc.i4 0x100 - ldnull - ldnull - ldnull - callvirt instance object [mscorlib]System.Type::InvokeMember( string, - valuetype [mscorlib]System.Reflection.BindingFlags, - class [mscorlib]System.Reflection.Binder, - object, - object[]) - pop - leave.s EXIT_TRY_INVOKE - } - catch [mscorlib]System.Object - { -#ifdef DEBUG_PRINT - ldstr "Error calling Python.Runtime.PythonEngine.InitExt()." - call void [mscorlib]System.Console::WriteLine(string) -#endif - leave.s EXIT_TRY_INVOKE - } - EXIT_TRY_INVOKE: nop - - ret - } -} - diff --git a/src/testing/Python.Test.csproj b/src/testing/Python.Test.csproj index a0d62d4f9..4566aeccf 100644 --- a/src/testing/Python.Test.csproj +++ b/src/testing/Python.Test.csproj @@ -1,4 +1,4 @@ - + Debug @@ -154,4 +154,4 @@ - \ No newline at end of file + diff --git a/src/testing/Python.Test.mdp b/src/testing/Python.Test.mdp deleted file mode 100644 index e8ab5d5cf..000000000 --- a/src/testing/Python.Test.mdp +++ /dev/null @@ -1,40 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/testing/callbacktest.cs b/src/testing/callbacktest.cs index 70c7bbc9e..f95cbc602 100644 --- a/src/testing/callbacktest.cs +++ b/src/testing/callbacktest.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Linq; using System.Text; diff --git a/src/testing/moduletest.cs b/src/testing/moduletest.cs index 8734f2569..ca75a1313 100644 --- a/src/testing/moduletest.cs +++ b/src/testing/moduletest.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Threading; namespace Python.Test { @@ -22,4 +22,4 @@ public static void JoinThreads() _thread.Join(); } } -} \ No newline at end of file +} diff --git a/src/testing/subclasstest.cs b/src/testing/subclasstest.cs index 4fd271fa7..2b61be254 100644 --- a/src/testing/subclasstest.cs +++ b/src/testing/subclasstest.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -114,4 +114,4 @@ public static int test_event(IInterfaceTest x, int value) return et.value; } } -} \ No newline at end of file +} diff --git a/src/tests/test_constructors.py b/src/tests/test_constructors.py index fdc1ef060..6e02528bb 100644 --- a/src/tests/test_constructors.py +++ b/src/tests/test_constructors.py @@ -44,7 +44,6 @@ class sub(System.Exception): instance = sub() ob = SubclassConstructorTest(instance) - print(ob) self.assertTrue(isinstance(ob.value, System.Exception))