lbartnik / subprocess

Other
49 stars 10 forks source link

Support for MACOSX #21

Closed johndharrison closed 7 years ago

johndharrison commented 7 years ago

Hi Lukasz,

Great job getting this on CRAN it definitely addresses an area that base R is perhaps lacking in. Is there any plans to have subprocess run on OSX. At the moment it fails to install as follows:

> devtools::install_github("lbartnik/subprocess@lukaszb/fix-vignette")
Downloading GitHub repo lbartnik/subprocess@lukaszb/fix-vignette
from URL https://api.github.com/repos/lbartnik/subprocess/zipball/lukaszb/fix-vignette
Installing subprocess
'/Library/Frameworks/R.framework/Resources/bin/R' --no-site-file --no-environ --no-save --no-restore --quiet  \
  CMD INSTALL  \
  '/private/var/folders/c2/d97mz0250bg08rr4g2znxk7m0000gq/T/RtmpScSMmr/devtools9e7043650edf/lbartnik-subprocess-bcae3b8'  \
  --library='/Library/Frameworks/R.framework/Versions/3.3/Resources/library' --install-tests 

* installing *source* package ‘subprocess’ ...
** libs
clang -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG  -I/usr/local/include -I/usr/local/include/freetype2 -I/opt/X11/include    -fPIC  -Wall -mtune=core2 -g -O2  -c subprocess.c -o subprocess.o
clang -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG  -I/usr/local/include -I/usr/local/include/freetype2 -I/opt/X11/include    -fPIC  -Wall -mtune=core2 -g -O2  -c sub-linux.c -o sub-linux.o
sub-linux.c:100:8: warning: implicit declaration of function 'pipe2' is invalid in C99 [-Wimplicit-function-declaration]
  if ((pipe2(pipe_stdout, O_NONBLOCK) < 0)) {
       ^
sub-linux.c:24:28: warning: unused variable 'FALSE' [-Wunused-const-variable]
static const int TRUE = 1, FALSE = 0;
                           ^
2 warnings generated.
clang -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG  -I/usr/local/include -I/usr/local/include/freetype2 -I/opt/X11/include    -fPIC  -Wall -mtune=core2 -g -O2  -c is_something.c -o is_something.o
clang -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/Library/Frameworks/R.framework/Resources/lib -L/usr/local/lib -o subprocess.so subprocess.o sub-linux.o is_something.o -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation
installing to /Library/Frameworks/R.framework/Versions/3.3/Resources/library/subprocess/libs
** R
** inst
** tests
** preparing package for lazy loading
** help
*** installing help indices
** building package indices
** installing vignettes
** testing if installed package can be loaded
Error in dyn.load(file, DLLpath = DLLpath, ...) : 
  unable to load shared object '/Library/Frameworks/R.framework/Versions/3.3/Resources/library/subprocess/libs/subprocess.so':
  dlopen(/Library/Frameworks/R.framework/Versions/3.3/Resources/library/subprocess/libs/subprocess.so, 6): Symbol not found: _pipe2
  Referenced from: /Library/Frameworks/R.framework/Versions/3.3/Resources/library/subprocess/libs/subprocess.so
  Expected in: flat namespace
 in /Library/Frameworks/R.framework/Versions/3.3/Resources/library/subprocess/libs/subprocess.so
Error: loading failed
Execution halted
ERROR: loading failed
* removing ‘/Library/Frameworks/R.framework/Versions/3.3/Resources/library/subprocess’
Error: Command failed (1)
lbartnik commented 7 years ago

Hey, thanks for the good word and the report! I'd love to get it to compile in MacOS. My only problem is that I don't have access to this system. However, since only pipe2 is missing according to your report I'll try to look it up and maybe have you run the compilation again?

johndharrison commented 7 years ago

@lbartnik I have a mac in the cloud for testing purposes. Let me know if you want me to run any changes you make on it.

lbartnik commented 7 years ago

Hey @johndharrison, so it seems that only the pipe2() call needs to be fixed. Could you please give this branch a try? https://github.com/lbartnik/subprocess/tree/fix-compilation

johndharrison commented 7 years ago

@lbartnik I ran the fix-compilation branch on a OSX el capitain build. I also ran it on TRAVIS on:

osx_image: xcode8   Xcode 8gm   OS X 10.11 

The relevant yml is here :

https://github.com/johndharrison/subprocess/blob/fix-compilation/.travis.yml

Both runs failed to install the install log can be seen at

https://travis-ci.org/johndharrison/subprocess/jobs/180647454#L939

lbartnik commented 7 years ago

Hey, I pushed a change that should fix it - I was actually able to find a mac VM. However, tests are Linux-specific and still fail - I think the package can be used, though.

johndharrison commented 7 years ago

Yeah that compiles and installs. I went through some of the vignette examples and they all run fine. I will try it on a real world example tomorrow and let you know if I see any issues.

lbartnik commented 7 years ago

There's a problem on Mac that I haven't encountered in Linux nor Windows. It seems that sometimes multi-byte characters are broken into parts when I do read() on a pipe. R fails saying that the "multibyte character" is "invalid". I'm not sure yet what to do with that.

lbartnik commented 7 years ago

I believe this has been addressed in #22