Skip to content

fixed assembly load with full path, + post-build script #102

New issue

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

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

Already on GitHub? Sign in to your account

Closed
wants to merge 10 commits into from
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
*.suo
*.pdb
[Oo]bj/
[Bb]in/
*.dll
*.pyd
*.exe
*.pyc
packages/*
dist
pythonnet.egg-info
*.userprefs
18 changes: 18 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
language: python
python:
- 2.6
- 2.7
before_install:
- sudo apt-get install software-properties-common
- sudo add-apt-repository -y "deb http://archive.ubuntu.com/ubuntu/ trusty main universe"
- sudo apt-get -qq update
- sudo apt-get -qq install mono-devel mono-gmcs mono-xbuild nunit-console
- sudo mozroots --import --machine --sync
- yes | sudo certmgr -ssl -m https://go.microsoft.com
- yes | sudo certmgr -ssl -m https://nugetgallery.blob.core.windows.net
- yes | sudo certmgr -ssl -m https://nuget.org
install:
- python setup.py build_ext --inplace
script:
- export PYTHONPATH=`pwd`
- ./npython src/tests/runtests.py
File renamed without changes.
23 changes: 23 additions & 0 deletions Python.Runtime.dll.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<!-- Mono DLL map for Python.Runtime.dll

Keep this file next to Python.Runtime.dll

For more information read:
http://www.mono-project.com/Config
http://www.mono-project.com/Config_DllMap

-->

<configuration>
<dllmap dll="python23" target="libpython2.3.so" os="!windows" />
<dllmap dll="python24" target="libpython2.4.so" os="!windows" />
<dllmap dll="python25" target="libpython2.5.so" os="!windows" />
<dllmap dll="python26" target="libpython2.6.so" os="!windows" />
<dllmap dll="python27" target="libpython2.7.so" os="!windows" />
<dllmap dll="python23.dll" target="libpython2.3.so" os="!windows" />
<dllmap dll="python24.dll" target="libpython2.4.so" os="!windows" />
<dllmap dll="python25.dll" target="libpython2.5.so" os="!windows" />
<dllmap dll="python26.dll" target="libpython2.6.so" os="!windows" />
<dllmap dll="python27.dll" target="libpython2.7.so" os="!windows" />
</configuration>

8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
pythonnet
=========

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.

[![Build Status](https://travis-ci.org/pythonnet/pythonnet.png?branch=develop)](https://travis-ci.org/pythonnet/pythonnet)

[![Build status](https://ci.appveyor.com/api/projects/status/65riiu1hvgaxsbwb)](https://ci.appveyor.com/project/davidanthoff/pythonnet)
43 changes: 43 additions & 0 deletions VS_README.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
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
31 changes: 31 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
os: Windows Server 2012

environment:
global:
PYTHONPATH: c:\testdir

matrix:
- pythonurl: http://www.python.org/ftp/python/2.7.6/python-2.7.6.amd64.msi
- pythonurl: http://www.python.org/ftp/python/2.7.6/python-2.7.6.msi
- pythonurl: http://www.python.org/ftp/python/2.6.6/python-2.6.6.msi
- pythonurl: http://www.python.org/ftp/python/2.6.6/python-2.6.6.amd64.msi

install:
- ps: (new-object net.webclient).DownloadFile($env:pythonurl, 'C:\python.msi')
- ps: start-process -wait -FilePath msiexec.exe -ArgumentList "/qn /i C:\python.msi TARGETDIR=C:\Python"
- ps: (new-object net.webclient).DownloadFile('https://raw.github.com/pypa/pip/master/contrib/get-pip.py', 'C:\get-pip.py')
# appveyor has python 2.7.6 x86 preinstalled, but in the wrong directory, this works around this
- ps: if ($env:pythonurl -eq "http://www.python.org/ftp/python/2.7.6/python-2.7.6.msi") {mi c:\python27 c:\python}
- set PATH=C:\Python;%PATH%
- C:\Python\python.exe c:\get-pip.py
- C:\Python\Scripts\pip.exe install wheel

build_script:
- C:\python\python.exe setup.py bdist_wheel

test_script:
- ps: C:\python\scripts\pip.exe install ("dist\" + (gci dist)[0].Name)
- mkdir c:\testdir
- ps: copy-item (gci -path build -re -include Python.Test.dll)[0].FullName c:\testdir
- c:\python\python.exe src\tests\runtests.py
- c:\python\scripts\npython.exe src\tests\runtests.py
18 changes: 13 additions & 5 deletions pythonnet/demo/helloform.py → demo/helloform.py
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
# FOR A PARTICULAR PURPOSE.
# ===========================================================================

import clr
SWF = clr.AddReference("System.Windows.Forms")
print SWF.Location
import System.Windows.Forms as WinForms
from System.Drawing import Size, Point

Expand All @@ -24,8 +27,8 @@ def __init__(self):

# Create the button
self.button = WinForms.Button()
self.button.Location = Point(256, 64)
self.button.Size = Size(120, 40)
self.button.Location = Point(160, 64)
self.button.Size = Size(820, 20)
self.button.TabIndex = 2
self.button.Text = "Click Me!"

Expand All @@ -36,8 +39,8 @@ def __init__(self):
self.textbox = WinForms.TextBox()
self.textbox.Text = "Hello World"
self.textbox.TabIndex = 1
self.textbox.Size = Size(360, 20)
self.textbox.Location = Point(16, 24)
self.textbox.Size = Size(1260, 40)
self.textbox.Location = Point(160, 24)

# Add the controls to the form
self.AcceptButton = self.button
Expand All @@ -46,14 +49,19 @@ def __init__(self):

def button_Click(self, sender, args):
"""Button click event handler"""
print "Click"
WinForms.MessageBox.Show("Please do not press this button again.")

def run(self):
WinForms.Application.Run(self)


def main():
HelloApp().run()
form = HelloApp()
print "form created"
app = WinForms.Application
print "app referenced"
app.Run(form)


if __name__ == '__main__':
Expand Down
File renamed without changes.
File renamed without changes.
21 changes: 21 additions & 0 deletions doc/Python.Runtime.dll.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<!-- Mono DLL map for Python.Runtime.dll

Keep this file next to Python.Runtime.dll

For more information read:
http://www.mono-project.com/Config
http://www.mono-project.com/Config_DllMap

-->

<configuration>
<dllmap dll="python23" target="/usr/lib/libpython2.3.dylib" os="!windows" />
<dllmap dll="python24" target="/usr/lib/libpython2.4.dylib" os="!windows" />
<dllmap dll="python25" target="/usr/lib/libpython2.5.dylib" os="!windows" />
<dllmap dll="python26" target="/usr/lib/libpython2.6.dylib" os="!windows" />
<dllmap dll="python23.dll" target="/usr/lib/libpython2.3.dylib" os="!windows" />
<dllmap dll="python24.dll" target="/usr/lib/libpython2.4.dylib" os="!windows" />
<dllmap dll="python25.dll" target="/usr/lib/libpython2.5.dylib" os="!windows" />
<dllmap dll="python26.dll" target="/usr/lib/libpython2.6.dylib" os="!windows" />
</configuration>

34 changes: 34 additions & 0 deletions doc/TODO.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
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.

107 changes: 105 additions & 2 deletions pythonnet/doc/changes.txt → doc/changes.txt
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,5 +1,108 @@
PythonNet Changes
-----------------
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
("<type 'exceptions.Exception'>").

- 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
---------------------------------------------------------------------------
Expand Down
17 changes: 17 additions & 0 deletions doc/mono_config.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<!-- Mono Config for PythonNet

Copy this file to ~/.mono/config or add the dllmaps to the global
configuration file /etc/mono/config
-->

<configuration>
<dllmap dll="python23" target="libpython2.3.so" os="!windows" />
<dllmap dll="python24" target="libpython2.4.so" os="!windows" />
<dllmap dll="python25" target="libpython2.5.so" os="!windows" />
<dllmap dll="python26" target="libpython2.6.so" os="!windows" />
<dllmap dll="python23.dll" target="libpython2.3.so" os="!windows" />
<dllmap dll="python24.dll" target="libpython2.4.so" os="!windows" />
<dllmap dll="python25.dll" target="libpython2.5.so" os="!windows" />
<dllmap dll="python26.dll" target="libpython2.6.so" os="!windows" />
</configuration>

Loading