rubypython 0.2.2 → 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt CHANGED
@@ -1,3 +1,17 @@
1
+ == 0.2.3 2008-08-29
2
+ * 2 Major Enhancements
3
+ * Introduced PyMain object to as a singleton wrapper for the Python __main__ and
4
+ __builtin__ modules.
5
+ * Introduced block functionality for PyMain object.
6
+
7
+ * Compatibility Updates
8
+ * Changed some declarations in the C code make RubyPython more compatible with the style
9
+ conventions of the Ruby C API.
10
+ * Update how RubyPython locates the Python headers and library.
11
+ * 1 Bug Fix
12
+ * Fixed an error in ptor.c that might have prevented RubyPython from building correctly
13
+ on certain systems.
14
+
1
15
  == 0.2.2 2008-08-07
2
16
  * Major Enhancements
3
17
  * Wrapped classes and instances should now behave as expected.
data/config/hoe.rb CHANGED
@@ -63,7 +63,9 @@ $hoe = Hoe.new(GEM_NAME, VERS) do |p|
63
63
  p.changes = p.paragraphs_of("History.txt", 0..1).join("\n\n")
64
64
  #p.extra_deps = EXTRA_DEPENDENCIES
65
65
 
66
- #p.spec_extras = {} # A hash of extra values to set in the gemspec.
66
+ p.spec_extras = {
67
+ :requirements => ["Python, ~>2.4"]
68
+ } # A hash of extra values to set in the gemspec.
67
69
  end
68
70
 
69
71
  CHANGES = $hoe.paragraphs_of('History.txt', 0..1).join("\\n\\n")
@@ -1,6 +1,6 @@
1
1
  #ifndef _PYTHON_H_
2
2
  #define _PYTHON_H_
3
- #include "python2.5/Python.h"
3
+ #include "Python.h"
4
4
  #endif /* _PYTHON_H_ */
5
5
 
6
6
  #ifndef _STDLIB_H_
@@ -1,7 +1,22 @@
1
1
  require 'mkmf'
2
+ require 'open3'
3
+
4
+ if (Open3.popen3("python --version") { |i,o,e| e.read}.chomp.split[1].to_f < 2.4)
5
+ puts "I'm sorry you need at least Python 2.4 to use rubypython"
6
+ exit -1
7
+ end
2
8
 
3
9
  dir_config("rubypython_bridge")
4
- find_library("python2.5",nil)
5
- find_header("python2.5/Python.h")
10
+ if(!`which python-config`)
11
+ print "Can't configure with python_config"
12
+ exit -1
13
+ end
14
+
15
+ unless find_library("python2.5",nil)||find("python2.4",nil)
16
+ puts "Could not find python libraries"
17
+ exit -1
18
+ end
19
+
20
+ find_header("Python.h",*`python-config --includes`.split.map{|s| s[2..-1]<<"/"})
6
21
 
7
22
  create_makefile("rubypython_bridge")
@@ -47,7 +47,7 @@ VALUE ptor_long(PyObject* pNum)
47
47
  cNum=PyLong_AsLong(pNum);
48
48
  if(PyErr_ExceptionMatches(PyExc_OverflowError))
49
49
  {
50
- raise_PyError();
50
+ rp_pythonerror();
51
51
  return Qnil;
52
52
  }
53
53
  rNum=INT2NUM(cNum);
@@ -1,8 +1,8 @@
1
1
  #include "rp_object.h"
2
2
  #include "stdio.h"
3
3
 
4
- extern VALUE mRubyPythonBridge;
5
- extern VALUE ePythonError;
4
+ RUBY_EXTERN VALUE mRubyPythonBridge;
5
+ RUBY_EXTERN VALUE ePythonError;
6
6
 
7
7
  VALUE cRubyPyObject;
8
8
  VALUE cRubyPyModule;
@@ -1,6 +1,6 @@
1
1
  #include "rtop.h"
2
2
 
3
- extern VALUE cRubyPyObject;
3
+ RUBY_EXTERN VALUE cRubyPyObject;
4
4
 
5
5
  PyObject* rtop_string(VALUE rString)
