SciRuby / rb-gsl

Ruby interface to the GNU Scientific Library
https://github.com/SciRuby/rb-gsl
Other
100 stars 46 forks source link

Publish a new release to rubygems #67

Open ruipserra opened 2 years ago

ruipserra commented 2 years ago

66 was merged a few months ago adding Ruby 3 compatibility, but it's not available in rubygems.

Can you publish a new release? Thanks!

obromios commented 2 years ago

In the meantime, you can get commit with the #66 merge by inserting into your Gemfile gem 'gsl', git: 'git@github.com:SciRuby/rb-gsl.git', ref: '103a3e1'

Note that the gem name to use is gsl not rb-gsl. Can anyone tell me why on rubygems.org there are two gems gsl and rb-gsl but both point to the source code at git@github.com:SciRuby/rb-gsl.git'?

I tried the updated code with ruby 3.1.1 and it appears to work on this ruby version as well.

xanadiu commented 2 years ago

I am wondering how to "push" a new rubygems version. For anybody struggling with the lack of GitHub credentials, including the https url in my Gemfile worked for me:

gem 'gsl', git: 'https://github.com/SciRuby/rb-gsl.git', ref: '103a3e1'

simon-dedeo commented 9 months ago

For those who are still not using bundler, gemfiles, etc, here's how to install this version globally:

git clone git@github.com:SciRuby/rb-gsl.git
cd rb-gsl
git checkout 103a3e1
gem build *.gemspec
sudo gem install ./gsl-2.1.0.3.gem

This pulls the git repository, goes to katafract's fixed version (thank you!), builds the gem locally, and then installs. This works on Mac OS X 14.2 (Sonoma).

dgdosen commented 5 months ago

This approach was working for me running on macos Sonoma - but some update (Xcode? gcc? bundler?) has caused this this gem to stop working, and I can't reinstall it:

blas2.c:1084:3: error: incompatible function pointer types passing 'VALUE (VALUE, VALUE, VALUE, VALUE, VALUE, VALUE)' (aka 'unsigned long (unsigned long, unsigned long, unsigned long, unsigned long, unsigned long, unsigned
long)') to parameter of type 'VALUE (*)(VALUE, VALUE, VALUE, VALUE, VALUE)' (aka 'unsigned long (*)(unsigned long, unsigned long, unsigned long, unsigned long, unsigned long)') [-Wincompatible-function-pointer-types]
  rb_define_module_function(module, "dsyr2!", rb_gsl_blas_dsyr2, 4);
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/opt/homebrew/var/rbenv/versions/3.2.2/include/ruby-3.2.0/ruby/internal/anyargs.h:338:142: note: expanded from macro 'rb_define_module_function'
#define rb_define_module_function(mod, mid, func, arity)    RBIMPL_ANYARGS_DISPATCH_rb_define_module_function((arity), (func))((mod), (mid), (func), (arity))
                                                                                                                                             ^~~~~~
/opt/homebrew/var/rbenv/versions/3.2.2/include/ruby-3.2.0/ruby/internal/anyargs.h:274:1: note: passing argument to parameter here
RBIMPL_ANYARGS_DECL(rb_define_module_function, VALUE, const char *)
^
/opt/homebrew/var/rbenv/versions/3.2.2/include/ruby-3.2.0/ruby/internal/anyargs.h:259:72: note: expanded from macro 'RBIMPL_ANYARGS_DECL'
RBIMPL_ANYARGS_ATTRSET(sym) static void sym ## _04(__VA_ARGS__, VALUE(*)(VALUE, VALUE, VALUE, VALUE, VALUE), int); \
                                                                       ^
blas2.c:1085:3: error: incompatible function pointer types passing 'VALUE (VALUE, VALUE, VALUE, VALUE, VALUE, VALUE)' (aka 'unsigned long (unsigned long, unsigned long, unsigned long, unsigned long, unsigned long, unsigned
long)') to parameter of type 'VALUE (*)(VALUE, VALUE, VALUE, VALUE, VALUE)' (aka 'unsigned long (*)(unsigned long, unsigned long, unsigned long, unsigned long, unsigned long)') [-Wincompatible-function-pointer-types]
  rb_define_module_function(module, "dsyr2", rb_gsl_blas_dsyr2_a, 4);
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/opt/homebrew/var/rbenv/versions/3.2.2/include/ruby-3.2.0/ruby/internal/anyargs.h:338:142: note: expanded from macro 'rb_define_module_function'
#define rb_define_module_function(mod, mid, func, arity)    RBIMPL_ANYARGS_DISPATCH_rb_define_module_function((arity), (func))((mod), (mid), (func), (arity))
                                                                                                                                             ^~~~~~
/opt/homebrew/var/rbenv/versions/3.2.2/include/ruby-3.2.0/ruby/internal/anyargs.h:274:1: note: passing argument to parameter here
RBIMPL_ANYARGS_DECL(rb_define_module_function, VALUE, const char *)
^
/opt/homebrew/var/rbenv/versions/3.2.2/include/ruby-3.2.0/ruby/internal/anyargs.h:259:72: note: expanded from macro 'RBIMPL_ANYARGS_DECL'
RBIMPL_ANYARGS_ATTRSET(sym) static void sym ## _04(__VA_ARGS__, VALUE(*)(VALUE, VALUE, VALUE, VALUE, VALUE), int); \
                                                                       ^
blas2.c:1086:3: error: incompatible function pointer types passing 'VALUE (VALUE, VALUE, VALUE, VALUE, VALUE, VALUE)' (aka 'unsigned long (unsigned long, unsigned long, unsigned long, unsigned long, unsigned long, unsigned
long)') to parameter of type 'VALUE (*)(VALUE, VALUE, VALUE, VALUE, VALUE)' (aka 'unsigned long (*)(unsigned long, unsigned long, unsigned long, unsigned long, unsigned long)') [-Wincompatible-function-pointer-types]
  rb_define_module_function(module, "zher2!", rb_gsl_blas_zher2, 4);
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/opt/homebrew/var/rbenv/versions/3.2.2/include/ruby-3.2.0/ruby/internal/anyargs.h:338:142: note: expanded from macro 'rb_define_module_function'
#define rb_define_module_function(mod, mid, func, arity)    RBIMPL_ANYARGS_DISPATCH_rb_define_module_function((arity), (func))((mod), (mid), (func), (arity))
                                                                                                                                             ^~~~~~
/opt/homebrew/var/rbenv/versions/3.2.2/include/ruby-3.2.0/ruby/internal/anyargs.h:274:1: note: passing argument to parameter here
RBIMPL_ANYARGS_DECL(rb_define_module_function, VALUE, const char *)
^
/opt/homebrew/var/rbenv/versions/3.2.2/include/ruby-3.2.0/ruby/internal/anyargs.h:259:72: note: expanded from macro 'RBIMPL_ANYARGS_DECL'
RBIMPL_ANYARGS_ATTRSET(sym) static void sym ## _04(__VA_ARGS__, VALUE(*)(VALUE, VALUE, VALUE, VALUE, VALUE), int); \
                                                                       ^
blas2.c:1087:3: error: incompatible function pointer types passing 'VALUE (VALUE, VALUE, VALUE, VALUE, VALUE, VALUE)' (aka 'unsigned long (unsigned long, unsigned long, unsigned long, unsigned long, unsigned long, unsigned
long)') to parameter of type 'VALUE (*)(VALUE, VALUE, VALUE, VALUE, VALUE)' (aka 'unsigned long (*)(unsigned long, unsigned long, unsigned long, unsigned long, unsigned long)') [-Wincompatible-function-pointer-types]
  rb_define_module_function(module, "zher2", rb_gsl_blas_zher2_a, 4);
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/opt/homebrew/var/rbenv/versions/3.2.2/include/ruby-3.2.0/ruby/internal/anyargs.h:338:142: note: expanded from macro 'rb_define_module_function'
#define rb_define_module_function(mod, mid, func, arity)    RBIMPL_ANYARGS_DISPATCH_rb_define_module_function((arity), (func))((mod), (mid), (func), (arity))
                                                                                                                                             ^~~~~~
/opt/homebrew/var/rbenv/versions/3.2.2/include/ruby-3.2.0/ruby/internal/anyargs.h:274:1: note: passing argument to parameter here
RBIMPL_ANYARGS_DECL(rb_define_module_function, VALUE, const char *)
^
/opt/homebrew/var/rbenv/versions/3.2.2/include/ruby-3.2.0/ruby/internal/anyargs.h:259:72: note: expanded from macro 'RBIMPL_ANYARGS_DECL'
RBIMPL_ANYARGS_ATTRSET(sym) static void sym ## _04(__VA_ARGS__, VALUE(*)(VALUE, VALUE, VALUE, VALUE, VALUE), int); \
                                                                       ^
2 warnings and 4 errors generated.
make: *** [blas2.o] Error 1

make failed, exit code 2

