ふにゃるんv2

もとは、http://d.hatena.ne.jp/Wacky/

もう何時でもリリース出来るのでは? IronPython for Visual Studio 2005の9月版

随分前に、IronPython for Visual Studio 2005ってのを紹介しました。
後、IronPython 1.0がリリースされた時、IronPythonの復習で、MSの関係者?さんが、VSSDKに新バージョンのIronPythonを組み込む旨の宣言をしているっぽいとも、紹介しました。


で、少し忘れかけていましたが、VSSDKの2006/09/15版が出ていたのに気付いたので、早速特攻です。

まずはチェック

readme.htmを覗いてみると、IronPythonの記述が、そこかしこに見られます。
適当に、英日翻訳にかけてみます。

原文:
IronPython: You cannot reference an IronPython assembly from another Microsoft .NET language (C#, Visual Basic, and the like). This includes both file and project-to-project references. However, you can reference other .NET assemblies or non-IronPython projects from an IronPython project. This is an IronPython issue and not an issue with the IronPython integration code that is covered above.

翻訳:
IronPython: あなたは別のマイクロソフト.NET言語(C#Visual Basic、および同様のもの)からIronPythonアセンブリに参照をつけることができません。 これはファイルとプロジェクトからプロジェクトへの両方の指示するものを含んでいます。 しかしながら、あなたはIronPythonプロジェクトからの参照他の.NETアセンブリか非IronPythonプロジェクトをそうすることができます。 これは問題ではなく、上にカバーされているIronPython統合コードのIronPython問題です。

原文:
IronPython Web Integration: Due to the space-sensitive nature of IronPython and its lack of support for partial classes, some scenarios around IntelliSense and code-generation of event handlers do not work. Please note that the IronPython integration sample is not to be used as a product, but rather as a sample of how you can integrate your own languages into Visual Studio. For more details on the scenarios that are not supported, please refer to the Overview.xml file for the IronPython sample.

翻訳:
IronPythonウェブ統合: IronPythonのスペース敏感な本質とその部分的なクラスのサポートの不足のため、イベントハンドラのインテリセンスとコード生成の周りのいくつかのシナリオは働いていません。 IronPython統合のサンプルが使用されるために製品としてあるのではなく、むしろあなたがどうあなた自身の言語をヴィジュアルスタジオと統合することができるかに関するサンプルとしてあります。 支持されないシナリオに関するその他の詳細について、IronPythonのサンプルのためのOverview.xmlファイルを参照してください。

原文:
IronPython and Source Code Control: Source Control presently will not behave properly with IronPython Projects (except for WebSites). If you add a project to source control and check out a file, you will see an error message with the following text: "Unexpected error encountered. It is recommended that you restart the application as soon as possible. Error: Unspecified error File: vsee\pkgs\vssprovider\csolutionnodebase.cpp Line number: 2112". This is due to an inconsistency in the way the IronPython project system handles icons. To have your project system work correctly with both Web Application Projects (WAP) and Source Code Control (SCC), we recommend implementing the IconImgList property and not implementing the IconHandle property for your project system. See vsshell.idl for more information about implementing the IconImgList/IconIndex or IconHandle properties on your project hierarchy. This problem will be addressed in a future release of the Visual Studio SDK. As an alternative reference, please note that the MyProj sample located in Archive\CS_Samples\Project also uses the MPF project base classes and does not exhibit this behavior with SCC.

翻訳:
IronPythonソースコードコントロール: ソースControlはやがて、IronPython Projects(WebSitesを除いた)と共に礼儀正しく振る舞わないでしょう。 ソースコントロールにプロジェクトを加えて、ファイルを調べると、あなたは以下のテキストがあるエラーメッセージを見るでしょう: 「遭遇する予期せぬエラー。」 あなたができるだけ早くアプリケーションを再開するのは、お勧めです。 誤り: 不特定の誤りFile: vsee\pkgs\vssprovider\csolutionnodebase.cpp線番号: 2112". これはIronPythonプロジェクトシステムがアイコンを扱う方法における矛盾のためです。 ウェブApplication Projects(WAP)とSource Code Control(SCC)の両方と共にあなたのプロジェクトシステム作業を正しく持つために、私たちは、あなたのプロジェクトシステムのためにIconImgListが特性であると実装して、IconHandleの特性を実装するのを勧めません。 IconImgList/IconIndexかIconHandleがあなたのプロジェクト階層構造の特性であると実装することに関する詳しい情報に関してvsshell.idlを見てください。 このその問題はヴィジュアルスタジオSDKの今後のリリースで訴えられるでしょう。 代替の参照として、アーカイブ\CS_Samples\Projectに位置するMyProjのサンプルも、MPFプロジェクト基底クラスを使用して、SCCとのこの振舞いを示しません。

used by. http://www.excite.co.jp/world/

では入れてみましょう

例の如く、以下のページのDownload the software development kitのページからVSSDKを入手します。


2006/10/21時点で登録されているのは、

  • File Name: VsSDKSeptember2006.exe
  • Version: 3.0
  • Date Published: 9/15/2006

といった按配です。


インストールすると、"C:\Program Files\Visual Studio 2005 SDK\2006.09\VisualStudioIntegration\Samples\IronPythonIntegration"にIronPythonのサンプルプロジェクトが出来上がりますので、ソリューションファイルを開いてビルドして下さい。


実行すると、新たに Visual Studio 2005が起動します。
新規プロジェクトを開くと、以下のメニューが追加されています。

1
1 posted by (C) wackyさんの写真


IronPython project menu:

  • Windows Application
  • Class Library
  • Console Application
  • ASP.NET Web Application
  • ASP.NET Web Service Application

IronPythonで、Windowsアプリケーションを作ってみよう

"Windows Application"を選んで、プロジェクトを作ると、以下の画面が出てきます。
2
2 posted by (C) wackyさんの写真


ぱっと見、C#VBで作成したフォーム画面と違いがわかりません。
タブをよく見ると、"*.py"が表記しているから、「ありゃ?」と思うぐらいです。


ツールボックスから、フォームへのポトペタも簡単です。
3
3 posted by (C) wackyさんの写真


ボタンをダブルクリックすると、コードが表示されます。
4
4 posted by (C) wackyさんの写真

どう見ても、.NETの画面とPythonが完全融合しています。すごいっすよ、こりは!?
(個人的には、属性が使える事にびっくり)


更に、コードの先頭で"import sys"すると、コード補完が働き始めます。
5
5 posted by (C) wackyさんの写真
(但し、幾つかのケースで表示されない場合があります。readmeで完全じゃないよと書いてあるのは、そういう意味なんでしょう)


デバッグも完璧です。
ブレークポイントもかけられますし、ウオッチも出来ます。
6
6 posted by (C) wackyさんの写真


更に、実行ファイルも出来ています。
7
7 posted by (C) wackyさんの写真

配布する時は、これを配ればOKという親切設計。
もう、「スクリプトだから配布しにくい」とか言わせません!!

まとめ

以前のリリースより、今回のVSSDKに含まれているものは、更に洗練されています。
元のPythonの強力さに、.NETの豊富なライブラリに強力なデバッグ機能が追加された姿は、鬼に金棒状態じゃない?と思わせるだけのインパクトがあります。

  • VS2005のメニューからプロジェクトを新規作成できます
  • 完全ではありませんが、インテリセンスが働きます
  • RAD開発ができます
  • ブレークポイントやウオッチといったデバッグも出来ます
  • Pythonの豊富な資産が使えます
  • 豊富な.NETライブラリが使えます
  • バイナリ化されるので、配布が簡単です


個人的には、SP1を出す際には、これを含めて欲しいなぁ。なんて思います。

追記

IronPythonのVSSDKの説明については、以下が存在します。


後、IronPythonのプロジェクト付きのVS2005を常用したければ、VSSDKのスタートメニューに、「Start Visual Studio 2005 under Experimental hive」というショートカットが追加されているので、デスクトップにでも貼り付けて下さい。


中では、単に、"devenv /rootsuffix Exp"として、オプション付きで VS2005を呼び出しているだけです。(レジストリを参照すると、なるほどぉと膝ポンです)