You are viewing a plain text version of this content. The canonical link for it is here.
Posted to pylucene-commits@lucene.apache.org by va...@apache.org on 2010/05/19 00:34:35 UTC

svn commit: r945938 - in /lucene/pylucene/trunk/jcc: CHANGES helpers/build.py helpers/mingw32.py setup.py

Author: vajda
Date: Tue May 18 22:34:34 2010
New Revision: 945938

URL: http://svn.apache.org/viewvc?rev=945938&view=rev
Log:
 - config.py now written only during build or when missing (Christian Heimes)

Added:
    lucene/pylucene/trunk/jcc/helpers/build.py   (with props)
Modified:
    lucene/pylucene/trunk/jcc/CHANGES
    lucene/pylucene/trunk/jcc/helpers/mingw32.py
    lucene/pylucene/trunk/jcc/setup.py

Modified: lucene/pylucene/trunk/jcc/CHANGES
URL: http://svn.apache.org/viewvc/lucene/pylucene/trunk/jcc/CHANGES?rev=945938&r1=945937&r2=945938&view=diff
==============================================================================
--- lucene/pylucene/trunk/jcc/CHANGES (original)
+++ lucene/pylucene/trunk/jcc/CHANGES Tue May 18 22:34:34 2010
@@ -20,6 +20,7 @@ Version 2.5 ->
  - fixed bug with array Release calls using isCopy instead of 0 mode
  - added support for --import
  - added read-only env.classpath property
+ - config.py now written only during build or when missing (Christian Heimes)
  - 
 
 Version 2.4 -> 2.5

Added: lucene/pylucene/trunk/jcc/helpers/build.py
URL: http://svn.apache.org/viewvc/lucene/pylucene/trunk/jcc/helpers/build.py?rev=945938&view=auto
==============================================================================
--- lucene/pylucene/trunk/jcc/helpers/build.py (added)
+++ lucene/pylucene/trunk/jcc/helpers/build.py Tue May 18 22:34:34 2010
@@ -0,0 +1,46 @@
+#   Licensed under the Apache License, Version 2.0 (the "License");
+#   you may not use this file except in compliance with the License.
+#   You may obtain a copy of the License at
+#
+#       http://www.apache.org/licenses/LICENSE-2.0
+#
+#   Unless required by applicable law or agreed to in writing, software
+#   distributed under the License is distributed on an "AS IS" BASIS,
+#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#   See the License for the specific language governing permissions and
+#   limitations under the License.
+
+import os
+
+from distutils.command.build_py import build_py
+from distutils import log
+
+class jcc_build_py(build_py):
+    config_text = None
+    config_file = None
+
+    def run(self):
+        self.write_jcc_config()
+        return build_py.run(self)
+
+    def write_jcc_config(self):
+        # only write jcc's config.py file if it doesn't exist or a build 
+        # command is given
+        write = False
+        if not os.path.isfile(self.config_file):
+            write = True
+        else:
+            for command in self.distribution.commands:
+                if command.startswith("build"):
+                    write = True
+                    break
+
+        if write:
+            log.info("writing %s" %(self.config_file))
+            config = open(self.config_file, 'w')
+            try:
+                config.write(self.config_text)
+            finally:
+                config.close()
+        else:
+            log.info("not writing %s" %(self.config_file))

Propchange: lucene/pylucene/trunk/jcc/helpers/build.py
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: lucene/pylucene/trunk/jcc/helpers/build.py
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: lucene/pylucene/trunk/jcc/helpers/mingw32.py
URL: http://svn.apache.org/viewvc/lucene/pylucene/trunk/jcc/helpers/mingw32.py?rev=945938&r1=945937&r2=945938&view=diff
==============================================================================
--- lucene/pylucene/trunk/jcc/helpers/mingw32.py (original)
+++ lucene/pylucene/trunk/jcc/helpers/mingw32.py Tue May 18 22:34:34 2010
@@ -1,3 +1,14 @@
+#   Licensed under the Apache License, Version 2.0 (the "License");
+#   you may not use this file except in compliance with the License.
+#   You may obtain a copy of the License at
+#
+#       http://www.apache.org/licenses/LICENSE-2.0
+#
+#   Unless required by applicable law or agreed to in writing, software
+#   distributed under the License is distributed on an "AS IS" BASIS,
+#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#   See the License for the specific language governing permissions and
+#   limitations under the License.
 
 import os, copy
 from distutils.cygwinccompiler import Mingw32CCompiler

Modified: lucene/pylucene/trunk/jcc/setup.py
URL: http://svn.apache.org/viewvc/lucene/pylucene/trunk/jcc/setup.py?rev=945938&r1=945937&r2=945938&view=diff
==============================================================================
--- lucene/pylucene/trunk/jcc/setup.py (original)
+++ lucene/pylucene/trunk/jcc/setup.py Tue May 18 22:34:34 2010
@@ -211,17 +211,20 @@ def main(debug):
     else:
         _javac = JAVAC[platform]
 
-    config = file(os.path.join(os.path.dirname(os.path.abspath(__file__)),
-                               'jcc', 'config.py'), 'w')
-    print >>config
-    print >>config, 'INCLUDES=%s' %(_includes)
-    print >>config, 'CFLAGS=%s' %(_cflags)
-    print >>config, 'DEBUG_CFLAGS=%s' %(_debug_cflags)
-    print >>config, 'LFLAGS=%s' %(_lflags)
-    print >>config, 'SHARED=%s' %(enable_shared)
-    print >>config, 'VERSION="%s"' %(jcc_ver)
-    print >>config
-    config.close()
+    from helpers.build import jcc_build_py
+
+    jcc_build_py.config_file = \
+        os.path.join(os.path.dirname(os.path.abspath(__file__)),
+                     'jcc', 'config.py')
+    jcc_build_py.config_text = \
+        '\n'.join(['',
+                   'INCLUDES=%s' %(_includes),
+                   'CFLAGS=%s' %(_cflags),
+                   'DEBUG_CFLAGS=%s' %(_debug_cflags),
+                   'LFLAGS=%s' %(_lflags),
+                   'SHARED=%s' %(enable_shared),
+                   'VERSION="%s"' %(jcc_ver),
+                   ''])
 
     extensions = []
 
@@ -325,7 +328,8 @@ def main(debug):
         'packages': ['jcc'],
         'package_dir': {'jcc': 'jcc'},
         'package_data': {'jcc': package_data},
-        'ext_modules': extensions
+        'ext_modules': extensions,
+        "cmdclass": {"build_py": jcc_build_py},
     }
     if with_setuptools:
         args['zip_safe'] = False