Run 'Python' code, make function calls, assign and retrieve variables, etc. from R. A fork from 'rPython' which uses 'jsonlite', 'Rcpp' and has several fixes and improvements.
Modern overhaul of rPython
, read more on the motivation and benefits of using it in this blog post.
Many thanks to Bob Rudis for basically teaching me how to write a modern R package and getting this off the ground.
In order to compile SnakeCharmR, you'll need to have Python >= 2.7 installed. Make sure you also have the development libraries and include files, the operating system package names will vary with your specific Linux distribution.
By default SnakeCharmR will look for python-config
and python
commands in the PATH. The former will be used to determine the location of the libraries and headers necessary to compile SnakeCharmR.
In systems where several Python versions coexist, you can force a different version to be used by setting an environment variable SNAKECHARMR_PYTHON_VERSION
to either the major version or major and minor versions.
For example, if you set SNAKECHARMR_PYTHON_VERSION=3.2
then Python 3.2 will be used. In this example, you will need to ensure:
that python3.2
and python3.2-config
exist and are in the PATH;
that a libpython3.2.so
exists at the locations indicated by python3.2-config --ldflags
.
In order to compile this on Windows, make sure you meet the following requirements:
Install the latest version of Rtools;
Ensure the python
command from the desired Python version is the first one in your PATH.
If you want to use the (very outdated) Python bundled with Rtools on a 64-bit system, for example, you would need to add c:\Rtools\mingw_64\opt\bin
to your PATH and possibly set PYTHONHOME
to c:\Rtools\mingw_64\opt
.
It is recommended, however, that you install and use the official Python distribution for Windows.
Many thanks to mattfidler for the help in getting this to work properly on Windows.
Avoid tripping maximum R string size when reading large data objects from Python. The JSON string string read from Python is stored into a raw vector, which is then read with jsonlite's push parser through a rawConnection.
Should now compile on Windows using the Rtools Python libraries or the standard Python package. Many thanks to Matthew Fidler (https://github.com/mattfidler), his help was invaluable in helping implement and test this.
Added Appveyor tests for the Windows build.
Fixed compilation on Python 3, fixing https://github.com/asieira/SnakeCharmR/issues/33. Thanks to https://github.com/lfdmotta for reporting this.
Updated Travis tests to cover Python 2 and 3, and also current and devel versions of R.
Startup message will now include contents of Python sys.version
information.
Cleaned up configure.ac and src/Makevars.in to remove unnecessary steps inherited from RPython code.
Fixed issue with logo image in README file in CRAN page.
Updated versions of package dependencies.
Fixed https://github.com/asieira/SnakeCharmR/issues/24. Thanks to David Severski (@dseverski) for reporting this.
Took measures to ensure SnakeCharmR will work properly on systems where the native encoding is not UTF-8:
Use Python API to check if variable is str/bytes or unicode and handling things correctly. In particular, when we read Python unicode values we flag the resulting R string as UTF-8 since that’s what we Python C API we are using will return;
Ensure that Python code being executed is converted to UTF-8 and that the Python interpreter is made aware of that according to PEP 263.
Fixed linking and building errors on some platforms (such as Amazon Linux) by updating the autoconf file to use the correct C++ compiler preferred by R.
Fixed handling of NULL values in arguments, including a workaround for jeroenooms/jsonlite#130 which was causing inconsistencies.
Initial release.