f-strings break building under python<3.6

Issue #589 resolved
Eugenio Piasini created an issue

Hi, I get this problem with rpy2 v3.1.0 and 3.2.0 ( Version 3.0.0 is fine), using Python 3.5. Linux, first noticed on Ubuntu 16.04LTS.

Since at least rev 29392d3 some f-strings have appeared in the code (for instance in doc/callbacks.rst but most importantly in rpy2/_rinterface_cffi_build.py, on line 121 - I think there are others, though). These are only supported in Python>=3.6. This is a shame as it’s breaking the package for everybody on Python 3.5, which is the python3 version installed in Ubuntu 16.04, which is an LTS and fairly popular in HPC type environments.

Possible solutions include reverting the string formatting to use the old style "{}".format(…), or at least updating the readme to make it clear that python 3.5 is no longer supported.

By the way, thanks a lot for the package! 🙂

Comments (7)

  1. Laurent Gautier

    rpy2 is no longer supported with Python < 3.6. Running the install script should inform user about this. Are you trying to reuse a Python >= 3.6 package installation directory with a Python < 3.6 through PYTHONPATH or something similar ?

  2. Eugenio Piasini reporter

    Mmh, no, building or installing breaks for me in a clean python3 virtualenv under stock Ubuntu 16.04 (which, as I mentioned, comes with Python 3.5). This holds for pip too. I guess the problem may be that f-strings give a syntax error under Python < 3.6, and pry2/_rinterface_cffi_build.py gets called by setup.py. So perhaps whatever logic you have in place to catch the issue with the Python version never gets executed because the file just isn’t well formed python according to the interpreter.

    Steps to reproduce and output message:

    $> python3 -m venv ~/virtualenvs/rpy2test
    $> source ~/virtualenvs/rpy2test/bin/activate
    (rpy2test) $> pip install rpy2
    Collecting rpy2
      Using cached https://files.pythonhosted.org/packages/7e/e0/7da849bb6cf47466ceb28a75f930e61c311878882c275dfb4bbb4fdcc3cb/rpy2-3.2.0.tar.gz
        Complete output from command python setup.py egg_info:
    
        Installed /tmp/pip-build-lit3x37x/rpy2/.eggs/cffi-1.12.3-py3.5-linux-x86_64.egg
        Searching for pycparser
        Reading https://pypi.python.org/simple/pycparser/
        Best match: pycparser 2.19
        Downloading https://files.pythonhosted.org/packages/68/9e/49196946aee219aead1290e00d1e7fdeab8567783e83e1b9ab5585e6206a/pycparser-2.19.tar.gz#sha256=a988718abfad80b6b157acce7bf130a30876d27603738ac39f140993246b25b3
        Processing pycparser-2.19.tar.gz
        Writing /tmp/easy_install-f5vae39l/pycparser-2.19/setup.cfg
        Running pycparser-2.19/setup.py -q bdist_egg --dist-dir /tmp/easy_install-f5vae39l/pycparser-2.19/egg-dist-tmp-83o_v09w
        /usr/lib/python3.5/distutils/dist.py:261: UserWarning: Unknown distribution option: 'python_requires'
          warnings.warn(msg)
        warning: no previously-included files found matching 'setup.pyc'
        warning: no previously-included files matching 'yacctab.*' found under directory 'tests'
        warning: no previously-included files matching 'lextab.*' found under directory 'tests'
        warning: no previously-included files matching 'yacctab.*' found under directory 'examples'
        warning: no previously-included files matching 'lextab.*' found under directory 'examples'
        zip_safe flag not set; analyzing archive contents...
        pycparser.ply.__pycache__.ygen.cpython-35: module references __file__
        pycparser.ply.__pycache__.yacc.cpython-35: module references __file__
        pycparser.ply.__pycache__.yacc.cpython-35: module MAY be using inspect.getsourcefile
        pycparser.ply.__pycache__.yacc.cpython-35: module MAY be using inspect.stack
        pycparser.ply.__pycache__.lex.cpython-35: module references __file__
        pycparser.ply.__pycache__.lex.cpython-35: module MAY be using inspect.getsourcefile
        creating /tmp/pip-build-lit3x37x/rpy2/.eggs/pycparser-2.19-py3.5.egg
        Extracting pycparser-2.19-py3.5.egg to /tmp/pip-build-lit3x37x/rpy2/.eggs
    
        Installed /tmp/pip-build-lit3x37x/rpy2/.eggs/pycparser-2.19-py3.5.egg
        Traceback (most recent call last):
          File "<string>", line 1, in <module>
          File "/tmp/pip-build-lit3x37x/rpy2/setup.py", line 182, in <module>
            'rpy2/rinterface_lib/R_API_eventloop.h'])],
          File "/usr/lib/python3.5/distutils/core.py", line 108, in setup
            _setup_distribution = dist = klass(attrs)
          File "/home/eugenio/virtualenvs/rpy2test/lib/python3.5/site-packages/setuptools/dist.py", line 272, in __init__
            _Distribution.__init__(self,attrs)
          File "/usr/lib/python3.5/distutils/dist.py", line 281, in __init__
            self.finalize_options()
          File "/home/eugenio/virtualenvs/rpy2test/lib/python3.5/site-packages/setuptools/dist.py", line 327, in finalize_options
            ep.load()(self, ep.name, value)
          File "/tmp/pip-build-lit3x37x/rpy2/.eggs/cffi-1.12.3-py3.5-linux-x86_64.egg/cffi/setuptools_ext.py", line 217, in cffi_modules
            add_cffi_module(dist, cffi_module)
          File "/tmp/pip-build-lit3x37x/rpy2/.eggs/cffi-1.12.3-py3.5-linux-x86_64.egg/cffi/setuptools_ext.py", line 49, in add_cffi_module
            execfile(build_file_name, mod_vars)
          File "/tmp/pip-build-lit3x37x/rpy2/.eggs/cffi-1.12.3-py3.5-linux-x86_64.egg/cffi/setuptools_ext.py", line 24, in execfile
            code = compile(src, filename, 'exec')
          File "rpy2/_rinterface_cffi_build.py", line 127
            """,
              ^
        SyntaxError: invalid syntax
    

    Also, the documentation still lists Python 3.5 as a minimum requirement, so you may wish to update that to prevent people from getting too confused (and opening issues 😉).

    Thanks!

  3. Laurent Gautier

    Also, the documentation still lists Python 3.5 as a minimum requirement, so you may wish to update that to prevent people from getting too confused (and opening issues 😉).

    Don’t worry. This would be the opportunity to help these people realize that they are looking at an older documentation and the doc for recent rpy2 releases is here: https://rpy2.github.io/ 😉

    Revisions 11198d97416e and 448ed6a23336 fix the mentions of Python 3.5 in the doc.

  4. Log in to comment