「URN」を含む日記 RSS

はてなキーワード: URNとは

2023-09-16

URNってどこにも使われてないよね。

WikipediaによるとURNはこういうやつ↓らしい。

urn:ISBN:0451450523

2023-07-11

anond:20230711093448

かもね かもね そうかもねくせになっちゃうかもね. Baby Burn!

2008-03-21

[]Python 2.5のdistutilsで、Visual Studio 2005を使いたい!

目的

Visual Studio 2005しかインストールしてない場合、Python 2.5だとdistutilsが正しく動かないっぽいので、どうにかしたいYO!

なんでVisual Studio 2005だと、distutilsが動かないんかな?

distutilsでVisual Studioを使うときのコンパイル環境は、sysモジュールのversionプロパティを参照して環境を選択をしているようです。Pythonインタプリタを起動して、以下のような命令を実行してみると、sys.versionプロパティが確認できます。

import sys;print sys.version

Python 2.5.2だと、以下のようになっています。Visual Studio 2003の環境が使われるようです。

2.5.2 (r252:60911, Feb 21 2008, 13:11:45) [MSC v.1310 32 bit (Intel)]

Python 2.6a1だと、以下のようになっています。Visual Studio 2008の環境が使われるようです。

2.6a1 (r26a1:61155, Mar  1 2008, 12:11:56) [MSC v.1500 32 bit (Intel)]

以上から察するに、Python 2.5.2とPython 2.6のどちらでも、Visual Studio 2005の環境が選択されることはないっぽいです。うーん、困った!

解決策

Python 2.6とVisual Studio 2008をインストールしよう!」というのを真っ先に思いつきましたが、あんまり環境を変えたくないんだよなー。というわけで、環境の変更を最低限に抑えてどうにかしてみました。簡単に言うと、distutilsだけの置き換えをしました。

Python 2.6 をインストールする

Python 2.6の公式ダウンロードページから、Windows版のインストーラーをダウンロードして、適当な場所にインストールしてください。

distutilsだけ置き換える

"Python-2.5.2/Lib/distutils"を別の場所に移動し、"Python-2.6a1/Lib/distutils"を"Python-2.5.2/Lib"以下にコピーしてください。以降はPython 2.6は必要ないので、アンインストールして構いません。

ファイルの修正
  • 例外をPython 2.5.2で許されている形式に変更。
  • get_build_version()関数で強制的に8を返すように変更。

上記の2点の変更を行います。distutilsディレクトリに、以下のパッチをあててください。

Index: msvccompiler.py
===================================================================
--- msvccompiler.py
+++ msvccompiler.py
@@ -170,6 +170,7 @@
     if majorVersion == 6:
         minorVersion = 0
     if majorVersion >= 6:
+        return 8
         return majorVersion + minorVersion
     # else we don't know what version of the compiler this is
     return None
Index: msvc9compiler.py
===================================================================
--- msvc9compiler.py
+++ msvc9compiler.py
@@ -128,7 +128,7 @@
                                "sdkinstallrootv2.0")
             else:
                 raise KeyError("sdkinstallrootv2.0")
