Commits

Ronald Oussoren  committed 8bdfeac

- Add 'File Templates' for various types of Python files (Xcode)
- make_distrib.py:
* Install the file templates where they will be picked up by Xcode
* Make the release-dir more usefull
- Update version number to 1.1a1
- Add getObjects:inRange: to OC_PythonArray
Cocoa calls this method when an instance of OC_PythonArray is used as
the value for setObject:forKey: in NSUserDefaults. Never mind that this
method is not documented...

  • Participants
  • Parent commits 83b7a85

Comments (0)

Files changed (15)

File pyobjc/Doc/gnustep.html

 build and pass some, but by far not all, unittests. More work is needed to
 make the GNUstep port as stable as the MacOS X &quot;port&quot;.</p>
 <p>The GNUstep port was primarily developed on Linux i86 (specifically 
-the Debian testing distribution), using python 2.3.2,  gcc 3.3.2 and 
-gnustep-base 1.7.3-1. The code in setup.py works for this configuration,
+the Debian testing distribution), using python 2.3.3,  gcc 3.3.2 and 
+gnustep-base1 1.9.0-1. The code in setup.py works for this configuration,
 but probably not for other configurations.</p>
+<p>GNUstep support is <i>very</i> fragile, in some versions of the the selectors for
+new classes should be strings, in others they should be SEL objects (as you
+would expect). We also use undocumented private functions to initialize new
+classes.</p>
 <h2><a name="todo">TODO</a></h2>
 <ul>
-<li>Fix bugs found using the unittests</li>
+<li>Fix the odd bug...<p>I currently get the following text when importing objc:</p>
+<pre>
+Unable to retrieve information about SIGPIPE
+</pre>
+<p>This text is not printed by PyObjC and I haven't been able to find who
+does print that text...</p>
+</li>
+<li>Fix bugs found using the unittests<p>runPyObjCTests finds some problems that disapear when those tests are run
+seperately...</p>
+</li>
 <li>Port the AppKit wrappers</li>
 <li>Extract more CFLAGS and LDFLAGS information from the GNUstep build system,
 instead of hard-coding the information</li>

File pyobjc/Lib/Foundation/test/test_nsuserdefaults.py

+import Foundation
+import unittest
+
+class PythonListAsValue (unittest.TestCase):
+
+    def testSettingPythonList(self):
+        defaults = Foundation.NSUserDefaults.standardUserDefaults()
+        defaults.setObject_forKey_(['a', 'b', 'c'], 'randomKey')
+
+        self.assertEquals(defaults.arrayForKey_('randomKey'), ['a', 'b', 'c'])
+
+if __name__ == "__main__":
+    unittest.main()

File pyobjc/Modules/objc/OC_PythonArray.h

  */
 -(void)replaceObjectAtIndex:(int)idx withObject:newValue;
 
+/*!
+ * @method getObjects:inRange:
+ * @abstract Fetch objects in the specified range
+ * @discussion The output buffer must have enough space to contain all
+ *             requested objects, the range must be valid.
+ *
+ *             This method is not documented in the NSArray interface, but
+ *             is used by Cocoa on MacOS X 10.3 when an instance of this
+ *             class is used as the value for -setObject:forKey: in
+ *             NSUserDefaults.
+ * @param buffer  The output buffer
+ * @param range   The range of objects to fetch.
+ */
+-(void)getObjects:(id*)buffer inRange:(NSRange)range;
+
 @end
 
 #endif /* OC_PythonArray_h */

File pyobjc/Modules/objc/OC_PythonArray.m

 	PyGILState_Release(state);
 }
 
+-(void)getObjects:(id*)buffer inRange:(NSRange)range
+{
+	unsigned int i;
+
+	for (i = 0; i < range.length; i++) {
+		buffer[i] = [self objectAtIndex:i+range.location];
+	}
+}
+
 @end /* implementation OC_PythonArray */

File pyobjc/Modules/objc/pyobjc.h

  * Central include file for PyObjC. 
  */
 
-#define OBJC_VERSION "1.1a0"
+#define OBJC_VERSION "1.1a1"
 
 #include <Python.h>
 #include "structmember.h"
 
 An overview of the relevant changes in new, and older, releases.
 
-Version "1.1a0" (2004-02-02)
-----------------------------
+Version 1.1a1 (2004-02-15?)
+---------------------------
+
+- Fixes some regressions in 1.1 w.r.t. 1.0
+
+- Add Xcode templates for python files
+
+  You can now select a new python file in the 'add file...' dialog in Xcode
+
+- Fix installer for Panther: the 1.1a0 version didn't behave correctly
+
+Version 1.1a0 (2004-02-02)
+--------------------------
+
 - Objective-C structs can now be wrapped using struct-like types. This has
   been used to implement wrapper types for NSPoint, NSSize, NSRange and NSRect
   in Foundation and NSAffineTransformStruct in AppKit.

File pyobjc/Scripts/make_distrib.py

     sys.exit(0)
 
 print "Running: '%s' setup.py sdist -d '%s'"%(
-        		escquotes(PYTHON), escquotes(OUTPUTDIR))
+        		escquotes(PYTHON), escquotes(os.path.dirname(OUTPUTDIR)))
 fd = os.popen("'%s' setup.py sdist -d '%s'"%(
-        		escquotes(PYTHON), escquotes(OUTPUTDIR)), 'r')
+        		escquotes(PYTHON), escquotes(os.path.dirname(OUTPUTDIR))), 'r')
 for ln in fd.xreadlines():
         sys.stdout.write(ln)
 
 # NOTE: We first install our scripts into the python tree and later on move
 # them to /usr/local to avoid clobbering a /usr/local symlink installed by
 # the user.
-print "Running: '%s' setup.py install --prefix='%s/package%s' --install-scripts=%s/package%s/lib/python%s/site-packages/PyObjC/bin"%(
+print "Running: '%s' setup.py install --prefix='%s/package%s' --install-scripts=%s/package/%s/lib/python%s/site-packages/PyObjC/bin"%(
         escquotes(PYTHON), escquotes(BUILDDIR), escquotes(basedir), escquotes(BUILDDIR), escquotes(basedir), PYTHONVER)
 fd = os.popen("'%s' setup.py install --prefix='%s/package%s' --install-scripts=%s/package%s/lib/python%s/site-packages/PyObjC/bin"%(
         escquotes(PYTHON), escquotes(BUILDDIR), escquotes(basedir), escquotes(BUILDDIR), escquotes(basedir), PYTHONVER), 'r')
         '%s/package%s/lib/python%s/site-packages/PyObjC.pth'%(BUILDDIR, basedir, PYTHONVER),
         '%s/package/Library/Python/%s/PyObjC.pth'%(BUILDDIR, PYTHONVER))
 
+    # Trash /System/Library/Frameworks/Python.framework in the to-be-installed
+    # tree, we don't want to replace those directories!
+    shutil.rmtree('%s/package/System'%(BUILDDIR,))
+
 print "Copying readme and license"
 shutil.copyfile("Installer Package/%s/ReadMe.html"%(osvers,), os.path.join(OUTPUTDIR, "ReadMe First.html"))
 shutil.copyfile("License.txt", os.path.join(OUTPUTDIR, "License.txt"))
         if not os.path.isdir(path): continue
         shutil.copytree(path, os.path.join(templateDestination, dname))
 