6
6
  {
@@ -1,9 +1,9 @@
1
1
  #include "rubypython_bridge.h"
2
2
 
3
3
  VALUE mRubyPythonBridge;
4
- extern VALUE cRubyPyObject;
5
- extern VALUE cRubyPyModule;
6
- extern VALUE cRubyPyClass;
4
+ RUBY_EXTERN VALUE cRubyPyObject;
5
+ RUBY_EXTERN VALUE cRubyPyModule;
6
+ RUBY_EXTERN VALUE cRubyPyClass;
7
7
 
8
8
 
9
9
  /*
@@ -2,7 +2,7 @@ module RubyPython
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 0
4
4
  MINOR = 2
5
- TINY = 2
5
+ TINY = 3
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
@@ -1,3 +1,4 @@
1
+ require 'singleton'
1
2
  class RubyPythonBridge::RubyPyObject
2
3
  def inspect
3
4
  "<#{self.class}:#{__name}>"
@@ -5,6 +6,47 @@ class RubyPythonBridge::RubyPyObject
5
6
  end
6
7
 
7
8
 
9
+ # A singleton object providing access to the python __main__ and __builtin__ modules.
10
+ # This can be conveniently accessed through the already instaniated PyMain constant.
11
+ # The __main__ namespace is searched beofre the __builtin__ namespace. As such,
12
+ # naming clashes will be resolved in that order.
13
+ #
14
+ # == Block Syntax
15
+ # The PyMainClass object provides somewhat experimental block support.
16
+ # A block may be passed to a method call and the object returned by the function call
17
+ # will be passed as an argument to the block.
18
+ class PyMainClass
19
+ include Singleton
20
+ #:nodoc:
21
+ def main
22
+ @main||=RubyPython.import "__main__"
23
+ end
24
+
25
+ #:nodoc:
26
+ def builtin
27
+ @builtin||=RubyPython.import "__builtin__"
28
+ end
29
+
30
+ #:nodoc:
31
+ def method_missing(name,*args,&block)
32
+ begin
33
+ result=main.send(name,*args)
34
+ rescue NoMethodError
35
+ begin
36
+ result=builtin.send(name,*args)
37
+ rescue NoMethodError
38
+ super(name,*args)
39
+ end
40
+ end
41
+ if(block)
42
+ return block.call(result)
43
+ end
44
+ end
45
+ end
46
+
47
+ # See _PyMainClass_
48
+ PyMain=PyMainClass.instance
49
+
8
50
  # A wrapper class for Python Modules.
9
51
  #
10
52
  # Methods calls are delegated to the equivalent Python methods/functions. Attribute references
@@ -30,14 +30,14 @@ class TestRubypython < Test::Unit::TestCase
30
30
  assert(RubyPython.stop)
31
31
  end
32
32
 
33
- def test_double_import
33
+ def test_two_imports
34
34
  RubyPython.start
35
35
  RubyPython.import "cPickle"
36
36
  RubyPython.import "urllib"
37
37
  RubyPython.stop
38
38
  end
39
39
 
40
- def test_handle_error
40
+ def test_propogate_python_errror
41
41
  RubyPython.start
42
42
  assert_raise PythonError do
43
43
  RubyPython.import "slasdfj"
data/website/index.html CHANGED
@@ -33,7 +33,7 @@
33
33
  <h1>rubypython</h1>
34
34
  <div id="version" class="clickable" onclick='document.location = "http://rubyforge.org/projects/rubypython"; return false'>
35
35
  <p>Get Version</p>
36
- <a href="http://rubyforge.org/projects/rubypython" class="numbers">0.2.2</a>
36
+ <a href="http://rubyforge.org/projects/rubypython" class="numbers">0.2.3</a>
37
37
  </div>
38
38
  <h2>What</h2>
39
39
  <p>RubyPython is a C bridge between Ruby and Python with a Ruby interface. It&#8217;s aim is to make the power of the Python&#8217;s great standard library available to Ruby programmers from within Ruby.<br />
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubypython
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Zach Raines
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-08-07 00:00:00 -04:00
12
+ date: 2008-08-29 00:00:00 -04:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
@@ -102,8 +102,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
102
102
  - !ruby/object:Gem::Version
103
103
  version: "0"
104
104
  version:
105
- requirements: []
106
-
105
+ requirements:
106
+ - Python, ~>2.4
107
107
  rubyforge_project: rubypython
108
108
  rubygems_version: 1.2.0
109
109
  signing_key: