mrkn / pycall.rb

Calling Python functions from the Ruby language
MIT License
1.05k stars 72 forks source link

gem install --pre pycall *Error* on Windows Ruby installed by Rubyinstaller #143

Closed yamatakau08 closed 3 years ago

yamatakau08 commented 3 years ago

I executed "gem install --pre pycall" on Windows Ruby installed by Rubyinstaller. I faced the instalation Error.

The following is the Ruby version I'm using. c:\Temp>ruby --version ruby 3.0.1p64 (2021-04-05 revision 0fb782ee38) [x64-mingw32]

When I used Ruby version 2.[67], installation was success. Yesterday, I've just updated Ruby version 3.0 .

The following is the "gem install" log.

c:\Temp>gem install --pre pycall
Temporarily enhancing PATH for MSYS/MINGW...
Building native extensions. This could take a while...
ERROR:  Error installing pycall:
        ERROR: Failed to build gem native extension.

    current directory: C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/pycall-1.3.1/ext/pycall
C:/Ruby30-x64/bin/ruby.exe -I C:/Ruby30-x64/lib/ruby/3.0.0 -r ./siteconf20210503-9804-2mrxul.rb extconf.rb
creating Makefile

current directory: C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/pycall-1.3.1/ext/pycall
make DESTDIR\= clean

current directory: C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/pycall-1.3.1/ext/pycall
make DESTDIR\=
generating pycall-x64-mingw32.def
compiling gc.c
compiling libpython.c
compiling pycall.c
pycall.c: In function 'pycall_without_gvl_p':
pycall.c:83:10: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
   83 |   return (int)pycall_tls_get(without_gvl_key);
      |          ^
pycall.c: At top level:
pycall.c:121:22: warning: 'pycall_pyptr_data_type' redeclared without dllimport attribute: previous dllimport ignored [-Wattributes]
  121 | const rb_data_type_t pycall_pyptr_data_type = {
      |                      ^~~~~~~~~~~~~~~~~~~~~~
pycall.c: In function 'Init_pycall':
pycall.c:2239:21: warning: passing argument 1 of 'pycall_tls_create' discards 'volatile' qualifier from pointer target type [-Wdiscarded-qualifiers]
 2239 |   pycall_tls_create(&without_gvl_key);
      |                     ^~~~~~~~~~~~~~~~
In file included from pycall.c:1:
pycall_internal.h:514:39: note: expected 'pycall_tls_key *' {aka 'long unsigned int *'} but argument is of type 'volatile pycall_tls_key *' {aka 'volatile long unsigned int *'}
  514 | int pycall_tls_create(pycall_tls_key* tls_key);
      |                       ~~~~~~~~~~~~~~~~^~~~~~~
compiling range.c
compiling ruby_wrapper.c
ruby_wrapper.c: In function 'PyRuby_hash_long':
ruby_wrapper.c:148:10: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
  148 |   return (void *)(h == -1 ? pycall_hash_salt : h);
      |          ^
ruby_wrapper.c: In function 'PyRuby_hash_long_with_gvl':
ruby_wrapper.c:155:12: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
  155 |     return (long)CALL_WITH_GVL(PyRuby_hash_long, pyro);
      |            ^
ruby_wrapper.c:157:10: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
  157 |   return (long)PyRuby_hash_long(pyro);
      |          ^
ruby_wrapper.c: In function 'PyRuby_hash_hash_t':
ruby_wrapper.c:177:28: warning: left shift count >= width of type [-Wshift-count-overflow]
  177 |   h = (pycall_hash_salt_32 << 32) | FIX2LONG(rbhash);
      |                            ^~
ruby_wrapper.c:178:48: warning: left shift count >= width of type [-Wshift-count-overflow]
  178 |   return (void *)(h == -1 ? ((pycall_hash_salt << 32) | pycall_hash_salt) : h);
      |                                                ^~
ruby_wrapper.c: At top level:
ruby_wrapper.c:363:3: error: initializer element is not constant
  363 |   &pycall_pyptr_data_type, 0, RUBY_TYPED_FREE_IMMEDIATELY
      |   ^
ruby_wrapper.c:363:3: note: (near initialization for 'pycall_pyrubyptr_data_type.parent')
make: *** [Makefile:245: ruby_wrapper.o] エラー 1

make failed, exit code 2

Gem files will remain installed in C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/pycall-1.3.1 for inspection.
Results logged to C:/Ruby30-x64/lib/ruby/gems/3.0.0/extensions/x64-mingw32/3.0.0/pycall-1.3.1/gem_make.out
Tcheetox commented 3 years ago

Same issue here, did you manage to fix it?

Tcheetox commented 3 years ago

@yamatakau08 did you find a workaround by any chance?

mrkn commented 3 years ago

@yamatakau08 @Tcheetox pycall.rb does not support Windows currently. Sorry for inconvenience. Could you please try to use with WSL2?

mrkn commented 3 years ago

I will release the new version 1.4.0 soon. This new version resolves the compile errors you mention in the description. So I guess you can install pycall 1.4.0 in your environment.

But, the bug I filed in https://github.com/mrkn/pycall.rb/issues/144 is still remaining in the new version.

If you can investigate the problem, it is very helpful for me.

yamatakau08 commented 3 years ago

mrkn-san, Thank you for fixing. pycall installation is succeeded.

c:\Temp>gem install --pre pycall
Fetching pycall-1.4.0.gem
Temporarily enhancing PATH for MSYS/MINGW...
Building native extensions. This could take a while...
Successfully installed pycall-1.4.0
Parsing documentation for pycall-1.4.0
Installing ri documentation for pycall-1.4.0
Done installing documentation for pycall after 2 seconds
1 gem installed

c:\Temp>gem list --local pycall

*** LOCAL GEMS ***

pycall (1.4.0)
yamatakau08 commented 3 years ago

I close this issue.

mrkn commented 3 years ago

@yamatakau08 I've resolved the bug on Windows. Please try the new version 1.4.1.