+    for dn in [ x for x in os.listdir('Xcode/File Templates') if x != 'CVS' ]:
+        makeDir(basedir, 
+                'Library', 'Application Support', 'Apple', 
+                'Developer Tools', 'File Templates', dn)
+        templateDestination = os.path.join(basedir, 
+                'Library', 'Application Support', 'Apple', 
+                'Developer Tools', 'File Templates', dn)
+        templateDir = os.path.join('Xcode', 'File Templates', dn)
+        for dname in os.listdir(templateDir):
+            if dname == 'CVS': continue
+            path = os.path.join(templateDir, dname)
+            if not os.path.isdir(path): continue
+            shutil.copytree(path, os.path.join(templateDestination, dname))
+
+
 else:
     raise ValueError, "Don't know how to build installer for %s"%(osvers,)
 
 # the binary PackMan installer (which is built manually)
 #
 print "Running: '%s' setup.py bdist -d '%s'"%(
-        		escquotes("python2.3"), escquotes(OUTPUTDIR))
+        		escquotes("python2.3"), escquotes(os.path.dirname(OUTPUTDIR)))
 fd = os.popen("'%s' setup.py bdist -d '%s'"%(
-        		escquotes("python2.3"), escquotes(OUTPUTDIR)), 'r')
+        		escquotes("python2.3"), escquotes(os.path.dirname(OUTPUTDIR))), 'r')
 for ln in fd.xreadlines():
         sys.stdout.write(ln)
 
         package_version(), package_version()))
 
 
+print "Creating a simple disk image"
+cmdline="hdiutil create -imagekey zlib-level=9 -srcfolder 'release-dir/PyObjC-%s' 'release-dir/pyobjc-%s-macosx%s.dmg'"%(
+        package_version(),
+        package_version(),
+        osvers,
+    )
+
+print "> ", cmdline
+os.system(cmdline)
+
 print "Done. Don't forget to test the output!"
-print "-- hdiutil create -imagekey zlib-level=9 -srcfolder PyObjC-1.1a0 pyobjc-1.1a0-panther.dmg"
-

File pyobjc/Xcode/File Templates/Cocoa/Python NIB class.pbfiletemplate/TemplateInfo.plist

+{
+	MainTemplateFile = "class.py";
+	Description = "A Python Cocoa-class file, imports Foundation. Use this for classes defined in a NIB file.";
+}

File pyobjc/Xcode/File Templates/Cocoa/Python NIB class.pbfiletemplate/class.py

+#
+#  «FILENAME»
+#  «PROJECTNAME»
+#
+#  Created by «FULLUSERNAME» on «DATE».
+#  Copyright (c) «YEAR» «ORGANIZATIONNAME». All rights reserved.
+#
+
+from Foundation import *
+from AppKit import *
+
+from PyObjCTools import NibClassBuilder
+
+class «FILEBASENAMEASIDENTIFIER»NibClassBuilder.AutoBaseClass):
+	pass

File pyobjc/Xcode/File Templates/Cocoa/Python class.pbfiletemplate/TemplateInfo.plist

+{
+	MainTemplateFile = "class.py";
+	Description = "A Python Cocoa-class file, imports Foundation.";
+}

File pyobjc/Xcode/File Templates/Cocoa/Python class.pbfiletemplate/class.py

+#
+#  «FILENAME»
+#  «PROJECTNAME»
+#
+#  Created by «FULLUSERNAME» on «DATE».
+#  Copyright (c) «YEAR» «ORGANIZATIONNAME». All rights reserved.
+#
+
+from Foundation import *
+
+class «FILEBASENAMEASIDENTIFIER» (NSObject):
+	pass

File pyobjc/Xcode/File Templates/pure python/Python module.pbfiletemplate/TemplateInfo.plist

+{
+	MainTemplateFile = "module.py";
+	Description = "A Python module";
+}

File pyobjc/Xcode/File Templates/pure python/Python module.pbfiletemplate/module.py

+#
+#  «FILENAME»
+#  «PROJECTNAME»
+#
+#  Created by «FULLUSERNAME» on «DATE».
+#  Copyright (c) «YEAR» «ORGANIZATIONNAME». All rights reserved.
+#

File pyobjc/Xcode/File Templates/pure python/Python tool.pbfiletemplate/TemplateInfo.plist

+{
+	MainTemplateFile = "tool.py";
+	Description = "A Python script";
+}

File pyobjc/Xcode/File Templates/pure python/Python tool.pbfiletemplate/tool.py

+#!/usr/bin/env python2.3
+#
+#  «FILENAME»
+#  «PROJECTNAME»
+#
+#  Created by «FULLUSERNAME» on «DATE».
+#  Copyright (c) «YEAR» «ORGANIZATIONNAME». All rights reserved.
+#
+