Skip to content
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

multi-architecture compile on windows #6

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

r2evans
Copy link

@r2evans r2evans commented Feb 4, 2016

  • updated docs, including need for options(rPython.paths=list(...))
  • added .onLoad logic to add PYTHONHOME, PYTHONPATH, and update
    PATH (only if rPython.paths is set correctly)
  • removed references to devtools (will not use options)
  • removed configure files
  • added makevars.win to change between 32-bit and 64-bit python
    directories and libraries
  • updated cleanup file (one typo, added other compile directories)

This might satisfy #2 though I admit to not having tested it extensively with different python installation configurations.

This compiles cleanly and runs on my Windows 10 (64), R 3.2.3, python 2.7.11.

Command-line Multi-Arch Compilation

$ /c/R/R-3.2.3/bin/R CMD INSTALL --build .
Entering C:/Users/r2/Documents/Projects/github/rPython-win
* installing to library 'C:/Users/r2/R/win-library/3.2'
* installing *source* package 'rPython' ...
** libs

*** arch - i386
gcc -m32 -I"C:/R/R-3.2.3/include" -DNDEBUG     -I"d:/RCompile/r-compiling/local/local323/include"  -I"C:/Python27/i386/include"   -O3 -Wall  -std=gnu99 -mtune=core2 -c pycall.c -o pycall.o
gcc -m32 -shared -s -static-libgcc -o rPython.dll tmp.def pycall.o -LC:/python27/i386/libs -lpython27 -Ld:/RCompile/r-compiling/local/local323/lib/i386 -Ld:/RCompile/r-compiling/local/local323/lib -LC:/R/R-3.2.3/bin/i386 -lR
installing to C:/Users/r2/R/win-library/3.2/rPython/libs/i386

*** arch - x64
gcc -m64 -I"C:/R/R-3.2.3/include" -DNDEBUG     -I"d:/RCompile/r-compiling/local/local323/include"  -I"C:/Python27/x64/include"   -O2 -Wall  -std=gnu99 -mtune=core2 -c pycall.c -o pycall.o
gcc -m64 -shared -s -static-libgcc -o rPython.dll tmp.def pycall.o -LC:/python27/x64/libs -lpython27 -Ld:/RCompile/r-compiling/local/local323/lib/x64 -Ld:/RCompile/r-compiling/local/local323/lib -LC:/R/R-3.2.3/bin/x64 -lR
installing to C:/Users/r2/R/win-library/3.2/rPython/libs/x64
** R
** inst
** preparing package for lazy loading
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded
*** arch - i386
Entering C:/Users/r2/Documents/Projects/github/rPython-win
Manually setting PYTHONHOME: /Python27/i386
Manually setting PYTHONPATH: /Python27/i386/Lib
*** arch - x64
Entering C:/Users/r2/Documents/Projects/github/rPython-win
Manually setting PYTHONHOME: /Python27/x64
Manually setting PYTHONPATH: /Python27/x64/Lib
* MD5 sums
packaged installation of 'rPython' as rPython_0.0-6.zip
* DONE (rPython)

32-bit R and Python

# R version 3.2.3 (2015-12-10) -- "Wooden Christmas-Tree"
# Copyright (C) 2015 The R Foundation for Statistical Computing
# Platform: i386-w64-mingw32/i386 (32-bit)
# ...
library(rPython)
# Loading required package: RJSONIO
# Manually setting PYTHONHOME: /Python27/i386
# Manually setting PYTHONPATH: /Python27/i386/Lib
python.exec('import platform')
python.get('platform.architecture()')
# [1] "32bit"     "WindowsPE"

64-bit R and Python

# R version 3.2.3 (2015-12-10) -- "Wooden Christmas-Tree"
# Copyright (C) 2015 The R Foundation for Statistical Computing
# Platform: x86_64-w64-mingw32/x64 (64-bit)
# ...
library(rPython)
# Loading required package: RJSONIO
# Manually setting PYTHONHOME: /Python27/x64
# Manually setting PYTHONPATH: /Python27/x64/Lib
python.exec('import platform')
python.get('platform.architecture()')
# [1] "64bit"     "WindowsPE"

TODO

  • On package load, perhaps it should determine if the available python is 32-bit or 64-bit, and if not compatible, tell the user as such. For instance, if both 32-bit and 64-bit R libraries are available but the 64-bit python cannot be found, on package load it will likely cause R to crash.
  • The munging of the current PATH to update it is, well, a munge, and not immune from breakage. Perhaps this could be improved.

Bill Evans added 3 commits February 4, 2016 14:38
- updated docs, including need for options(rPython.paths=list(...))
- added .onLoad logic to add PYTHONHOME, PYTHONPATH, and update
  PATH (only if rPython.paths is set correctly)
- removed references to devtools (will not use options)
- removed configure files
- added makevars.win to change between 32-bit and 64-bit python
  directories and libraries
- updated cleanup file (one typo, added other compile directories)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant