rubypython 0.3.2 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.autotest +3 -0
- data/.gemtest +0 -0
- data/.gitignore +13 -0
- data/.hgignore +14 -0
- data/.hgtags +7 -0
- data/.rspec +1 -1
- data/Contributors.rdoc +9 -0
- data/History.rdoc +148 -0
- data/{License.txt → License.rdoc} +7 -1
- data/Manifest.txt +15 -10
- data/PostInstall.txt +11 -4
- data/README.rdoc +272 -0
- data/Rakefile +107 -22
- data/autotest/discover.rb +1 -0
- data/lib/rubypython.rb +214 -120
- data/lib/rubypython/blankobject.rb +16 -14
- data/lib/rubypython/conversion.rb +242 -173
- data/lib/rubypython/legacy.rb +30 -31
- data/lib/rubypython/macros.rb +43 -34
- data/lib/rubypython/operators.rb +103 -101
- data/lib/rubypython/options.rb +41 -44
- data/lib/rubypython/pygenerator.rb +61 -0
- data/lib/rubypython/pymainclass.rb +46 -29
- data/lib/rubypython/pyobject.rb +193 -177
- data/lib/rubypython/python.rb +189 -176
- data/lib/rubypython/pythonerror.rb +54 -63
- data/lib/rubypython/pythonexec.rb +123 -0
- data/lib/rubypython/rubypyproxy.rb +213 -137
- data/lib/rubypython/type.rb +20 -0
- data/spec/basic_spec.rb +50 -0
- data/spec/callback_spec.rb +7 -17
- data/spec/conversion_spec.rb +7 -21
- data/spec/legacy_spec.rb +1 -16
- data/spec/pymainclass_spec.rb +6 -15
- data/spec/pyobject_spec.rb +39 -64
- data/spec/python_helpers/basics.py +20 -0
- data/spec/python_helpers/objects.py +24 -20
- data/spec/pythonerror_spec.rb +5 -17
- data/spec/refcnt_spec.rb +4 -10
- data/spec/rubypyclass_spec.rb +1 -11
- data/spec/rubypyproxy_spec.rb +45 -54
- data/spec/rubypython_spec.rb +45 -57
- data/spec/spec_helper.rb +49 -33
- metadata +87 -63
- data.tar.gz.sig +0 -0
- data/History.markdown +0 -97
- data/README.markdown +0 -105
- data/lib/rubypython/core_ext/string.rb +0 -7
- data/lib/rubypython/version.rb +0 -9
- data/spec/python_helpers/objects.pyc +0 -0
- metadata.gz.sig +0 -0
data.tar.gz.sig
DELETED
Binary file
|
data/History.markdown
DELETED
@@ -1,97 +0,0 @@
|
|
1
|
-
## 0.3.2 2011-02-02
|
2
|
-
* Major Enhancements
|
3
|
-
* Allow procs and methods to be passed to Ruby.
|
4
|
-
* Allow configuration of the loaded Python library.
|
5
|
-
|
6
|
-
## 0.3.1 2011-01-19
|
7
|
-
* Compatability Updates
|
8
|
-
* Cleanup of code which finds Python library thanks to Austin Ziegler.
|
9
|
-
|
10
|
-
## 0.3.0 2010-09-06
|
11
|
-
* Major Enhancements
|
12
|
-
* Version 0.3.0 represents an almost complete rewrite of the RubyPython codebase.
|
13
|
-
* A native C extension is no longer required. RubyPython uses the 'ffi' gem.
|
14
|
-
* RubyPython by default now returns proxy instances for all Ruby objects. See the documentation for more information.
|
15
|
-
* Compatibility Updates
|
16
|
-
* Version 0.3.0 was created with the goal of being compatible with as many Ruby versions as possible. It should at the very least run on MRI 1.8.6 - 1.9.1.
|
17
|
-
* A legacy mode option has been added to provide partial compatibility with version 0.2.x.
|
18
|
-
|
19
|
-
## 0.2.11 2010-07-12
|
20
|
-
* Bug Fixes
|
21
|
-
* Fixed some issues with building the extension under ruby 1.9. Sould now be truly 1.9 compatible.
|
22
|
-
|
23
|
-
## 0.2.10 2010-07-08
|
24
|
-
* Bug Fixes
|
25
|
-
* Made some changes to how the native extension is configured and build.
|
26
|
-
|
27
|
-
## 0.2.9 2009-10-19
|
28
|
-
* Minor Enhancements
|
29
|
-
* Updated the C code to make it cleaner, more readable, and more maintainable.
|
30
|
-
|
31
|
-
## 0.2.8 2009-10-05
|
32
|
-
* Bug Fixes
|
33
|
-
* Some test files were improperly formatted (minor bug fix).
|
34
|
-
|
35
|
-
## 0.2.7 2009-3-30
|
36
|
-
* Bug Fixes
|
37
|
-
* Fixed some bugs which caused rubypython to be unable to determine python version correctly.
|
38
|
-
|
39
|
-
## 0.2.6 2009-3-19
|
40
|
-
* Bug Fixes
|
41
|
-
* Further updates to increase compatibility with 1.9.
|
42
|
-
|
43
|
-
## 0.2.5 2009-3-18
|
44
|
-
* Bug Fixes
|
45
|
-
* Updated to build and run under Ruby 1.9.
|
46
|
-
|
47
|
-
## 0.2.4 2008-10-24
|
48
|
-
* Major Enhancements
|
49
|
-
* Provided setter methods for object attributes. Python object attributes can now be set from within ruby.
|
50
|
-
* Made wrapper classes a subclass of custom made blank object class to try to avoid name collisions.
|
51
|
-
* Bug Fix
|
52
|
-
* Changed part of extconf.rb file that would not work under windows.
|
53
|
-
|
54
|
-
## 0.2.3 2008-08-29
|
55
|
-
* 2 Major Enhancements
|
56
|
-
* Introduced PyMain object as a singleton wrapper for the Python __main__ and __builtin__ modules.
|
57
|
-
* Introduced block functionality for PyMain object.
|
58
|
-
|
59
|
-
* Compatibility Updates
|
60
|
-
* Changed some declarations in the C code to make RubyPython more compatible with the style conventions of the Ruby C API.
|
61
|
-
* Update how RubyPython locates the Python headers and library.
|
62
|
-
* 1 Bug Fix
|
63
|
-
* Fixed an error in ptor.c that might have prevented RubyPython from building correctly on certain systems.
|
64
|
-
|
65
|
-
|
66
|
-
## 0.2.2 2008-08-07
|
67
|
-
* Major Enhancements
|
68
|
-
* Wrapped classes and instances should now behave as expected.
|
69
|
-
* Gave RubyPyClasses a "new" method for creating instances.
|
70
|
-
* Callable class can now be called provided that at least one argument is given
|
71
|
-
* A wrapped object's respond_to? method now has some relation to its actual methods.
|
72
|
-
|
73
|
-
* Bug fixes
|
74
|
-
* Fixed bug with inspect method of RubyPyObject that caused a bus error when inspecting certain objects
|
75
|
-
|
76
|
-
|
77
|
-
## 0.2.1 2008-08-02
|
78
|
-
* 1 Bug Fix
|
79
|
-
* Incorrect require fixed
|
80
|
-
|
81
|
-
## 0.2.0 2008-08-02
|
82
|
-
* 3 major enhancements
|
83
|
-
* RubyPython can now effectively convert or wrap most types from Python.
|
84
|
-
* Errors in the Python interpreter are relayed to Ruby errors.
|
85
|
-
* Less seg faults by mass.
|
86
|
-
* Bug Fixes
|
87
|
-
* RubyPython.run did not work correctly. This is fixed now.
|
88
|
-
* Cleanup in RubyPython.stop fixes some issues in RubyPythonBridge.stop
|
89
|
-
|
90
|
-
## 0.1.0 2008-08-01
|
91
|
-
* A lot of major enhancements
|
92
|
-
* Too many to name. Hey I'm still developing
|
93
|
-
|
94
|
-
## 0.0.1 2008-07-30
|
95
|
-
|
96
|
-
* 1 major enhancement:
|
97
|
-
* Initial release
|
data/README.markdown
DELETED
@@ -1,105 +0,0 @@
|
|
1
|
-
# RubyPython
|
2
|
-
|
3
|
-
* [RubyPython](http://bitbucket.org/raineszm/rubypython/)
|
4
|
-
|
5
|
-
## DESCRIPTION:
|
6
|
-
|
7
|
-
RubyPython is a bridge between the Ruby and Python interpreters. It embeds a
|
8
|
-
running Python interpreter in the application's process using FFI and
|
9
|
-
provides a means for wrapping and converting Python objects.
|
10
|
-
|
11
|
-
## FEATURES/PROBLEMS:
|
12
|
-
|
13
|
-
### Features
|
14
|
-
|
15
|
-
* Can handle simple conversion of Python builtin types to Ruby builtin types and vice versa
|
16
|
-
* Can import Python modules
|
17
|
-
* Can execute arbitrary methods on imported modules and return the result
|
18
|
-
* Python objects can be treated as Ruby objects!
|
19
|
-
* Python's standard library available to you from within Ruby.
|
20
|
-
* Pass Ruby methods and procs as callbacks and call them from within Python code.
|
21
|
-
* Specify the python executable to be loaded.
|
22
|
-
|
23
|
-
### Known Problems
|
24
|
-
|
25
|
-
* Builtin Python methods which require a top level frame object (eval, dir, ...) do not work properly at present.
|
26
|
-
* There is no support for passing more complicated Ruby types to Python.
|
27
|
-
|
28
|
-
## SYNOPSIS:
|
29
|
-
RubyPython lets you leverage the power of the Python standard library while
|
30
|
-
using the syntactical power of ruby. Using RubyPython you can write code such
|
31
|
-
as:
|
32
|
-
|
33
|
-
RubyPython.start
|
34
|
-
cPickle = RubyPython.import("cPickle")
|
35
|
-
p cPickle.dumps("RubyPython is awesome!").rubify
|
36
|
-
RubyPython.stop
|
37
|
-
|
38
|
-
The main point of the gem is to allow access to tools that are not readily availible in Ruby. However, it is clear that many people may wish to use Ruby tools with Python code bases using this library. The largest problem in this case is that there is no support for passing Ruby classes, procs, or methods to Python. That being said, with some creative coding it is still possible to do a lot.
|
39
|
-
|
40
|
-
One caveat is that it may be tempting to try to translate Python code to Ruby code directly using RubyPython. However, it often makes much more sense to use idiomatic Ruby code where possible. For example if we have the following Python code:
|
41
|
-
|
42
|
-
import library
|
43
|
-
for i in library.a_list:
|
44
|
-
print(library.function_call(i))
|
45
|
-
|
46
|
-
If we wanted for some reason to migrate this to RubyPython, we could do it as follows:
|
47
|
-
|
48
|
-
RubyPython.start
|
49
|
-
library = RubyPython.import 'library'
|
50
|
-
library.a_list.to_a.each { |i| puts library.function_call(i).rubify }
|
51
|
-
RubyPython.stop
|
52
|
-
|
53
|
-
There are several things to note about the code above:
|
54
|
-
|
55
|
-
1. We made sure to call RubyPython.start before doing anything with the Python interpreter.
|
56
|
-
1. We manually bound our imported library to a local variable. RubyPython will not do that for us.
|
57
|
-
1. We used to\_a to convert a python iterable type to a Ruby array.
|
58
|
-
1. We called rubify before we printed the objects so that they would be displayed as native Ruby objects.
|
59
|
-
1. We stopped the interpreter after we were done with RubyPython.stop.
|
60
|
-
|
61
|
-
## REQUIREMENTS:
|
62
|
-
|
63
|
-
* Python >= 2.4, < 3.0
|
64
|
-
* Ruby >= 1.8.6
|
65
|
-
* You must be able to build the ffi gem under your environment.
|
66
|
-
|
67
|
-
Note: RubyPython has been tested on Mac OS 10.5.x
|
68
|
-
|
69
|
-
|
70
|
-
## INSTALL:
|
71
|
-
|
72
|
-
[sudo] gem install rubypython
|
73
|
-
|
74
|
-
## DOCUMENTATION:
|
75
|
-
|
76
|
-
The documentation should provide a reasonable description of how to use RubyPython.
|
77
|
-
Starting with version 0.3.x there are two modes of operation: normal and
|
78
|
-
legacy. These are described in the docs.
|
79
|
-
|
80
|
-
The most useful to check out [docs](http://rubydoc.info/gems/rubypython/) will be those for RubyPython and RubyPython::RubyPyProxy.
|
81
|
-
|
82
|
-
## LICENSE:
|
83
|
-
|
84
|
-
(The MIT License)
|
85
|
-
|
86
|
-
Copyright (c) 2008-2011 Zach Raines
|
87
|
-
|
88
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
89
|
-
a copy of this software and associated documentation files (the
|
90
|
-
'Software'), to deal in the Software without restriction, including
|
91
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
92
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
93
|
-
permit persons to whom the Software is furnished to do so, subject to
|
94
|
-
the following conditions:
|
95
|
-
|
96
|
-
The above copyright notice and this permission notice shall be
|
97
|
-
included in all copies or substantial portions of the Software.
|
98
|
-
|
99
|
-
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
100
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
101
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
102
|
-
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
103
|
-
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
104
|
-
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
105
|
-
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/lib/rubypython/version.rb
DELETED
Binary file
|
metadata.gz.sig
DELETED
Binary file
|