Gem files will remain installed in /opt/homebrew/var/rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/bundler/gems/rb-gsl-103a3e1941e2 for inspection.
Results logged to /opt/homebrew/var/rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/bundler/gems/extensions/arm64-darwin-23/3.2.0/rb-gsl-103a3e1941e2/gem_make.out

  /opt/homebrew/var/rbenv/versions/3.2.2/lib/ruby/3.2.0/rubygems/ext/builder.rb:119:in `run'
  /opt/homebrew/var/rbenv/versions/3.2.2/lib/ruby/3.2.0/rubygems/ext/builder.rb:51:in `block in make'
  /opt/homebrew/var/rbenv/versions/3.2.2/lib/ruby/3.2.0/rubygems/ext/builder.rb:43:in `each'
  /opt/homebrew/var/rbenv/versions/3.2.2/lib/ruby/3.2.0/rubygems/ext/builder.rb:43:in `make'
  /opt/homebrew/var/rbenv/versions/3.2.2/lib/ruby/3.2.0/rubygems/ext/ext_conf_builder.rb:41:in `build'
  /opt/homebrew/var/rbenv/versions/3.2.2/lib/ruby/3.2.0/rubygems/ext/builder.rb:187:in `build_extension'
  /opt/homebrew/var/rbenv/versions/3.2.2/lib/ruby/3.2.0/rubygems/ext/builder.rb:221:in `block in build_extensions'
  /opt/homebrew/var/rbenv/versions/3.2.2/lib/ruby/3.2.0/rubygems/ext/builder.rb:218:in `each'
  /opt/homebrew/var/rbenv/versions/3.2.2/lib/ruby/3.2.0/rubygems/ext/builder.rb:218:in `build_extensions'
  /opt/homebrew/var/rbenv/versions/3.2.2/lib/ruby/3.2.0/rubygems/installer.rb:843:in `build_extensions'
  /opt/homebrew/var/rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/bundler-2.4.16/lib/bundler/rubygems_gem_installer.rb:72:in `build_extensions'
  /opt/homebrew/var/rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/bundler-2.4.16/lib/bundler/source/path/installer.rb:28:in `post_install'
  /opt/homebrew/var/rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/bundler-2.4.16/lib/bundler/source/path.rb:244:in `generate_bin'
  /opt/homebrew/var/rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/bundler-2.4.16/lib/bundler/source/git.rb:202:in `install'
  /opt/homebrew/var/rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/bundler-2.4.16/lib/bundler/installer/gem_installer.rb:54:in `install'
  /opt/homebrew/var/rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/bundler-2.4.16/lib/bundler/installer/gem_installer.rb:16:in `install_from_spec'
  /opt/homebrew/var/rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/bundler-2.4.16/lib/bundler/installer/parallel_installer.rb:156:in `do_install'
  /opt/homebrew/var/rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/bundler-2.4.16/lib/bundler/installer/parallel_installer.rb:147:in `block in worker_pool'
  /opt/homebrew/var/rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/bundler-2.4.16/lib/bundler/worker.rb:62:in `apply_func'
  /opt/homebrew/var/rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/bundler-2.4.16/lib/bundler/worker.rb:57:in `block in process_queue'
  /opt/homebrew/var/rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/bundler-2.4.16/lib/bundler/worker.rb:54:in `loop'
  /opt/homebrew/var/rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/bundler-2.4.16/lib/bundler/worker.rb:54:in `process_queue'
  /opt/homebrew/var/rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/bundler-2.4.16/lib/bundler/worker.rb:90:in `block (2 levels) in create_threads'

An error occurred while installing gsl (2.1.0.3), and Bundler cannot continue.

In Gemfile:
  gsl

Anybody else have a similar issue?

0xdevalias commented 3 months ago

This approach was working for me running on macos Sonoma - but some update (Xcode? gcc? bundler?) has caused this this gem to stop working, and I can't reinstall it

I'm also running onto this issue on macOS Sonoma 14.4.1 (23E224); but in my case, I was just trying to use the existing published version of gsl 2.1.0.3 on a ruby 2.7.1 install.

Initially I had just done a brew install gsl, which gave me version 2.8; but looking closer at the notes in my Gemfile it said to try brew install gsl@2.1:

# ..snip..

# LSI (related posts)
# Note: You need to install one of nmatrix or narray first, and export NMATRIX=1 or NARRAY=1 before running bundle install
# otherwise gsl won't use them. Note that you can only use one or the other, not both.
#   see https://github.com/SciRuby/rb-gsl#nmatrix-and-narray-usage
#
# Both of these seem to be extremely outdated, see:
#   https://github.com/0xdevalias/devalias.net/issues/83
#   https://github.com/jekyll/classifier-reborn/issues/192
#   https://github.com/SciRuby/rb-gsl/issues/63
gem 'nmatrix'
gem 'gsl' # Note: you need to install a compatible version (eg. 2.1) of gsl first: brew install gsl@2.1
gem 'classifier-reborn'

# ..snip..

Which unfortunately no longer works:

⇒ brew install gsl@2.1
Warning: No available formula with the name "gsl@2.1".
==> Searching for similarly named formulae and casks...
Error: No formulae or casks found for gsl@2.1.

Digging a little deeper, I found these issues:

It seems it's only compatible with gsl 2.1 as well:

I wonder, does using gsl version 2.1 work for you?

There are some instructions for building gsl on macOS without homebrew here:

We can see the latest version of the homebrew formula here:

And it's history here:

Though the first 2.x version listed there seems to be 2.2, so I guess we can't just copy the old brew build version:

Since the only thing that changed from the 1.x build was the source download link though.. maybe we could do it fairly easily.. with something like this:

class GslAT21 < Formula
  desc "Numerical library for C and C++"
  homepage "https://www.gnu.org/software/gsl/"
  url "https://ftp.gnu.org/gnu/gsl/gsl-2.1.tar.gz"
  mirror "https://ftpmirror.gnu.org/gsl/gsl-2.1.tar.gz"
  sha256 "59ad06837397617f698975c494fe7b2b698739a59e2fcf830b776428938a0c66"
  license "GPL-3.0-or-later"

  def install
    ENV.deparallelize
    system "./configure", "--disable-dependency-tracking", "--prefix=#{prefix}"
    system "make" # A GNU tool which doesn't support just make install! Shameful!
    system "make", "install"
  end

  test do
    system bin/"gsl-randist", "0", "20", "cauchy", "30"
  end
end

Saved in:

Then we could install it like this:

⇒ HOMEBREW_NO_INSTALL_FROM_API=1 brew info gsl@2.1
==> gsl@2.1: stable 2.1
Numerical library for C and C++
https://www.gnu.org/software/gsl/
Not installed
From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/g/gsl@2.1.rb
License: GPL-3.0-or-later

⇒ HOMEBREW_NO_INSTALL_FROM_API=1 brew install gsl@2.1
==> Fetching gsl@2.1
==> Downloading https://ftp.gnu.org/gnu/gsl/gsl-2.1.tar.gz
############################################################################################################################################ 100.0%
==> ./configure
==> make
==> make install
🍺  /usr/local/Cellar/gsl@2.1/2.1: 257 files, 8.1MB, built in 4 minutes 48 seconds
==> Running `brew cleanup gsl@2.1`...
Disable this behaviour by setting HOMEBREW_NO_INSTALL_CLEANUP.
Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`).

