From d787c9ba7243b54f8dbc3dc9a97d9b8577473950 Mon Sep 17 00:00:00 2001 From: Florian Schwendinger Date: Tue, 10 Mar 2020 05:50:21 +0000 Subject: [PATCH] version 0.1-9 --- ChangeLog | 6 ++- DESCRIPTION | 8 ++-- MD5 | 15 ++++--- R/Basics.R | 2 + R/PySource.R | 4 +- configure | 104 +++++++++++++++++++++++++------------------- man/BEGIN.Python.Rd | 4 -- man/pyHelp.Rd | 2 + src/Makevars.in | 25 +++++++++++ 9 files changed, 108 insertions(+), 62 deletions(-) create mode 100644 src/Makevars.in diff --git a/ChangeLog b/ChangeLog index b19498a..c3c0195 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,10 @@ +2020-02-26 + * By default the new fedora only knows the command python3 but not python, + changed the configure script to cover this change in fedora. + 2018-07-27 - * activated debug printing of Makevars again + * activated debug printing of Makevars again 2018-01-16 diff --git a/DESCRIPTION b/DESCRIPTION index 15f6fa0..c2749bc 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: PythonInR Title: Use 'Python' from Within 'R' -Version: 0.1-7 +Version: 0.1-9 Authors@R: c( person("Florian", "Schwendinger", role = c("aut", "cre"), email = "FlorianSchwendinger@gmx.at"), person("Kimyen", "Truong", role = "ctb") ) @@ -15,10 +15,10 @@ URL: https://bitbucket.org/Floooo/pythoninr/ BugReports: https://bitbucket.org/Floooo/pythoninr/issues License: GPL-3 NeedsCompilation: yes -RoxygenNote: 6.0.0 -Packaged: 2019-04-22 12:53:26 UTC; florian +RoxygenNote: 6.1.1 +Packaged: 2020-03-09 18:53:39 UTC; florian Author: Florian Schwendinger [aut, cre], Kimyen Truong [ctb] Maintainer: Florian Schwendinger Repository: CRAN -Date/Publication: 2019-04-23 07:10:03 UTC +Date/Publication: 2020-03-10 06:50:21 UTC diff --git a/MD5 b/MD5 index 99c38ee..9e8851c 100644 --- a/MD5 +++ b/MD5 @@ -1,8 +1,8 @@ -541395f2d3aea6393956bb23bcad5fb3 *ChangeLog -16c639b795b3c162fa60016c938e6a97 *DESCRIPTION +0c9df7953c463761b277567bb139853f *ChangeLog +f120060a5c39e26e24969f5b8393f847 *DESCRIPTION fdf8803f84f1d032720c76c1dabdba0e *NAMESPACE 8f23ca90a540abd478e8eae1d9f7ca1a *R/AutodetectPython.R -82ef4cf949d70774f311c906df0896be *R/Basics.R +37aab45a28757b4fd42d86ca69f2a817 *R/Basics.R 2cb549a7b1bbeafde04d7a5329bf2a65 *R/PyAttach.R 6bb89d261699323e50d521d81dbca6ac *R/PyCall.R 74b5c060c224d2b9a4b7b9c8e5f80f06 *R/PyClasses.R @@ -15,14 +15,14 @@ d9eab43f33e8f35cf562b98b8d392ea4 *R/PyObjectDict.R bb2be964ec8bdea823542bf7a7faab95 *R/PyObjectTuple.R 4f06f22e66785fd8dc9d8b10fb930e0e *R/PyOptions.R a5e7059dbff4935aa2087bd8bc3ab523 *R/PySet.R -8129b32851b15ca444f1a2cbd78a3e6f *R/PySource.R +2c814c4f07f1f8a05f1ea5b2bc28845e *R/PySource.R 2cf4d7429fcbb99d87ac5b79ec2e7b00 *R/PythonInR.R 033dfb5f35fbbf6f109d228a0b53186d *R/TransformReturnValues.R e9b54a51e96a787b28ad51f94e03c898 *R/Utility.R b8313baf3d27ccdb477556c07b37f2b1 *R/zzz.R 873763a1e1dc563e392f21866860a148 *README.md 75a78cb0c1fa53ba6696b487f37ef4c2 *cleanup -0693eaeda7d05f9cc04b54faa26d7725 *configure +2279dda51f0fa53ccd2b57dc0370100e *configure 70031f25497e1421e156bd2d5316fc9e *inst/testing/Basics.R aa867dd99ecb0cddd42f1af8d31e592c *inst/testing/NA_NaN_Inf.R a4f40b6366bc25896b02d8c2a13fff19 *inst/testing/PyAttach.R @@ -37,7 +37,7 @@ d1c2230280e49bc7d07ad6cad531f32c *inst/testing/PyOptions.R be7608bcd269973c9aebd61531f7a63e *inst/testing/Test_cases.py 896888f9d5d5f91e5729ae1b53830865 *inst/testing/Utf8.R f0ab85292080c6f33ec7c32cbe5b9594 *inst/testing/all.R -3c2e55d7ff670b8b604b96151d1e8c0d *man/BEGIN.Python.Rd +906a264ed7c8e046ce900d1b8e9a3b7f *man/BEGIN.Python.Rd 314f3e26badfaaa135098da9a1d62110 *man/autodetectPython.Rd a10a59d6fd185cd885e2a681efb58eba *man/pyAttach.Rd df989a552858494ba638839d565657e4 *man/pyCall.Rd @@ -52,7 +52,7 @@ f14bee65bfe64de165bbd9ead37d7b19 *man/pyExit.Rd 16726509ab63030160571ce5baa88e23 *man/pyFunction.Rd f8e52a66f6b879e83f3f975ed461a8df *man/pyGet.Rd a35bdcf5644729f15993c00168d912c4 *man/pyGet0.Rd -bcd51012f9f97acfa00c3a55cbe0af5f *man/pyHelp.Rd +8cd064e1c651bd0030907c6f27c38f64 *man/pyHelp.Rd 4acf3d6a674b089c083c3080911c434e *man/pyImport.Rd 2c4cb67c7ad6ebd6efd940402735a415 *man/pyIsConnected.Rd 58a09fb7082904b081f208e8982d2dda *man/pyList.Rd @@ -71,6 +71,7 @@ db5c84655c1e971494d99587c9e14820 *man/pyTuple.Rd 1f5354226008b9de135e496d48884822 *src/CastRObjects.h 91471cf85c09b13d3ab936fba7e0e542 *src/GetPyObjects.c 12fa0d8d4591328ddb4c1a680bad13d5 *src/GetPyObjects.h +049dc07c7696793feecf168f968da0b1 *src/Makevars.in 67e8d5b072c91b99b6ec67f5fa0f80d8 *src/PyCall.c 254e9df8b96b33f9d891f1fcadd81768 *src/PyCall.h a4ecd1bb63a3a910f88ef47d06b15cef *src/PyRunString.c diff --git a/R/Basics.R b/R/Basics.R index 0a3a852..b8647dd 100644 --- a/R/Basics.R +++ b/R/Basics.R @@ -46,7 +46,9 @@ pyDir <- function(objName=NULL){ #' @return Prints the help to the given string. #' @examples #' \dontshow{PythonInR:::pyCranConnect()} +#' \dontrun{ #' pyHelp("abs") +#' } # ----------------------------------------------------------- pyHelp <- function(topic){ if ( pyConnectionCheck() ) return(invisible(NULL)) diff --git a/R/PySource.R b/R/PySource.R index 9d22067..a07bc01 100644 --- a/R/PySource.R +++ b/R/PySource.R @@ -56,6 +56,8 @@ pySource <- function(file, local = FALSE, echo = verbose, print.eval = echo, # ----------------------------------------------------------- # BEGIN.Python # ============ +# note This won't work with RStudio because of a known +# \href{https://support.rstudio.com/hc/communities/public/questions/206744317-readLines-Bug-?page=1#answer-206647788}{RStudio issue}. #' @title Execute Python interactively from within R #' #' @description The function BEGIN.Python starts an Python read-eval-print loop. @@ -64,8 +66,6 @@ pySource <- function(file, local = FALSE, echo = verbose, print.eval = echo, #' from within R. #' @return Returns the entered code as character, code lines which throw an #' exception are omitted. -#' @note This won't work with RStudio because of a known -#' \href{https://support.rstudio.com/hc/communities/public/questions/206744317-readLines-Bug-?page=1#answer-206647788}{RStudio issue}. #' @examples #' \dontshow{PythonInR:::pyCranConnect()} #' \dontrun{ diff --git a/configure b/configure index 821f27d..4fc63a6 100755 --- a/configure +++ b/configure @@ -5,87 +5,103 @@ # # NOTES: # The system variable USESPECIALPYTHONVERSION can be used to link to a special -# python version. +# python version. # export USESPECIALPYTHONVERSION="python3.4" # it can be very usefull especially for testing but one has to ensure that # the file PYVERSION-config is present at the provided location else it will # fail. -# But when using python3 also python3-dev has to be installed +# But when using python3 also python3-dev has to be installed # (apt-get install python3-dev) -# +# # gcc: # there seems to be a new option which doesn't allows me to compile # -fstack-protector-strong so I just remove it # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ if ! [ -z "$USESPECIALPYTHONVERSION" ]; then - echo "use special version" - alias python="$USESPECIALPYTHONVERSION" -fi + echo "use special version" + alias python3="$USESPECIALPYTHONVERSION" +fi -PYVERSION=`python -c "import sys;import distutils.sysconfig as sc;sys.stdout.write(sc.get_config_var('VERSION'))"` -PYINCLUDE=`python -c "import sys;import distutils.sysconfig as sc;sys.stdout.write(sc.get_config_var('INCLUDEPY'))"` -PYBINPATH=`python -c "import sys;import os;sys.stdout.write(os.path.dirname(sys.executable))"` +PYVERSION=`python3 -c "import sys;import distutils.sysconfig as sc;sys.stdout.write(sc.get_config_var('VERSION'))"` +PYINCLUDE=`python3 -c "import sys;import distutils.sysconfig as sc;sys.stdout.write(sc.get_config_var('INCLUDEPY'))"` +PYBINPATH=`python3 -c "import sys;import os;sys.stdout.write(os.path.dirname(sys.executable))"` # sys.version_info.major would be a alternative to hexversion -PY3FLAG=`python -c 'import sys; print("%i" % (sys.hexversion<0x03000000))'` +PY3FLAG=`python3 -c 'import sys; print("%i" % (sys.hexversion<0x03000000))'` +PYABOVE38FLAG=`python3 -c 'import sys; print("%i" % (sys.hexversion>0x03080000))'` PICFLAGS=`"${R_HOME}/bin/R" CMD config CXX11PICFLAGS` +if [ $PYABOVE38FLAG -eq 1 ]; then + echo "detected python3.8 or newer" + PYEMBEDPKGCONF="-embed" + PYEMBEDPYCONF="--embed" +fi + +#python-3.8-embed + ## echo $PYVERSION ## echo $PYBINPATH ## echo $PY3FLAG ## echo $PICFLAGS ## echo "" -## TODO: -## Change the generation of PKG_LIBS so it works with coda. +## TODO: +## Change the generation of PKG_LIBS so it works with conda. ## PYLIBS="PKG_LIBS="`python -c 'import sysconfig; print(" ".join(sysconfig.get_config_var("LDSHARED").split()[1:]))'` if [ $PY3FLAG -eq 0 ]; then - echo "python version is > 3" - PYXY="PYTHONLIBXY=libpython"$PYVERSION"m.so" -else - echo "python version is < 3" - PYXY="PYTHONLIBXY=libpython"$PYVERSION".so" + echo "python version is > 3" + PYXY="PYTHONLIBXY=libpython"$PYVERSION"m.so" +else + echo "python version is < 3" + PYXY="PYTHONLIBXY=libpython"$PYVERSION".so" fi -PYLIBS="PKG_LIBS="`$PYBINPATH/python$PYVERSION-config --ldflags` -PYCFLAGS="PKG_CFLAGS="`$PYBINPATH/python$PYVERSION-config --cflags`" -D $PYXY -D PYTHON_IN_R_NO_EXPLICIT_LINKING" +PKG_LIBS=`$PYBINPATH/python$PYVERSION-config --ldflags $PYEMBEDPYCONF` -## echo "" -## echo "Makevars:" -## echo $PYLIBS -## echo $PYCFLAGS | sed 's/Wstrict-prototypes/pedantic/' | sed 's/ -fstack-protector-strong//' -## echo "" +## +## PKG_CFLAGS +## +if [ -z "$(pkg-config --version 2>&1 | grep 'pkg-config')" ]; then + if (pkg-config --exists python-$PYVERSION$PYEMBEDPKGCONF); then + echo "pkg-config" + PKG_CFLAGS=`pkg-config --cflags python-$PYVERSION$PYEMBEDPKGCONF` + else + #echo "python-config" + #PKG_CFLAGS=`$PYBINPATH/python$PYVERSION-config --cflags $PYEMBEDPYCONF` + PKG_CFLAGS="-I$PYINCLUDE" + fi +else + #echo "python-config" + #PKG_CFLAGS=`$PYBINPATH/python$PYVERSION-config --cflags $PYEMBEDPYCONF` + PKG_CFLAGS="-I$PYINCLUDE" +fi -# replacing Wstric-prototypes removes some unnecessary warnings -PYCFLAGS=$(echo $PYCFLAGS | sed 's/ -Wstrict-prototypes//') -PYCFLAGS=$(echo $PYCFLAGS | sed 's/ -fstack-protector-strong//') -PYCFLAGS=$(echo $PYCFLAGS | sed 's/ -Wdate-time//') -PYCFLAGS=$(echo $PYCFLAGS | sed 's/ -Werror=format-security//') -PYCFLAGS=$(echo $PYCFLAGS | sed 's/ -Wformat//') +PKG_CFLAGS=$(echo $PKG_CFLAGS | sed 's/ -Wstrict-prototypes//') +PKG_CFLAGS=$(echo $PKG_CFLAGS | sed 's/ -fstack-protector-strong//') +PKG_CFLAGS=$(echo $PKG_CFLAGS | sed 's/ -Wdate-time//') +PKG_CFLAGS=$(echo $PKG_CFLAGS | sed 's/ -Werror=format-security//') +PKG_CFLAGS=$(echo $PKG_CFLAGS | sed 's/ -Wformat//') ## added 27.07.2018 -PYCFLAGS=$(echo $PYCFLAGS | sed 's/ -fstack-clash-protection//') -PYCFLAGS=$(echo $PYCFLAGS | sed 's/ -fcf-protection//') +PKG_CFLAGS=$(echo $PKG_CFLAGS | sed 's/ -fstack-clash-protection//') +PKG_CFLAGS=$(echo $PKG_CFLAGS | sed 's/ -fcf-protection//') if ! [ -z "$PICFLAGS" ]; then - PYCFLAGS=$(echo $PYCFLAGS | sed 's/ -fpic//') -fi + PKG_CFLAGS=$(echo $PKG_CFLAGS | sed 's/ -fpic//') +fi -# if [ -z "$PICFLAGS" ]; then -# echo $PYCFLAGS | sed 's/Wstrict-prototypes/pedantic/' | sed 's/ -fstack-protector-strong//' | sed 's/ -Wdate-time//' | sed 's/ -Werror=format-security//' | sed 's/ -Wformat//' >> src/Makevars -# else -# echo $PYCFLAGS | sed 's/Wstrict-prototypes/pedantic/' | sed 's/ -fstack-protector-strong//' | sed 's/ -Wdate-time//' | sed 's/ -Werror=format-security//' | sed 's/ -Wformat//' | sed 's/ -fpic//' >> src/Makevars -# fi + + +sed -e "s|@PKG_CFLAGS@|$PKG_CFLAGS|" -e "s|@PKG_LIBS@|$PKG_LIBS|" -e "s|@PYXY@|$PYXY|" src/Makevars.in > src/Makevars echo "" +echo "-----------------------------------" echo " Makevars:" echo "" -echo " "$PYLIBS -echo "" -echo " "$PYCFLAGS +cat src/Makevars echo "" +echo "-----------------------------------" echo "" -echo ${PYLIBS} > src/Makevars -echo ${PYCFLAGS} >> src/Makevars +exit 0 diff --git a/man/BEGIN.Python.Rd b/man/BEGIN.Python.Rd index 445f67b..c66e7af 100644 --- a/man/BEGIN.Python.Rd +++ b/man/BEGIN.Python.Rd @@ -18,10 +18,6 @@ BEGIN.Python emulates the behavior of the Python terminal and therefore allows interactive Python code development from within R. } -\note{ -This won't work with RStudio because of a known -\href{https://support.rstudio.com/hc/communities/public/questions/206744317-readLines-Bug-?page=1#answer-206647788}{RStudio issue}. -} \examples{ \dontshow{PythonInR:::pyCranConnect()} \dontrun{ diff --git a/man/pyHelp.Rd b/man/pyHelp.Rd index dafd494..7a31091 100644 --- a/man/pyHelp.Rd +++ b/man/pyHelp.Rd @@ -17,5 +17,7 @@ a convenience function to access the Python \strong{help} system. } \examples{ \dontshow{PythonInR:::pyCranConnect()} +\dontrun{ pyHelp("abs") } +} diff --git a/src/Makevars.in b/src/Makevars.in new file mode 100644 index 0000000..c49734b --- /dev/null +++ b/src/Makevars.in @@ -0,0 +1,25 @@ +# Compilation used the following non-portable flag(s): +# ‘-Wdate-time’ ‘-Werror=format-security’ ‘-Wformat’ + +PKG_LIBS=@PKG_LIBS@ +PKG_CFLAGS=@PKG_CFLAGS@ -D @PYXY@ -D PYTHON_IN_R_NO_EXPLICIT_LINKING + +OBJECTS = CToR.o PythonInR.o CastPyObjects.o CastRObjects.o GetPyObjects.o init.o PyCall.o PyRunString.o Python_Explicit_Linking.o SetPyObjects.o + +all: $(SHLIB) + +$(SHLIB): $(OBJECTS) + +#ALL_CFLAGS = $(R_XTRA_CFLAGS) $(PKG_CFLAGS) $(CPICFLAGS) $(SHLIB_CFLAGS) $(CFLAGS) +#ALL_CPPFLAGS = $(R_XTRA_CPPFLAGS) $(PKG_CPPFLAGS) $(CLINK_CPPFLAGS) $(CPPFLAGS) + +ALL_CFLAGS = $(R_XTRA_CFLAGS) $(PKG_CFLAGS) +ALL_CPPFLAGS = $(R_XTRA_CPPFLAGS) $(PKG_CPPFLAGS) + + +%.o: %.c + $(CC) $(R_XTRA_CPPFLAGS) $(R_XTRA_CFLAGS) $(PKG_CFLAGS) $(CPICFLAGS) $(SHLIB_CFLAGS) -c $< -o $@ + +# original from /etc/R/Makeconf +# %.o: %.c +# $(CC) $(ALL_CPPFLAGS) $(ALL_CFLAGS) -c $< -o $@