Rev 2327: Merge in pyrex branch. in file:///home/robertc/source/baz/pathinfo/

Robert Collins robertc at robertcollins.net
Fri Mar 9 06:56:21 GMT 2007


At file:///home/robertc/source/baz/pathinfo/

------------------------------------------------------------
revno: 2327
revision-id: robertc at robertcollins.net-20070309065618-ywyoek2q5sf3knht
parent: robertc at robertcollins.net-20070309061608-pau0d6iy2rss65lg
parent: robertc at robertcollins.net-20070308040606-84gsniv56huiyjt4
committer: Robert Collins <robertc at robertcollins.net>
branch nick: pathinfo
timestamp: Fri 2007-03-09 17:56:18 +1100
message:
  Merge in pyrex branch.
modified:
  HACKING                        HACKING-20050805200004-2a5dc975d870f78c
  Makefile                       Makefile-20050805140406-d96e3498bb61c5bb
  NEWS                           NEWS-20050323055033-4e00b5db738777ff
  bzr                            bzr.py-20050313053754-5485f144c7006fa6
  bzrlib/__init__.py             __init__.py-20050309040759-33e65acf91bbcd5d
  setup.py*                      setup.py-20050314065409-02f8a0a6e3f9bc70
    ------------------------------------------------------------
    revno: 1739.1.3
    merged: robertc at robertcollins.net-20070308040606-84gsniv56huiyjt4
    parent: robertc at robertcollins.net-20060609141337-4ea84d88e8d4dc0f
    parent: robertc at robertcollins.net-20070307120012-cgx5yk2cob9v0i92
    committer: Robert Collins <robertc at robertcollins.net>
    branch nick: pyrex
    timestamp: Thu 2007-03-08 15:06:06 +1100
    message:
      Merge bzr.dev.
        ------------------------------------------------------------
        revno: 2323.2.1
        merged: robertc at robertcollins.net-20070307120012-cgx5yk2cob9v0i92
        parent: pqm at pqm.ubuntu.com-20070307110538-3026a526f5178b00
        committer: Robert Collins <robertc at robertcollins.net>
        branch nick: integration
        timestamp: Wed 2007-03-07 23:00:12 +1100
        message:
          (robertc) Setup for 0.16 development.
    ------------------------------------------------------------
    revno: 1739.1.2
    merged: robertc at robertcollins.net-20060609141337-4ea84d88e8d4dc0f
    parent: robertc at robertcollins.net-20060604173418-51fbd7c12775039e
    committer: Robert Collins <robertc at robertcollins.net>
    branch nick: pyrex
    timestamp: Sat 2006-06-10 00:13:37 +1000
    message:
      More pyrex finesse, documentation.
    ------------------------------------------------------------
    revno: 1739.1.1
    merged: robertc at robertcollins.net-20060604173418-51fbd7c12775039e
    parent: pqm at pqm.ubuntu.com-20060603212040-9ec7af97aa11d4d7
    committer: Robert Collins <robertc at robertcollins.net>
    branch nick: pyrex
    timestamp: Mon 2006-06-05 03:34:18 +1000
    message:
      First cut at adding pyrex facilities.
=== modified file 'HACKING'
--- a/HACKING	2007-01-24 19:42:26 +0000
+++ b/HACKING	2007-03-08 04:06:06 +0000
@@ -632,6 +632,41 @@
 so, please reply and say so.)
 
 
+C Extension Modules
+===================
+
+We write some extensions in C using pyrex. We design these to work in
+three scenarios:
+ * User with no C compiler
+ * User with C compiler
+ * Developers
+
+The recommended way to install bzr is to have a C compiler so that the
+extensions can be built, but if no C compiler is present, the pure python
+versions we supply will work, though more slowly.
+
+For developers we recommend that pyrex be installed, so that the C
+extensions can be changed if needed.
+
+For the C extensions, the extension module should always match the
+original python one in all respects (modulo speed). This should be
+maintained over time.
+
+To create an extension, add rules to setup.py for building it with pyrex,
+and with distutils. Now start with an empty .pyx file. At the top add
+"include 'yourmodule.py'". This will import the contents of foo.py into this 
+file at build time - remember that only one module will be loaded at
+runtime. Now you can subclass classes, or replace functions, and only your
+changes need to be present in the .pyx file.
+
+Note that pyrex does not support all 2.4 programming idioms, so some
+syntax changes may be required. I.e. 
+ - 'from foo import (bar, gam)' needs to change to not use the brackets. 
+ - 'import foo.bar as bar' needs to be 'import foo.bar; bar = foo.bar' 
+If the changes are too dramatic, consider
+maintaining the python code twice - once in the .pyx, and once in the .py,
+and no longer including the .py file.
+
 Making installers for OS Windows
 ================================
 To build a win32 installer, see the instructions on the wiki page:

