Python.NET and VS2001/.NET 4.0

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Python.NET and VS2001/.NET 4.0

Oleksii Bidiuk
Hi All,

I hope this will help some people like me searching for an answer. Several steps were mentioned by other people as well, but I haven't seen a step-by-step guide. It is not my intention to duplicate other posts in that sense, but rather have all-in-one post.

Here is how I've got VS2010 and .NET 4.0 working with the revision 119 of the Python.NET having Python 2.6 installed. Note that the latest trunk (revision 122) gave me some problems, so I have basically reverted changes to match 119 for the time being.

1. Get the sources (tarball from sourceforge or directly from SVN)
2. Open the pythonnet.sln with VS2010 and convert to 2010 format (will happen automagically)
3. Change the target framework to 4. Follow the following step for EACH project
    3.1. Right-click on the project name and select "Properties"
    3.2. Select the "Application" tab on the left (if not selected yet)
    3.3. Change the "Target framework" to ".NET Framework 4"
4. Open the clrmodule.il and change the lines with the version number in the following piece of code 

.assembly extern mscorlib { .publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) .ver 2:0:0:0 }

to have

.ver 4:0:0:0

5. Open the buildclrmodule.bat and change the 

%windir%\Microsoft.NET\Framework\v2.0.50727\ilasm /nologo /quiet /dll %ILASM_EXTRA_ARGS% /include=%INCLUDE_PATH% /output=%OUTPUT_PATH% %INPUT_PATH%

to

%windir%\Microsoft.NET\Framework\v4.0.30319\ilasm /nologo /quiet /dll %ILASM_EXTRA_ARGS% /include=%INCLUDE_PATH% /output=%OUTPUT_PATH% %INPUT_PATH%

5. Recompile the whole solution, ignore the deprecation warnings.

Now you have all necessary files under the pythonnet folder where you have the sources. You need clr.pyd, python.exe and Python.Runtime.dll.

Test
Run the newly comiled python.exe
Type the following

>>> import System >>> print System.Environment.Version 4.0.30319.1

The last line proves that you're using hte 4.0 runtime. The precomiled binaries available from Sourceforge would show 
2.0.50727.3615

This is also posted with somewhat better formatting under blog.bidiuk.com/2011/01/python-net-and-vs2010-net-4/

Comments and suggestions are welcome!
--
oleksii

_________________________________________________
Python.NET mailing list - [hidden email]
http://mail.python.org/mailman/listinfo/pythondotnet
Reply | Threaded
Open this post in threaded view
|

Re: Python.NET and VS2001/.NET 4.0

Tribble, Brett

Thanks Biduik,

 

I will need this in a few short weeks.

 

From: pythondotnet-bounces+btribble=[hidden email] [mailto:pythondotnet-bounces+btribble=[hidden email]] On Behalf Of Oleksii Bidiuk
Sent: Monday, January 17, 2011 8:06 AM
To: [hidden email]
Subject: [Python.NET] Python.NET and VS2001/.NET 4.0

 

Hi All,

 

I hope this will help some people like me searching for an answer. Several steps were mentioned by other people as well, but I haven't seen a step-by-step guide. It is not my intention to duplicate other posts in that sense, but rather have all-in-one post.

 

Here is how I've got VS2010 and .NET 4.0 working with the revision 119 of the Python.NET having Python 2.6 installed. Note that the latest trunk (revision 122) gave me some problems, so I have basically reverted changes to match 119 for the time being.

 

1. Get the sources (tarball from sourceforge or directly from SVN)

2. Open the pythonnet.sln with VS2010 and convert to 2010 format (will happen automagically)

3. Change the target framework to 4. Follow the following step for EACH project

    3.1. Right-click on the project name and select "Properties"

    3.2. Select the "Application" tab on the left (if not selected yet)

    3.3. Change the "Target framework" to ".NET Framework 4"

4. Open the clrmodule.il and change the lines with the version number in the following piece of code 

 

.assembly extern mscorlib

{

     .publickeytoken = (B7 7A 5C 56 19 34 E0 89 )

     .ver 2:0:0:0

}

 

to have



     .ver 4:0:0:0

 