⇒ gsl-config --version
2.1

After which we could go back and see if rb-gsl can install now... but alas it cannot, and still gets the same errors from before.


Exploring this issue more:

⇒ clang --version
Apple clang version 15.0.0 (clang-1500.3.9.4)
Target: x86_64-apple-darwin23.4.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

In the clang 15 docs it doesn't say it can be disabled:

But in clang 16 it does:

ChatGPT claims I should be able to pass that through like this:

CFLAGS="-Wno-incompatible-function-pointer-types" gem install gsl -v '2.1.0.3' --source 'https://rubygems.org/'

But when I tried I still got the same errors.

Not sure if that is because I'm passing it through wrong, the 'opt out' flag doesn't exist on clang 15, or if it just won't work as a solution at all.

Originally posted by @0xdevalias in https://github.com/SciRuby/rb-gsl/issues/68#issuecomment-2179825864

BenTalagan commented 1 week ago

After which we could go back and see if rb-gsl can install now... but alas it cannot, and still gets the same errors from before.

@0xdevalias thank you, your technique worked for me on MacOS Ventura.

I had to remove the currently upgraded gsl version by homebrew :

brew uninstall gsl

After creating the local recipe as you did (in /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/g/gsl@2.1.rb), I've installed it with the following flags :

HOMEBREW_NO_INSTALL_FROM_API=1 brew install --build-from-source gsl@2.1

Then relinked gsl :

HOMEBREW_NO_INSTALL_FROM_API=1 brew link gsl@2.1

Then, from my project environment (which uses rvm to activate ruby 2.7.1), I uninstalled the precedent gem version :

gem uninstall gsl

And reinstalled it with bundler from within the project dir :

bundle

The gem then accepted to build, using the local gsl@2.1 library version installed with homebrew.

0xdevalias commented 5 days ago

thank you, your technique worked for me on MacOS Ventura

@BenTalagan Awesome! Glad it was helpful!


Then relinked gsl :

HOMEBREW_NO_INSTALL_FROM_API=1 brew link gsl@2.1

@BenTalagan Oh true.. I wonder if that was the reason why it didn't work for me:

After which we could go back and see if rb-gsl can install now... but alas it cannot, and still gets the same errors from before.

I can't remember exactly what I did, but skimming my notes above, it looks like I didn't link gsl@2.1, nor does it look like I changed any ENV vars to make the gem installation point to that version; so maybe that would have made it work.