#PPx 書庫ファイルの展開用スクリプト
書庫の展開を 7zG に変えてみた #PPx から変更。
- 7zG を使うと startw を使っても一瞬フォーカスが移るのが嫌だったので 7z へ。
- 展開中に別のファイルを展開しようとしたらキューイングするようにした。
- *logwindow on を使ってみてもログウィンドウが表示されなかったので*logwindow "メッセージ" を使っている。*logwindow on も動いていた気がしたんだけどな……。
unite-everything インストール
インストールしたときの覚書。
- NeoBundleLazy 'sgur/unite-everything' だと動かないみたい。設定が悪いのかな。NeoBundle 'sgur/unite-everything' にした。
- es.exe をインストールし忘れていたので動いていなかった。
- es.exe をインストールしても動いてくれなかった。everything.exe が管理者権限で動いていると駄目みたい。そもそも 1.2 は通常、管理者権限じゃないと動かないのでは?
- everything 1.3.2.649b をインストール。everything -install-service でサービスをインストールしてから everything.exe を起動。これなら管理者権限でなくても OK。
- 管理者権限で動かしている Autohotkey から Everything を起動するようにしていたので、これをはずす。bbLean の bbKeys で Everything 起動用のショートカットを指定。
ag のビルド
ackより速いagを試してみる - secretbase.log
MinGWでSilver Searcher(ag.exe)をビルドする方法。 #Windows #MinGW - Qiita
chocolatey install
mingw を簡単にインストールしようと思って chocolatey 導入。
@powershell -NoProfile -ExecutionPolicy unrestricted -Command "iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'))" && SET PATH=%PATH%;%systemdrive%\chocolatey\bin
ag build
git clone git://github.com/ggreer/the_silver_searcher.git cd the_silver_searcher.git git co c9c2b5b
MinGWでSilver Searcher(ag.exe)をビルドする方法。 #Windows #MinGW - Qiita だと zlib もバイナリを入れているけれど、 mingw-get list で libz が見つかったので、そちらを使用。
mingw-get install mingw32-libz
pcre-x86-mingw4-8.21-src.tar.bz2
pcre-x86-mingw4-8.21-bin.tar.bz2
- pcre-x86-mingw4-8.21-src.tar.bz2内のpcre.h.genericとconfig.h.genericを.genericを外してthe_silver_searcher/src内にコピーする。
- pcre-x86-mingw4-8.21-bin.tar.bz2内のbin/libpcre.dllをthe_silver_searcher内にコピーする。
- the_silver_searcher/Makefile.w32を以下のように書き換える。
+ LDFLAGS = -static -static-libgcc - LIBS = -lz -lpthread -lpcre -lshlwapi + LIBS = ./libpcre.dll -lz -lpthread -lshlwapi
- gcc -o $@ $(OBJS) $(LIBS) + gcc $(LDFLAGS) -o $@ $(OBJS) $(LIBS)
mingw32-make -f Makefile.w32
mingw 外で使うには以下のファイルも必要。
- libpcre.dll
- pthreadGC2.dll
蛇足
LDFLAGS = -static で libz-1.dll は不要になった。
libgcc_s_dw2-1.dll も不要になったみたい。
pthreadGC2.dll も外したいけど、どうしたらいいんだ?
pcre
ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/
ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.32.tar.bz2
./configure mingw32-make.exe mingw32-make.exe install
gcc に -I を指定したり -L を指定したりしたけど、使ってくれなかったみたい。
PyQt で exe を作ってみた #pyhack:
(第31回)Python mini Hack-a-thon のもう一つとして、PyQt を触ってみた。パイキュートだそうです。
helloworld.py と setup.py を書いて py2exe を実行して exe のできあがり。
helloworld.py に import sip ががないと exe の実行時にエラーになった。
helloworld.py
# -*- coding: utf-8 -*- import sys import PyQt4.QtCore as QtCore import PyQt4.QtGui as QtGui import sip # py2exe に必要 def print_state(state): if state == 0: print('Unchecked') else: print('checked') def main(): app = QtGui.QApplication(sys.argv) main_window = QtGui.QMainWindow() listbox = QtGui.QListView() main_window.setCentralWidget(listbox) main_window.show() app.exec_() if __name__ == '__main__': main()
setup.py
from distutils.core import setup import py2exe target = py2exe.build_exe.Target(script='helloworld.py') setup(options={"py2exe": {'bundle_files': 1, 'optimize': 2, 'compressed': True } }, windows=[target], zipfile=None )
実行
python setup.py py2exe
Vim の Python コード補完でエラー(似非解決) #pyhack:
(第31回)Python mini Hack-a-thon に参加してきた。
最近使い始めた Vim で Python を書いていると、補完時にランタイムエラーが発生していたので、その解決方法を調べた。
回避方法は見つかったけれど、スジが悪いので別解がほしい。
問題
試行1
64bit版Vimから一部の64bit版のPythonモジュールを呼び出せない? ・ Issue #302 ・ vim-jp/issues を参考に C:\Windows\SysWOW64\pywintypes27.dll へ以下の manifest を埋め込んでみても現象は変わらず。
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0"> <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3"> <security> <requestedPrivileges> <requestedExecutionLevel level="asInvoker" uiAccess="false"></requestedExecutionLevel> </requestedPrivileges> </security> </trustInfo> <dependency> <dependentAssembly> <assemblyIdentity type="win32" name="Microsoft.VC90.CRT" version="9.0.21022.8" processorArchitecture="x86" publicKeyToken="1fc8b3b9a1e18e3b"></assemblyIdentity> </dependentAssembly> </dependency> </assembly>
Resource Type: 24 Resource Name: 1 Resource Language: 1033
32bit なのでこれで良いと思っているんだけど、それも違うのかな?
加えて C:\Windows\SysWOW64\python27.dll へも同様の対応を取ってみたが、こちらも変わらず。
試行2
python - Runtime Error with Vim Omnicompletion - Stack Overflow と同様に gvim.exe の manifest を入れ替えてやると動くようになった。
コマンドプロンプトから
"C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\vcvarsall.bat" x86 mt.exe -inputresource:M:\OLS\Program\Python27\python.exe;#1 -out:M:\ols\Text\vim\python.exe.manifest mt.exe -inputresource:M:\ols\Text\vim\gvim.exe;#1 -out:M:\ols\Text\vim\gvim.exe.org.manifest REM gvim.exe.org.manifest の dependency - dependentAssembly - assemblyIdentity を python.exe.manifest のものに書き換えて gvim.exe.manifest で保存。 mt.exe -manifest M:\ols\Text\vim\gvim.exe.manifest -outputresource:M:\ols\Text\vim\gvim.exe;1
gvim.exe.manifest
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0" xmlns:asmv3="urn:schemas-microsoft-com:asm.v3"> <assemblyIdentity processorArchitecture="*" version="7.3.0.0" type="win32" name="Vim"></assemblyIdentity> <description>Vi Improved - A Text Editor</description> <dependency> <dependentAssembly> <assemblyIdentity type="win32" name="Microsoft.VC90.CRT" version="9.0.21022.8" processorArchitecture="x86" publicKeyToken="1fc8b3b9a1e18e3b"></assemblyIdentity> </dependentAssembly> </dependency> <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3"> <security> <requestedPrivileges> <requestedExecutionLevel level="asInvoker" uiAccess="false"></requestedExecutionLevel> </requestedPrivileges> </security> </trustInfo> <asmv3:application> <asmv3:windowsSettings xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings"> <dpiAware>true</dpiAware> </asmv3:windowsSettings> </asmv3:application> </assembly>
試行3
gvim.exe にこのような manifest を埋め込んでやるのはおかしいよね? ということで別解を探したけど見つからず。
試行2 の結果、補完時に gvim.exe 読み込まれている DLL 【1】とエラーとなった際に読み込まれている DLL 【2】を比べてみると、【1】は wxPython 関係の DLL が幾つか多く読み込まれていた(他にもあったけど)。ということで、そいつらに manifest を埋め込んでやれば gvim での対応は不要になるのではないかと考えている。でもこれ全部に? ということで躊躇してしまっている。ということで、今は gvim.exe に埋め込めばいいやと落ち着いた。
補足
pyhack の成果発表時に libpython は? という話が出たので探してみたところ、 M:\OLS\Program\Python27\libs\libpython27.a があるらしいことはわかったけれど、これをどうすれば良いのかまではわからず。
Windows で Fabric に自動応答させる
環境作り
env.py -c fabric easy_install pycrypto-2.6.win32-py2.7.exe easy_install fabric
winexpect
Python Fabric で、自動応答 -- pexpect - Guutaraの日記 を試してみたけれど、pexpect は Windows では動かないらしい。
代わりということで winpexpect を使ってみた。
easy_install pywin32-218.win32-py2.7.exe easy_install winpexpect
試しに実行。
fab init [127.0.0.1:2222] Executing task 'init' Traceback (most recent call last): File "C:\virtualenv\fabric\lib\site-packages\fabric-1.6.0-py2.7.egg\fabric\main.py", line 739, in main *args, **kwargs File "C:\virtualenv\fabric\lib\site-packages\fabric-1.6.0-py2.7.egg\fabric\tasks.py", line 316, in execute multiprocessing File "C:\virtualenv\fabric\lib\site-packages\fabric-1.6.0-py2.7.egg\fabric\tasks.py", line 213, in _execute return task.run(*args, **kwargs) File "C:\virtualenv\fabric\lib\site-packages\fabric-1.6.0-py2.7.egg\fabric\tasks.py", line 123, in run return self.wrapped(*args, **kwargs) File "C:\Users\hokorobi\Documents\Program\Python\fabric\vagrant\fabfile.py", line 16, in init fexpect('init_aptget', 'Do you want to continue', 'Y') File "C:\Users\hokorobi\Documents\Program\Python\fabric\vagrant\fabfile.py", line 10, in fexpect child = winspawn(cmd) File "C:\virtualenv\fabric\lib\site-packages\winpexpect-1.5-py2.7.egg\winpexpect.py", line 346, in __init__ logfile=logfile, cwd=cwd, env=env) File "C:\virtualenv\fabric\lib\site-packages\winpexpect-1.5-py2.7.egg\pexpect.py", line 429, in __init__ self._spawn (command, args) File "C:\virtualenv\fabric\lib\site-packages\winpexpect-1.5-py2.7.egg\winpexpect.py", line 401, in _spawn startupinfo) pywintypes.error: (2, 'CreateProcess', '\x8ew\x92\xe8\x82\xb3\x82\xea\x82\xbd\x83t\x83@\x83C\x83\x8b\x82\xaa\x8c\xa9\x82\xc2\x82\xa9\x82\xe8\x82\xdc\x82\xb9\x82\xf1\x81B')
どうも virtualenv を使っていると駄目みたい。
sys.exec_prefix の python.exe を見にいっているみたいで、virtualenv を使っていると python.exe は Scripts の中にあるのか。
とりあえず素の環境でこんなの動かした。
fork 版 winexpect
winpexpect / weyou こちらの winpexpect だと virtualenv でも使えるみたい。
env.py fabric pip uninstall winpexpect hg clone ssh://hg@bitbucket.org/weyou/winpexpect cd winpexpect python setup.py install fab init
動いた。
#PPx fenrir を使ってインクリメンタルサーチでタブを選択
タブ選択メニュー表示 #PPx: - hokorobiの日記 ではメニューを使っていたけれど、インクリメンタルサーチで選択したいので、こんな感じに変更。
できないよな〜とずいぶん前に悩んでいたけど、思いついたら簡単だった。
- 表示しているタブのパスを fenrir の path へ出力。(普段使いの fenrir とは別物)
- その path を使う fenrir を起動。
- 選択したパスを表示しているタブが PPx にあるので、それを表示する。