インストール目標:
実現目標:
src=$HOME/src # my case tcl=$srcdir/tcl8.6b2 tk=$srcdir/tk8.6b2 rm -rf $src/build # if exists
$tcl/macosx
および $tk/macosx
の中には Makefile
と GNUmakefile
が含まれている。Mac/OSX の make
は実際には gnumake
なので、ファイルを指定しない場合には GNUmakefile
が使われる。そして、README には GNUmakefile
の使用が推奨されている。しかし、以下では Makefile
を使う。理由は、GNUmakefile
を思うように操るのが困難だったからである。
cd $tcl.macosx export CFLAGS="-arch i386 -arch x86_64" ./configure --enable-framework make -f Makefile
-bash$ ls -l Tcl -rwxr-xr-x 1 arisawa staff 2552984 4 7 14:22 Tcl -bash$ ls -l tclsh -rwxr-xr-x 1 arisawa staff 37496 4 7 14:22 tclsh -bash$ file Tcl Tcl: Mach-O universal binary with 2 architectures Tcl (for architecture i386): Mach-O dynamically linked shared library i386 Tcl (for architecture x86_64): Mach-O 64-bit dynamically linked shared library x86_64 -bash$ file tclsh tclsh: Mach-O universal binary with 2 architectures tclsh (for architecture i386): Mach-O executable i386 tclsh (for architecture x86_64): Mach-O 64-bit executable x86_64 -bash$
sudo make -f Makefile install
-bash$ ls -l /usr/local/bin/tcl* -rwxr-xr-x 1 root wheel 12728 3 27 07:48 /usr/local/bin/tclsh8.5 -rwxr-xr-x 1 root wheel 37496 4 7 15:11 /usr/local/bin/tclsh8.6 -bash$ -bash$ ls -l /usr/local/libtcl* /usr/local/tcl* ls: /usr/local/libtcl*: No such file or directory ls: /usr/local/tcl*: No such file or directory -bash$ -bash$ ls -l /Library/Frameworks/Tcl.framework total 56 lrwxr-xr-x 1 root admin 24 4 7 15:11 Headers -> Versions/Current/Headers lrwxr-xr-x 1 root admin 31 4 7 15:11 PrivateHeaders -> Versions/Current/PrivateHeaders lrwxr-xr-x 1 root admin 26 4 7 15:11 Resources -> Versions/Current/Resources lrwxr-xr-x 1 root admin 20 4 7 15:11 Tcl -> Versions/Current/Tcl drwxr-xr-x 5 root admin 170 4 7 15:11 Versions lrwxr-xr-x 1 root admin 28 3 27 07:48 libtclstub8.5.a -> Versions/8.5/libtclstub8.5.a lrwxr-xr-x 1 root admin 28 4 7 15:11 libtclstub8.6.a -> Versions/8.6/libtclstub8.6.a lrwxr-xr-x 1 root admin 29 4 7 15:11 tclConfig.sh -> Versions/Current/tclConfig.sh -bash$ ls -l /Library/Frameworks/Tcl.framework/Versions total 8 drwxr-xr-x 9 root admin 306 3 27 07:48 8.5 drwxr-xr-x 10 root admin 340 4 7 15:11 8.6 lrwxr-xr-x 1 root admin 3 4 7 15:11 Current -> 8.6 -bash$ ls -l /Library/Frameworks/Tcl.framework/Versions/8.6 total 5040 drwxr-xr-x 9 root admin 306 4 7 15:11 Headers drwxr-xr-x 10 root admin 340 4 7 15:11 PrivateHeaders drwxr-xr-x 7 root admin 238 4 7 15:11 Resources -r-xr-xr-x 1 root admin 2552984 4 7 15:11 Tcl -rw-r--r-- 1 root admin 9608 4 7 15:11 libtclstub8.6.a drwxr-xr-x 3 root admin 102 4 7 15:11 pkgconfig -rw-r--r-- 1 root admin 6280 4 7 15:11 tclConfig.sh -rw-r--r--@ 1 root admin 788 4 7 15:11 tclooConfig.sh -bash$
-bash$ /usr/local/bin/tclsh8.6 % puts $tcl_patchLevel 8.6b2 % puts $tcl_library /Library/Frameworks/Tcl.framework/Versions/8.6/Resources/Scripts %
cd $tk/macosx export CFLAGS="-arch i386 -arch x86_64" ./configure --enable-framework --enable-aqua make -f Makefile
-bash$ ls -l wish -rwxr-xr-x 1 arisawa staff 66504 4 7 15:32 wish -bash$ ls -l Tk -rwxr-xr-x 1 arisawa staff 2779248 4 7 15:32 Tk -bash$ file wish wish: Mach-O universal binary with 2 architectures wish (for architecture i386): Mach-O executable i386 wish (for architecture x86_64): Mach-O 64-bit executable x86_64 -bash$ file Tk Tk: Mach-O universal binary with 2 architectures Tk (for architecture i386): Mach-O dynamically linked shared library i386 Tk (for architecture x86_64): Mach-O 64-bit dynamically linked shared library x86_64 -bash$
sudo make -f Makefile install
-bash$ ls -l /usr/local/bin/wish* -rwxr-xr-x 1 root wheel 123 3 27 07:55 /usr/local/bin/wish8.5 -rwxr-xr-x 1 root wheel 123 4 7 15:44 /usr/local/bin/wish8.6 -bash$ ls -ld /usr/local/lib/libtk* /usr/local/lib/tk* lrwxr-xr-x 1 root wheel 48 4 6 18:14 /usr/local/lib/libtk8.5.dylib -> /Library/Frameworks/Tk.framework/Versions/8.5/Tk lrwxr-xr-x 1 root wheel 60 4 6 18:14 /usr/local/lib/libtkstub8.5.a -> /Library/Frameworks/Tk.framework/Versions/8.5/libtkstub8.5.a drwxr-xr-x 37 root wheel 1258 3 18 17:59 /usr/local/lib/tk8.5 -rw-r--r-- 1 root wheel 3551 4 4 06:18 /usr/local/lib/tkConfig.sh -bash$ ls -l /Library/Frameworks/Tk.framework total 56 lrwxr-xr-x 1 root admin 24 4 7 15:44 Headers -> Versions/Current/Headers lrwxr-xr-x 1 root admin 31 4 7 15:44 PrivateHeaders -> Versions/Current/PrivateHeaders lrwxr-xr-x 1 root admin 26 4 7 15:44 Resources -> Versions/Current/Resources lrwxr-xr-x 1 root admin 19 4 7 15:44 Tk -> Versions/Current/Tk drwxr-xr-x 5 root admin 170 4 7 15:44 Versions lrwxr-xr-x 1 root admin 27 3 27 07:55 libtkstub8.5.a -> Versions/8.5/libtkstub8.5.a lrwxr-xr-x 1 root admin 27 4 7 15:44 libtkstub8.6.a -> Versions/8.6/libtkstub8.6.a lrwxr-xr-x 1 root admin 28 4 7 15:44 tkConfig.sh -> Versions/Current/tkConfig.sh -bash$ ls -l /Library/Frameworks/Tk.framework/Versions total 8 drwxr-xr-x 9 root admin 306 3 27 07:55 8.5 drwxr-xr-x 9 root admin 306 4 7 15:44 8.6 lrwxr-xr-x 1 root admin 3 4 7 15:44 Current -> 8.6 -bash$ ls -l /Library/Frameworks/Tk.framework/Versions/8.6 total 5464 drwxr-xr-x 8 root admin 272 4 7 15:44 Headers drwxr-xr-x 11 root admin 374 4 7 15:44 PrivateHeaders drwxr-xr-x 9 root admin 306 4 7 15:44 Resources -r-xr-xr-x 1 root admin 2779248 4 7 15:44 Tk -rw-r--r-- 1 root admin 11544 4 7 15:44 libtkstub8.6.a drwxr-xr-x 3 root admin 102 4 7 15:44 pkgconfig -rw-r--r-- 1 root admin 3512 4 7 15:44 tkConfig.sh -bash$
/usr/local/bin/wish8.6 a.tclを実行すれば、次図の結果を得る。
-bash$ /usr/local/bin/wish8.6 a.tcl 8.6b2 8.6b2 /Library/Frameworks/Tcl.framework/Versions/8.6/Resources/Scripts /Library/Frameworks/Tk.framework/Versions/8.6/Resources/Scripts -bash$
-bash$ ls -l /usr/local/lib/libtcl* /usr/local/lib/libtk* lrwxr-xr-x 1 root wheel 50 4 7 17:03 /usr/local/lib/libtcl8.6.dylib -> /Library/Frameworks/Tcl.framework/Versions/8.6/Tcl lrwxr-xr-x 1 root wheel 62 4 7 17:01 /usr/local/lib/libtclstub8.6.a -> /Library/Frameworks/Tcl.framework/Versions/8.6/libtclstub8.6.a lrwxr-xr-x 1 root wheel 48 4 6 18:14 /usr/local/lib/libtk8.5.dylib -> /Library/Frameworks/Tk.framework/Versions/8.5/Tk lrwxr-xr-x 1 root wheel 48 4 7 17:02 /usr/local/lib/libtk8.6.dylib -> /Library/Frameworks/Tk.framework/Versions/8.6/Tk lrwxr-xr-x 1 root wheel 60 4 6 18:14 /usr/local/lib/libtkstub8.5.a -> /Library/Frameworks/Tk.framework/Versions/8.5/libtkstub8.5.a lrwxr-xr-x 1 root wheel 60 4 7 16:59 /usr/local/lib/libtkstub8.6.a -> /Library/Frameworks/Tk.framework/Versions/8.6/libtkstub8.6.a -bash$この作業は、Python のコンパイルのために必要
src=$HOME/src py=$src/Python-3.2.2 unset CFLAGS ./configure --enable-framework
Fix Makefile by inserting EXTLIBRARY as shown below. Fix by hand usig text editor.
LIBRARY= libpython$(VERSION)$(ABIFLAGS).a EXTLIBRARY = /usr/local/lib/libtk8.6.dylib \ /usr/local/lib/libtcl8.6.dylib \ /usr/local/lib/libtkstub8.6.a \ /usr/local/lib/libtclstub8.6.a \ /usr/local/lib/libintl.dylib
$(INSTALL) -d -m $(DIRMODE) $(PYTHONFRAMEWORKDIR)/Versions/$(VERSION) $(CC) -o $(LDLIBRARY) $(PY_LDFLAGS) -dynamiclib \ $(EXTLIBRARY) \ -all_load $(LIBRARY) -Wl,-single_module \
make CFLAGS="-arch i386 -arch x86_64"
running build running build_extここで停止する。CTRL-C で抜け出せる。結果は、
Python build finished, but the necessary bits to build these modules were not found: ossaudiodev readline spwd To find the necessary bits, look in setup.py in detect_modules() for the module's name. running build_scripts copying and adjusting /users/arisawa/src/Python-3.2.2/Tools/scripts/pydoc3 -> build/scripts-3.2 copying and adjusting /users/arisawa/src/Python-3.2.2/Tools/scripts/idle3 -> build/scripts-3.2 copying and adjusting /users/arisawa/src/Python-3.2.2/Tools/scripts/2to3 -> build/scripts-3.2 changing mode of build/scripts-3.2/pydoc3 from 644 to 755 changing mode of build/scripts-3.2/idle3 from 644 to 755 changing mode of build/scripts-3.2/2to3 from 644 to 755 renaming build/scripts-3.2/pydoc3 to build/scripts-3.2/pydoc3.2 renaming build/scripts-3.2/idle3 to build/scripts-3.2/idle3.2 renaming build/scripts-3.2/2to3 to build/scripts-3.2/2to3-3.2 -bash$
sudo make install CFLAGS="-arch i386 -arch x86_64"
/usr/local/bin
-bash$ ls -l /usr/local/bin/python* lrwxr-xr-x 1 root wheel 69 10 31 12:36 /usr/local/bin/python3 -> ../../../Library/Frameworks/Python.framework/Versions/3.2/bin/python3 lrwxr-xr-x 1 root wheel 72 10 31 12:36 /usr/local/bin/python3-32 -> ../../../Library/Frameworks/Python.framework/Versions/3.2/bin/python3-32 lrwxr-xr-x 1 root wheel 76 10 31 12:36 /usr/local/bin/python3-config -> ../../../Library/Frameworks/Python.framework/Versions/3.2/bin/python3-config lrwxr-xr-x 1 root wheel 71 10 31 12:36 /usr/local/bin/python3.2 -> ../../../Library/Frameworks/Python.framework/Versions/3.2/bin/python3.2 lrwxr-xr-x 1 root wheel 74 10 31 12:36 /usr/local/bin/python3.2-32 -> ../../../Library/Frameworks/Python.framework/Versions/3.2/bin/python3.2-32 lrwxr-xr-x 1 root wheel 78 10 31 12:36 /usr/local/bin/python3.2-config -> ../../../Library/Frameworks/Python.framework/Versions/3.2/bin/python3.2-config lrwxr-xr-x 1 root wheel 72 10 31 12:36 /usr/local/bin/python3.2m -> ../../../Library/Frameworks/Python.framework/Versions/3.2/bin/python3.2m lrwxr-xr-x 1 root wheel 79 10 31 12:36 /usr/local/bin/python3.2m-config -> ../../../Library/Frameworks/Python.framework/Versions/3.2/bin/python3.2m-config -bash$注意: この中には、今回のインストール以前のものも混じっている。今回インストールされたのは
/usr/local/bin/python3.2 /usr/local/bin/python3.2mのはずである。
"3.2
" の後のサフィックスの意味は、サポートされている arch であろう。file
コマンドで様子がわかる。
-bash$ file `ls /usr/local/bin/python3*` /usr/local/bin/python3: Mach-O universal binary with 2 architectures /usr/local/bin/python3 (for architecture i386): Mach-O executable i386 /usr/local/bin/python3 (for architecture x86_64): Mach-O 64-bit executable x86_64 /usr/local/bin/python3-32: Mach-O universal binary with 1 architecture /usr/local/bin/python3-32 (for architecture i386): Mach-O executable i386 /usr/local/bin/python3-config: a /Library/Frameworks/Python.fram script text executable /usr/local/bin/python3.2: Mach-O 64-bit executable x86_64 /usr/local/bin/python3.2-32: Mach-O universal binary with 1 architecture /usr/local/bin/python3.2-32 (for architecture i386): Mach-O executable i386 /usr/local/bin/python3.2-config: a /Library/Frameworks/Python.fram script text executable /usr/local/bin/python3.2m: Mach-O 64-bit executable x86_64 /usr/local/bin/python3.2m-config: a /Library/Frameworks/Python.fram script text executable -bash$
/Library/Frameworks/Python.framework
-bash$ ls -l /Library/Frameworks/Python.framework total 24 lrwxr-xr-x 1 root admin 24 4 7 17:34 Headers -> Versions/Current/Headers lrwxr-xr-x 1 root admin 23 4 7 17:34 Python -> Versions/Current/Python lrwxr-xr-x 1 root admin 26 4 7 17:34 Resources -> Versions/Current/Resources drwxr-xr-x 7 root admin 238 4 7 17:34 Versions -bash$ ls -l /Library/Frameworks/Python.framework/Versions total 8 drwxrwxr-x 10 root admin 340 5 22 2009 2.5 drwxrwxr-x 10 root admin 340 4 16 2009 2.6 drwxrwxr-x 10 root admin 340 3 27 08:23 2.7 drwxrwxr-x 9 root admin 306 4 7 17:34 3.2 lrwxr-xr-x 1 root admin 3 4 7 17:34 Current -> 3.2 -bash$ ls -l /Library/Frameworks/Python.framework/Versions/3.2 total 4944 lrwxr-xr-x 1 root admin 18 4 7 17:34 Headers -> include/python3.2m -r-xr-xr-x 1 root admin 2526992 4 7 17:34 Python drwxrwxr-x 5 root admin 170 10 31 12:36 Resources drwxrwxr-x 20 root admin 680 4 7 17:34 bin drwxrwxr-x 3 root admin 102 9 4 2011 include drwxrwxr-x 5 root admin 170 9 4 2011 lib drwxrwxr-x 4 root admin 136 9 4 2011 share -bash$ ls -l /Library/Frameworks/Python.framework/Versions/3.2/bin/python3* -rwxrwxr-x 1 root admin 25624 9 4 2011 /Library/Frameworks/Python.framework/Versions/3.2/bin/python3 lrwxr-xr-x 1 root admin 12 10 31 12:36 /Library/Frameworks/Python.framework/Versions/3.2/bin/python3-32 -> python3.2-32 lrwxr-xr-x 1 root admin 16 10 31 12:36 /Library/Frameworks/Python.framework/Versions/3.2/bin/python3-config -> python3.2-config -rwxr-xr-x 2 root admin 9296 4 7 17:34 /Library/Frameworks/Python.framework/Versions/3.2/bin/python3.2 -rwxrwxr-x 1 root admin 13928 9 4 2011 /Library/Frameworks/Python.framework/Versions/3.2/bin/python3.2-32 lrwxr-xr-x 1 root admin 17 10 31 12:36 /Library/Frameworks/Python.framework/Versions/3.2/bin/python3.2-config -> python3.2m-config -rwxr-xr-x 2 root admin 9296 4 7 17:34 /Library/Frameworks/Python.framework/Versions/3.2/bin/python3.2m -rwxrwxr-x 1 root admin 1865 9 4 2011 /Library/Frameworks/Python.framework/Versions/3.2/bin/python3.2m-config -bash$
tk.tcl
が見つからないと言われたら設定する)export TK_LIBRARY=/Library/Frameworks/Tk.framework/Versions/8.6/Resources/Scripts
-bash$ python3.2 Python 3.2.2 (default, Apr 7 2012, 17:12:01) [GCC 4.2.1 (Apple Inc. build 5646)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> import tkinter >>> tkinter.TclVersion 8.6 >>> tkinter.TkVersion 8.6 >>> tk=tkinter.Tk() >>> tk.getvar("tk_version") '8.6' >>> tk.getvar("tk_patchLevel") '8.6b2' >>> print(tk.getvar('tcl_library')) /Library/Frameworks/Tcl.framework/Versions/8.6/Resources/Scripts >>> print(tk.getvar("tk_library")) /Library/Frameworks/Tk.framework/Versions/8.6/Resources/Scripts >>>
#encoding: utf-8 from tkinter import * tk=Tk() c=Canvas(tk,width=300,height=200) c.pack(fill="both",expand=1) c.create_text(150,80,text="ABC",font=("Times",30,"italic")) c.create_text(150,120,text="いろは",font=("Hiragino Kaku Gothic Pro",30,"bold")) c.create_rectangle(100,50,200,150,outline="green") def cmd(): c.postscript(file="a.eps") tk.destroy() dir(tk) b=Button(tk,text="終了", command=cmd) b.pack() tk.mainloop()
a
はタプルであるためソートできない。そこでリスト b
に変換し、それをソートしている。
-bash$ python3.2 f.py AGENDAJinmeiGyoshotaiL1 AGENDAJinmeiSeikaishotaiL1 [中略] Helvetica Helvetica CY Helvetica Neue Herculanum Hiragino Kaku Gothic Pro Hiragino Kaku Gothic ProN Hiragino Kaku Gothic Std Hiragino Kaku Gothic StdN Hiragino Maru Gothic Pro Hiragino Maru Gothic ProN Hiragino Mincho Pro Hiragino Mincho ProN Hiragino Sans GB Hoefler Text [中略] jsMath-cmsy10 jsMath-cmti10 -bash$
Tcl/Tk の postscript コマンドで日本語文字が扱えるようにするためには、次の修正を行えば良い。もっと良い方法もあろうが、取りあえず、この方法で何とかなる。
mkpsenc.tcl
の修正ISOEncode
が、CMAP に対しては無効になる。
tkFont.c
の修正// begin Kenarの行から
// end Kenarまでの行を挿入する。デバッグコードも含まれているが、邪魔なら外す。
cd $tk/macosx make -f Makefile sudo make -f Makefile install「終了」ボタンをクリックすると、
a.eps
が生成される。
-bash$ ps2pdf -dEPSCrop a.eps -bash$ gs a.pdf -bash$ open -a "/Applications/Adobe Reader 9/Adobe Reader.app" a.pdfMac/OSX の Preview.app で開くと、Preview.app が潰れる! (潰れるのは Preview.app のバグ)
もっと、良い方法があるだろう。OSAKA フォントに関して問題があるかも知れない。
fmap
のところは、普通は fontmap
と書くところであるが、postscript
オプションの fontmap
と紛らわしいので、このプログラムでは敢えて fmap
とした。他の名前で構わない。
Tk
は Python が利用する Tk のダイナミックライブラリ(dylib)である。システム上に多数ある Tk
のどれとリンクするのか?
$py/setup.pyがコンパイル時に実行される。 これを見ると、
- /Library/Frameworks
- /System/Library/Frameworks
- $HOME/Library/Frameworks
の順で、Tk.framework/Tk
を探すことが分かる。