=== modified file 'Makefile'
--- a/Makefile	2007-01-30 12:45:50 +0000
+++ b/Makefile	2007-03-08 04:06:06 +0000
@@ -1,6 +1,8 @@
-all:
+all: 
+	@echo "building extension modules."
+	./setup.py build_ext -i
 
-check:
+check: all
 	python -Werror ./bzr selftest -v $(tests)
 	@echo "Running all tests with no locale."
 	LC_CTYPE= LANG=C LC_ALL= ./bzr selftest -v $(tests)

=== modified file 'NEWS'
--- a/NEWS	2007-03-07 11:34:48 +0000
+++ b/NEWS	2007-03-09 06:56:18 +0000
@@ -1,3 +1,5 @@
+IN DEVELOPMENT
+ 
 bzr 0.15rc1  2007-03-07
 
   SURPRISES:

=== modified file 'bzr'
--- a/bzr	2007-03-06 08:05:08 +0000
+++ b/bzr	2007-03-07 12:00:12 +0000
@@ -84,7 +84,7 @@
 import bzrlib.commands
 import bzrlib.trace
 
-if bzrlib.version_info[:3] != (0, 15, 0):
+if bzrlib.version_info[:3] != (0, 16, 0):
     sys.stderr.write("bzr: WARNING: bzrlib version doesn't match the bzr program.\n"
             "This may indicate an installation problem.\n"
             "bzrlib from %s is version %r\n"

=== modified file 'bzrlib/__init__.py'
--- a/bzrlib/__init__.py	2007-03-07 11:34:48 +0000
+++ b/bzrlib/__init__.py	2007-03-09 06:56:18 +0000
@@ -35,7 +35,7 @@
 # Python version 2.0 is (2, 0, 0, 'final', 0)."  Additionally we use a
 # releaselevel of 'dev' for unreleased under-development code.
 
-version_info = (0, 15, 0, 'candidate', 0)
+version_info = (0, 16, 0, 'dev', 0)
 
 if version_info[3] == 'final':
     version_string = '%d.%d.%d' % version_info[:3]

=== modified file 'setup.py' (properties changed)
--- a/setup.py	2007-01-30 12:13:18 +0000
+++ b/setup.py	2007-03-08 04:06:06 +0000
@@ -147,6 +147,25 @@
 ## Setup
 ########################
 
+command_classes = {'install_scripts': my_install_scripts,
+                  'build': bzr_build}
+ext_modules = []
+try:
+    from Pyrex.Distutils import build_ext
+except ImportError:
+    # try to build the extension from the prior generated source.
+    print ("Pyrex not available, while bzr will build"
+           ", you cannot modify the C extensions.")
+    from distutils.command import build_ext
+    from distutils.extension import Extension
+    #ext_modules.append(
+    #    Extension("bzrlib.modulename", ["bzrlib/foo.c"], libraries = []))
+else:
+    from distutils.extension import Extension
+    #ext_modules.append(
+    #    Extension("bzrlib.modulename", ["bzrlib/foo.pyx"], libraries = []))
+command_classes['build_ext'] = build_ext
+
 if 'bdist_wininst' in sys.argv:
     import glob
     # doc files
@@ -218,9 +237,8 @@
     # std setup
     ARGS = {'scripts': ['bzr'],
             'data_files': [('man/man1', ['bzr.1'])],
-            'cmdclass': {'build': bzr_build,
-                         'install_scripts': my_install_scripts,
-                        },
+            'cmdclass': command_classes,
+            'ext_modules': ext_modules,
            }
     
     ARGS.update(META_INFO)



More information about the bazaar-commits mailing list