Python3でscons

#Python3でscons
Python3でもsconsを使えるようにします。
多くのライブラリがPython3に対応してきていますが、sconsはいまだに対応が完了していないので、非公式版を利用します。

##ソースコードの取得
sconsの[公式バージョン](http://www.scons.org/)はいまだにPython3には対応していないので、forkされてPython3に移植されたソースコード([こちら](https://bitbucket.org/userzimmermann/scons/branch/python3-port))を利用します。

```bash
hg clone https://bitbucket.org/userzimmermann/scons
cd scons
hg pull && hg update python3-port
```

##ソースコードの修正
src/setup.pyに少し問題があって、ビルド中にエラーになるので修正します。
※バージョン番号の部分が\_\_VERSION__になっているので、気になる方は各自で修正してください

```patch:diff.patch
diff -r 6679e468ada7 src/setup.py
--- a/src/setup.py	Sun Apr 06 10:50:33 2014 -0400
+++ b/src/setup.py	Wed Sep 03 16:00:20 2014 +0900
@@ -368,19 +368,19 @@ class install_data(_install_data):
 description = "Open Source next-generation build tool."
 
 long_description = """Open Source next-generation build tool.
 Improved, cross-platform substitute for the classic Make
 utility.  In short, SCons is an easier, more reliable
 and faster way to build software."""
 
 scripts = [
-    'script/scons',
-    'script/sconsign',
-    'script/scons-time',
+    'script/scons.py',
+    'script/sconsign.py',
+    'script/scons-time.py',
 
     # We include scons.bat in the list of scripts, even on UNIX systems,
     # because we provide an option to allow it be installed explicitly,
     # for example if you're installing from UNIX on a share that's
     # accessible to Windows and you want the scons.bat.
     'script/scons.bat',
 ]
 
@@ -402,78 +402,87 @@ arguments = {
                           "SCons.Tool",
                           "SCons.Tool.docbook",
                           "SCons.Tool.MSCommon",
                           "SCons.Tool.packaging",
                           "SCons.Variables",
                          ],
     'package_dir'      : {'' : 'engine',
                           'SCons.Tool.docbook' : 'engine/SCons/Tool/docbook'},
-    'package_data'     : {'SCons.Tool.docbook' : ['docbook-xsl-1.76.1/*',
+    'package_data'     : {'SCons.Tool.docbook' : ['docbook-xsl-1.76.1/*.*',
+                                                  'docbook-xsl-1.76.1/AUTHORS',
+                                                  'docbook-xsl-1.76.1/BUGS',
+                                                  'docbook-xsl-1.76.1/COPYING',
+                                                  'docbook-xsl-1.76.1/INSTALL',
+                                                  'docbook-xsl-1.76.1/Makefile',
+                                                  'docbook-xsl-1.76.1/NEWS',
+                                                  'docbook-xsl-1.76.1/README',
+                                                  'docbook-xsl-1.76.1/TODO',
+                                                  'docbook-xsl-1.76.1/VERSION',
                                                   'docbook-xsl-1.76.1/common/*',
                                                   'docbook-xsl-1.76.1/docsrc/*',
                                                   'docbook-xsl-1.76.1/eclipse/*',
-                                                  'docbook-xsl-1.76.1/epub/*',
-                                                  'docbook-xsl-1.76.1/epub/bin/*',
+                                                  'docbook-xsl-1.76.1/epub/docbook.xsl',
+                                                  'docbook-xsl-1.76.1/epub/README',
+                                                  'docbook-xsl-1.76.1/epub/bin/dbtoepub',
                                                   'docbook-xsl-1.76.1/epub/bin/lib/*',
                                                   'docbook-xsl-1.76.1/epub/bin/xslt/*',
                                                   'docbook-xsl-1.76.1/extensions/*',
                                                   'docbook-xsl-1.76.1/fo/*',
                                                   'docbook-xsl-1.76.1/highlighting/*',
                                                   'docbook-xsl-1.76.1/html/*',
                                                   'docbook-xsl-1.76.1/htmlhelp/*',
-                                                  'docbook-xsl-1.76.1/images/*',
+                                                  'docbook-xsl-1.76.1/images/*.svg',
                                                   'docbook-xsl-1.76.1/images/callouts/*',
                                                   'docbook-xsl-1.76.1/images/colorsvg/*',
                                                   'docbook-xsl-1.76.1/javahelp/*',
                                                   'docbook-xsl-1.76.1/lib/*',
                                                   'docbook-xsl-1.76.1/manpages/*',
                                                   'docbook-xsl-1.76.1/params/*',
                                                   'docbook-xsl-1.76.1/profiling/*',
                                                   'docbook-xsl-1.76.1/roundtrip/*',
                                                   'docbook-xsl-1.76.1/slides/browser/*',
                                                   'docbook-xsl-1.76.1/slides/fo/*',
                                                   'docbook-xsl-1.76.1/slides/graphics/*',
                                                   'docbook-xsl-1.76.1/slides/graphics/active/*',
                                                   'docbook-xsl-1.76.1/slides/graphics/inactive/*',
                                                   'docbook-xsl-1.76.1/slides/graphics/toc/*',
                                                   'docbook-xsl-1.76.1/slides/html/*',
                                                   'docbook-xsl-1.76.1/slides/htmlhelp/*',
-                                                  'docbook-xsl-1.76.1/slides/keynote/*',
+                                                  'docbook-xsl-1.76.1/slides/keynote/default.xsl',
                                                   'docbook-xsl-1.76.1/slides/keynote/xsltsl/*',
                                                   'docbook-xsl-1.76.1/slides/svg/*',
                                                   'docbook-xsl-1.76.1/slides/xhtml/*',
                                                   'docbook-xsl-1.76.1/template/*',
                                                   'docbook-xsl-1.76.1/tests/*',
                                                   'docbook-xsl-1.76.1/tools/bin/*',
                                                   'docbook-xsl-1.76.1/tools/make/*',
-                                                  'docbook-xsl-1.76.1/webhelp/*',
-                                                  'docbook-xsl-1.76.1/webhelp/docs/*',
-                                                  'docbook-xsl-1.76.1/webhelp/docs/common/*',
+                                                  'docbook-xsl-1.76.1/webhelp/LICENSE',
+                                                  'docbook-xsl-1.76.1/webhelp/docs/index.html',
+                                                  'docbook-xsl-1.76.1/webhelp/docs/common/main.js',
                                                   'docbook-xsl-1.76.1/webhelp/docs/common/css/*',
                                                   'docbook-xsl-1.76.1/webhelp/docs/common/images/*',
-                                                  'docbook-xsl-1.76.1/webhelp/docs/common/jquery/*',
+                                                  'docbook-xsl-1.76.1/webhelp/docs/common/jquery/*.js',
                                                   'docbook-xsl-1.76.1/webhelp/docs/common/jquery/theme-redmond/*',
                                                   'docbook-xsl-1.76.1/webhelp/docs/common/jquery/theme-redmond/images/*',
                                                   'docbook-xsl-1.76.1/webhelp/docs/common/jquery/treeview/*',
                                                   'docbook-xsl-1.76.1/webhelp/docs/common/jquery/treeview/images/*',
-                                                  'docbook-xsl-1.76.1/webhelp/docs/content/*',
-                                                  'docbook-xsl-1.76.1/webhelp/docs/content/search/*',
+                                                  'docbook-xsl-1.76.1/webhelp/docs/content/*.html',
+                                                  'docbook-xsl-1.76.1/webhelp/docs/content/search/*.js',
                                                   'docbook-xsl-1.76.1/webhelp/docs/content/search/stemmers/*',
                                                   'docbook-xsl-1.76.1/webhelp/docsrc/*',
-                                                  'docbook-xsl-1.76.1/webhelp/template/*',
-                                                  'docbook-xsl-1.76.1/webhelp/template/common/*',
+                                                  'docbook-xsl-1.76.1/webhelp/template/common/main.js',
                                                   'docbook-xsl-1.76.1/webhelp/template/common/css/*',
                                                   'docbook-xsl-1.76.1/webhelp/template/common/images/*',
-                                                  'docbook-xsl-1.76.1/webhelp/template/common/jquery/*',
+                                                  'docbook-xsl-1.76.1/webhelp/template/common/jquery/*.js',
                                                   'docbook-xsl-1.76.1/webhelp/template/common/jquery/theme-redmond/*',
                                                   'docbook-xsl-1.76.1/webhelp/template/common/jquery/theme-redmond/images/*',
                                                   'docbook-xsl-1.76.1/webhelp/template/common/jquery/treeview/*',
                                                   'docbook-xsl-1.76.1/webhelp/template/common/jquery/treeview/images/*',
-                                                  'docbook-xsl-1.76.1/webhelp/template/content/search/*',
+                                                  'docbook-xsl-1.76.1/webhelp/template/content/search/*.*',
                                                   'docbook-xsl-1.76.1/webhelp/template/content/search/stemmers/*',
                                                   'docbook-xsl-1.76.1/webhelp/xsl/*',
                                                   'docbook-xsl-1.76.1/website/*',
                                                   'docbook-xsl-1.76.1/xhtml/*',
                                                   'docbook-xsl-1.76.1/xhtml-1_1/*',
                                                   'utils/*']},
     'data_files'       : [('man/man1', man_pages)],
     'scripts'          : scripts,

```

##ビルド＆インストール
あとは、srcディレクトリに移動してビルド＆インストールするだけ
※バージョン番号の部分が\_\_VERSION__になっているので、気になる方は各自で修正してください

```bash
cd src
python setup.py build
python setup.py install
```

##最後に
実際に移植版のsconsを利用してみて、私の使い方が悪いのかバグなのかはわかりませんが、ファイルが変更されていないのでスキップされるはずの部分がスキップされないというのが、一度だけありました。この問題はSConstructの書き方を変えると解決しました。
他に問題は発生していないので、十分実用に耐えると思います。

それでは、日本語環境下でのsconsを存分に堪能してください。