-
Notifications
You must be signed in to change notification settings - Fork 278
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ruby wrappers initial file structure and Basic class #414
Ruby wrappers initial file structure and Basic class #414
Conversation
I think this looks good so far. |
The next step is to try to create the actual wrappers by compiling a simple C++ code and calling it from Ruby. |
I will say that if you want to use a different spec library, you're welcome to. We use rspec because we had hoped originally to incorporate NMatrix into ruby-core. These days that's less likely. I know some people prefer cucumber. Just have a good justification for it. =) |
Looks good so far. Looking forward to seeing some wrapper code. Tag me when you push some. =) |
So I went through this blog and a few other places. What I have guessed is RSpec tests it the way a developer would like it to, to make sure all works as he intended them. More like the unit tests. Whereas, Cucumber tests it the way a client/consumer would expect from the software. Like the integration tests. Most of the places, people suggest that both go hand in hand. But is it really required to have integration testing while writing the wrappers? Feels like overkill. Since I am new, I would like you to suggest. |
The tests are needed to ensure the wrappers work correctly (things like Sent from my mobile phone.
|
95d0f2f
to
d1d56af
Compare
#unless have_library("libcsympy") | ||
# raise "libcsympy not found" | ||
#end | ||
#How is libcsympy installed? Not able to find libcsympy |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@certik I couldn't find anything like libcsympy. How is csympy's library installed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It depends how you install symengine, but it is either src/libsymengine.a
or src/libsymengine.so
. After it gets installed, it will be in lib/
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still no luck. I searched in /lib
, /usr/lib
, /usr/local/lib
and /opt/lib
.
@abinashmeher999 thanks for pushing your latest changes in. How do I compile it? Can you write step by step instructions how you test this? I'll try to get it working on my machine and then provide some feedback. |
@certik They are actually incomplete now. There will be errors. I will put that in a separate README.md in the |
Thanks, I'll try it out later today. Why not just wrap a single function, to make sure the wrappers compile, and then iteratively keep adding more and more functions, while making sure the wrappers still compile? |
Ok. I will do that. |
Hi @abinashmeher999! Good work so far. :) Please, don't forget to update |
@agarie yes, exactly. Thanks for looking at it. |
@agarie Thanks for having a look at it. I haven't forgotten that. I will surely update it after I set building of ruby extensions from |
@abinashmeher999 here is what I tried, per your instructions:
I previously compiled symengine with:
Can you tell me what you get when you run |
e55152b
to
4ccf13f
Compare
@certik Seems you are missing bundler. I forgot to mention this. |
basic_free(basic_ptr); | ||
} | ||
|
||
static VALUE cbasic_alloc(VALUE klass){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line generates the following error:
ruby_basic.c:8:14: error: ‘cbasic_alloc’ defined but not used [-Werror=unused-function]
static VALUE cbasic_alloc(VALUE klass){
^
I think that's because the function is declared static
, so it is local to this file. I don't think you should declare it as static.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had referred to this guide for declaring functions. I will give a try without static
and post the results.
@certik I apologise for the delay. The good news is the wrappers compile ✨ . The bad news is I still can't load them from ruby interpreter . I am on it. |
gem.authors = ['Abinash Meher'] | ||
gem.email = ["abinashdakshana999@gmail.com"] | ||
gem.extensions = ['ext/symengine/extconf.rb'] | ||
gem.files = Dir["lib/**/*.rb", "bin/*", "LICENSE", "*.md"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With lib/**/*.rb
you are excluding lib/symengine/symengine.so
. That's why you are getting a file not found error
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@isuruf I can't thank you enough. I was stuck at this for a while now. This is exactly the thing I was missing. 😌
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @isuruf!
@abinashmeher999 please push in the working wrappers, so that others can try your PR out.
@abinashmeher999 can you post step by step instructions how to compile it?
How do I install the rake/extensiontask? I wasn't able to find it online. (I posted the same question on gitter yesterday: https://gitter.im/sympy/symengine?at=557e0be7c030cae67ed3a339.) |
@certik, there's a README in src/ruby. I was able to build it using the instructions there. Two things he missed was, build shared libs for libsymengine and do |
The installation instructions are insufficient for me. Here is a better version: # Steps to compile the extensions
## Install RVM
None of this requires root access.
Follow the instructions at https://rvm.io to install RVM, e.g.:
gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3
curl -sSL https://get.rvm.io | bash -s stable
Then use RVM to install Ruby and dependencies:
rvm autolibs disable
rvm install ruby --with-openssl-dir=$HASHSTACK
gem install bundler
## Install SymEngine
cmake -DCOMMON_DIR=$HASHSTACK -DWITH_RUBY=yes -DBUILD_SHARED_LIBS=yes .
make
## Install the Ruby wrappers
cd src/ruby
bundle install
rake compile When I follow these steps, the last
How do you fix this error? Are you perhaps installing symengine and then giving |
This seems to fix it: --- a/src/ruby/ext/symengine/extconf.rb
+++ b/src/ruby/ext/symengine/extconf.rb
@@ -14,6 +14,8 @@ HEADER_DIRS = [
# Check the ruby install locations
INCLUDEDIR,
+ '/home/certik/repos/symengine/src',
+
# Finally fall back to /usr
'/usr/include'
] So clearly something is wrong. |
Currently, the extconf.rb searches for header files mentioned in '/opt/local/include', '/usr/local/include', '/usr/include' and the include dir of the path where ruby is installed, like it is |
Anyway, so I did:
@abinashmeher999, @isuruf, how did you manage to load it? |
I now followed the steps I posted above in a new terminal to make sure things work when started from scratch. All went fine, until:
It's missing the gmp include, but somehow previously it found it... This can be fixed by: index bf426f2..70a0bf6 100644
--- a/src/ruby/ext/symengine/extconf.rb
+++ b/src/ruby/ext/symengine/extconf.rb
@@ -14,6 +14,9 @@ HEADER_DIRS = [
# Check the ruby install locations
INCLUDEDIR,
+ '/home/certik/repos/symengine/src',
+ '/local/certik/bld/profile/xt33omorophg/include',
+
# Finally fall back to /usr
'/usr/include'
] |
@isuruf Could you please check why shippable is failing. I keep getting this message
|
One test timed out which is unrelated to the PR. I've restarted the build On Mon, Jun 22, 2015 at 1:02 PM, Abinash Meher notifications@github.com
|
An unrelated question. The config files are very similar for both travis-ci and shippable. Any specific reason we are testing this at both the places? |
I think that looks good enough to be merged. The shippable failure is just some timeout, that is a bug at Shippable, so I think we can ignore it. Can you create a few nice commits out of these? The 49 commits are not needed in my opinion, as they show some of the dead ends when we were trying to figure out how to write the wrappers. For other people it will be much easier to see in the git history instead of the 49 commits. Why don't you create a few nice commits, then we can merge it. |
578b16a
to
a3f217a
Compare
Deleted Rakefile and extconf.rb
Currently only for operators like +,-,*,/,**,and -@ Rewrote Ruby C wrappers w/o typedefed array basic - Removed the `basic` type variables because they were not required - Changed the incorrect code in wrappers - Removed the `static` qualifier in wrappers - Added functions for binary, unary op
test passes and also pending tests
Added display messages in CMakeLists.txt for Ruby Added WITH_RUBY flags to CMakeLists.txt
Added src/ruby/pkg Added src/ruby/LICENSE
for building and testing the extensions
To avoid file duplication and also gem needs the LICENSE
to support new container-based infrastructure in travis-ci
a3f217a
to
7706f7c
Compare
@certik I have cleaned up the commit history. Please have a look. |
I think this looks very good. +1 to merge if tests pass. |
Tests pass on Travis, merging. |
Ruby wrappers initial file structure and Basic class
Addresses issue #413.
Most of the files are empty. I have tried to use the standard tools like RSpec and bundler which I am not very familiar with, but believe will prove to be very useful during the development. The main reason for choosing RSpec was because SciRuby prefers RSpec.
TODO list before we can merge this PR:
src/ruby/bin/htmldiff
is probably not needed)After this is merged, we will then expose more functionality of SymEngine (both in the C wrappers as well as the Ruby wrappers).