-        except KeyError as exc: #
+        except KeyError, exc: #
             raise DistutilsPlatformError(
             """Python was built with Visual Studio 2008;
 extensions must be built with a compiler than can generate compatible binaries.
@@ -172,6 +172,7 @@
     if majorVersion == 6:
         minorVersion = 0
     if majorVersion >= 6:
+        return 8
         return majorVersion + minorVersion
     # else we don't know what version of the compiler this is
     return None
@@ -455,7 +456,7 @@
                 try:
                     self.spawn([self.rc] + pp_opts +
                                [output_opt] + [input_opt])
-                except DistutilsExecError as msg:
+                except DistutilsExecError, msg:
                     raise CompileError(msg)
                 continue
             elif ext in self._mc_extensions:
@@ -482,7 +483,7 @@
                     self.spawn([self.rc] +
                                ["/fo" + obj] + [rc_file])
 
-                except DistutilsExecError as msg:
+                except DistutilsExecError, msg:
                     raise CompileError(msg)
                 continue
             else:
@@ -495,7 +496,7 @@
                 self.spawn([self.cc] + compile_opts + pp_opts +
                            [input_opt, output_opt] +
                            extra_postargs)
-            except DistutilsExecError as msg:
+            except DistutilsExecError, msg:
                 raise CompileError(msg)
 
         return objects
@@ -520,7 +521,7 @@
                 pass # XXX what goes here?
             try:
                 self.spawn([self.lib] + lib_args)
-            except DistutilsExecError as msg:
+            except DistutilsExecError, msg:
                 raise LibError(msg)
         else:
             log.debug("skipping %s (up-to-date)", output_filename)
@@ -598,7 +599,7 @@
             self.mkpath(os.path.dirname(output_filename))
             try:
                 self.spawn([self.linker] + ld_args)
-            except DistutilsExecError as msg:
+            except DistutilsExecError, msg:
                 raise LinkError(msg)
 
         else:
manifestファイルを作る

python.exeと同じディレクトリに、以下のXMLを"python.exe.manifest"として保存してください。

<?xml version='1.0' encoding='UTF-8' standalone='yes'?>
<assembly xmlns='urn:schemas-microsoft-com:asm.v1' manifestVersion='1.0'>
  <dependency>
    <dependentAssembly>
      <assemblyIdentity
        type='win32'
        name='Microsoft.VC80.CRT'
        version='8.0.50608.0'
        processorArchitecture='x86'
        publicKeyToken='1fc8b3b9a1e18e3b'
        />
    </dependentAssembly>
  </dependency>
</assembly>

これで終わりです。

2008-03-15

[][]PythonからSWIG経由でVisual Studio 2005を使って困ったこと

以上のような組み合わせで出くわした困ったことと、その解決策をメモしておきます。

setup.py を実行するとエラーが表示された!

Python was built with Visual Studio 2003;

extensions must be built with a compiler than can generate compatible binaries.

Visual Studio 2003 was not found on this system. If you have Cygwin installed,

you can try compiling with MingW32, by passing "-c mingw32" to setup.py.

setup.pyに.iファイルとか.cppファイルを記述して実行すると、こんな感じのエラーメッセージが表示されました。うーん、困った!

http://labs.cybozu.co.jp/blog/mitsunari/2007/08/vc2005boostpython.html

上記のページを参考にして、"%Pythonインストールしたフォルダ%/Lib/distutils/msvcompiler.py"を以下のように修正してみたら解決できました。ありがとうありがとう

--- msvccompiler.py    2007-04-04 17:17:12.000000000 +0900
+++ 
@@ -126,7 +126,7 @@
         self.set_macro("FrameworkDir", net, "installroot")
         try:
             if version > 7.0:
-                self.set_macro("FrameworkSDKDir", net, "sdkinstallrootv1.1")
+                self.set_macro("FrameworkSDKDir", net, "sdkinstallrootv2.0")
             else:
                 self.set_macro("FrameworkSDKDir", net, "sdkinstallroot")
         except KeyError, exc: #
@@ -252,7 +252,10 @@

     def initialize(self):
         self.__paths = []
-        if os.environ.has_key("DISTUTILS_USE_SDK") and os.environ.has_key("MSSdk") and self.find_exe("cl.exe"):
+        if self.__version >= 7.1 or (
+            os.environ.has_key("DISTUTILS_USE_SDK") and
+            os.environ.has_key("MSSdk") and
+            self.find_exe("cl.exe")):
             # Assume that the SDK set up everything alright; don't try to be
             # smarter
             self.cc = "cl.exe"
@@ -288,10 +291,16 @@

         self.preprocess_options = None
         if self.__arch == "Intel":
-            self.compile_options = [ '/nologo', '/Ox', '/MD', '/W3', '/GX' ,
-                                     '/DNDEBUG']
-            self.compile_options_debug = ['/nologo', '/Od', '/MDd', '/W3', '/GX',
-                                          '/Z7', '/D_DEBUG']
+            if self.__version >= 7.1:
+                self.compile_options = [
+                    '/nologo', '/Ox', '/MD',  '/W3', '/EHsc', '/DNDEBUG']
+                self.compile_options_debug = [
+                    '/nologo', '/Od', '/MDd', '/W3', '/EHsc', '/Z7', '/D_DEBUG']
+            else:
+                self.compile_options = [
+                    '/nologo', '/Ox', '/MD',  '/W3', '/GX',  '/DNDEBUG']
+                self.compile_options_debug = [
+                    '/nologo', '/Od', '/MDd', '/W3', '/GX', '/Z7', '/D_DEBUG']
         else:
             # Win64

cl.exeが見つからないと言われた!

setup.pyを実行するとcl.exeが見つからないみたいなエラーが表示されました。これは、アレだ。「パス通せ!」ということですね。bashを起動するときのバッチファイル(たぶん"cygwin.bat"とか)で、以下のような行を入れてやれば解決しました。

call "%VS80COMNTOOLS%vsvars32.bat"

setup.pyを実行したときに"basetsd.h"が開けないと言われた!

d:\python25\include\pyconfig.h(189) : fatal error C1083: include ファイルを開けません。'basetsd.h': No such file or directory

error: command 'cl.exe' failed with exit status 2

setup.pyを実行すると、上のようなエラーが表示されました。

http://d.hatena.ne.jp/ousttrue/20070531/1180556273

上記のサイトを見るとインクルードパスが通っていない場所に"basetsd.h"があるのが原因なので、"cygwin.bat"にインクルードパスの設定をしておきました。

call "%VS80COMNTOOLS%vsvars32.bat"
set INCLUDE=C:\Program Files\Microsoft Platform SDK\Include;%INCLUDE%

setup.pyを実行したときのリンク時にエラーが発生した!

link: extra operand `/INCREMENTAL:NO'

詳しくは `link --help' を実行して下さい.

error: command 'link.exe' failed with exit status 1

これは、cygwinのほうのlink.exeが実行されてるのが原因でした。スマートな解決策ではありませんが、cygwinのほうのlink.exeをリネームして解決。パスの設定順序とかでどうにかできるといいんだけど、どうすればいいんかな。

MSVCR80.dllが見つからないと言われた!

MSVCR80.dllが見つからなかったため、このアプリケーションを開始できませんでした。アプリケーションインストールし直すとこの問題は解決される場合があります。

SWIGが生成した.pyファイルをimportしたら、こんな感じのエラーダイアログが表示されたよ。うーん、困った!

http://d.hatena.ne.jp/moriyoshi/20070525

上記のページを参考にして、"%Pythonインストールしたフォルダ%/python.exe.manifest"として以下のようなファイルを新しく作ったら、解決できました。ありがとうありがとう

あとこれ、bashから実行したらエラーダイアログが表示されず、importするモジュールが見つからないみたいなエラーメッセージが出力されるだけだったよ。

<?xml version='1.0' encoding='UTF-8' standalone='yes'?>
<assembly xmlns='urn:schemas-microsoft-com:asm.v1' manifestVersion='1.0'>
  <dependency>
    <dependentAssembly>
      <assemblyIdentity type='win32' name='Microsoft.VC80.CRT' version='8.0.50608.0' processorArchitecture='x86' publicKeyToken='1fc8b3b9a1e18e3b' />
    </dependentAssembly>
  </dependency>
</assembly>

2007-08-08

http://anond.hatelabo.jp/20070808015717

URLURNも全部まとめてURIと言って問題なし。

というのがW3Cの公式見解だったような。

URIでいいよね?

http://serif.hatelabo.jp/bc8f7f7cc511e49477ac52273262f506da1a03fa/6185013b8cff98399c4616671c794bc6dfe54f38

URIって識別子という大枠の中に、具体的なリソースロケーションを示す用途のURL名前空間みたいなので使うURNがあって、

それを国際化したものがIRIって事でOK?

はてなセリフへはコメントとかトラックバックってないんですよね?

 
ログイン ユーザー登録
ようこそ ゲスト さん