5. Open the buildclrmodule.bat and change the 

 

%windir%\Microsoft.NET\Framework\v2.0.50727\ilasm /nologo /quiet /dll %ILASM_EXTRA_ARGS% /include=%INCLUDE_PATH% /output=%OUTPUT_PATH% %INPUT_PATH%

 

to

 

%windir%\Microsoft.NET\Framework\v4.0.30319\ilasm /nologo /quiet /dll %ILASM_EXTRA_ARGS% /include=%INCLUDE_PATH% /output=%OUTPUT_PATH% %INPUT_PATH%

 

5. Recompile the whole solution, ignore the deprecation warnings.

 

Now you have all necessary files under the pythonnet folder where you have the sources. You need clr.pyd, python.exe and Python.Runtime.dll.

 

Test

Run the newly comiled python.exe

Type the following

 

>>> import System >>> print System.Environment.Version 4.0.30319.1

 

The last line proves that you're using hte 4.0 runtime. The precomiled binaries available from Sourceforge would show 

2.0.50727.3615

 

This is also posted with somewhat better formatting under blog.bidiuk.com/2011/01/python-net-and-vs2010-net-4/

 

Comments and suggestions are welcome!

--
oleksii


_________________________________________________
Python.NET mailing list - [hidden email]
http://mail.python.org/mailman/listinfo/pythondotnet
Reply | Threaded
Open this post in threaded view
|

Re: Python.NET and VS2001/.NET 4.0

Oleksii Bidiuk
In reply to this post by Oleksii Bidiuk
Hi All,

A small correction to my post. Revision 122 seem to contain all the code, only the reference to the constructorbinding.cs is missing in the Python.Runtime.csproj. Simply adding a reference solves the problem!

2011/1/17 Oleksii Bidiuk <[hidden email]>
Hi All,

I hope this will help some people like me searching for an answer. Several steps were mentioned by other people as well, but I haven't seen a step-by-step guide. It is not my intention to duplicate other posts in that sense, but rather have all-in-one post.

Here is how I've got VS2010 and .NET 4.0 working with the revision 119 of the Python.NET having Python 2.6 installed. Note that the latest trunk (revision 122) gave me some problems, so I have basically reverted changes to match 119 for the time being.

1. Get the sources (tarball from sourceforge or directly from SVN)
2. Open the pythonnet.sln with VS2010 and convert to 2010 format (will happen automagically)
3. Change the target framework to 4. Follow the following step for EACH project
    3.1. Right-click on the project name and select "Properties"
    3.2. Select the "Application" tab on the left (if not selected yet)
    3.3. Change the "Target framework" to ".NET Framework 4"
4. Open the clrmodule.il and change the lines with the version number in the following piece of code 

.assembly extern mscorlib { .publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) .ver 2:0:0:0 }

to have

.ver 4:0:0:0

5. Open the buildclrmodule.bat and change the 

%windir%\Microsoft.NET\Framework\v2.0.50727\ilasm /nologo /quiet /dll %ILASM_EXTRA_ARGS% /include=%INCLUDE_PATH% /output=%OUTPUT_PATH% %INPUT_PATH%

to

%windir%\Microsoft.NET\Framework\v4.0.30319\ilasm /nologo /quiet /dll %ILASM_EXTRA_ARGS% /include=%INCLUDE_PATH% /output=%OUTPUT_PATH% %INPUT_PATH%

5. Recompile the whole solution, ignore the deprecation warnings.

Now you have all necessary files under the pythonnet folder where you have the sources. You need clr.pyd, python.exe and Python.Runtime.dll.

Test
Run the newly comiled python.exe
Type the following

>>> import System >>> print System.Environment.Version 4.0.30319.1

The last line proves that you're using hte 4.0 runtime. The precomiled binaries available from Sourceforge would show 
2.0.50727.3615

This is also posted with somewhat better formatting under blog.bidiuk.com/2011/01/python-net-and-vs2010-net-4/

Comments and suggestions are welcome!
--
oleksii



--
oleksii

_________________________________________________
Python.NET mailing list - [hidden email]
http://mail.python.org/mailman/listinfo/pythondotnet