[contestms] Re: CMS with Python3

  • From: Gary Conway <gconway@xxxxxxxxxxxxxxxx>
  • To: contestms@xxxxxxxxxxxxx
  • Date: Fri, 19 Feb 2016 13:30:53 +0000


Thanks William. That worked!

On 19/02/16 11:18, William Di Luigi wrote:

Those comments are wrong if I recall correctly.

Use this: https://github.com/cms-dev/cms/pull/506

It works (I currently use it), but you have to do two things:

1) add the following (we wary of breaking JSON syntax) to cms.conf:

"python_version": "3",

2) Make sure you have Python 3.4, because if you have Python 3.5 you must change this line of the patch:

+            pyc_name = "__pycache__/%s.cpython-34.pyc" % basename

to this:

+            pyc_name = "__pycache__/%s.cpython-35.pyc" % basename

On Fri, Feb 19, 2016 at 12:01 PM Gary Conway <gconway@xxxxxxxxxxxxxxxx <mailto:gconway@xxxxxxxxxxxxxxxx>> wrote:


    Hi,

    I have converted my cms to use Python3 as instructed in
    cms/grading/__init__.py:

    py_command = ["/usr/bin/python3", "-m", "py_compile",
    source_filenames[0]]
    mv_command = ["/bin/mv", "__pycache__/%s.*.pyc" %
    os.path.splitext(os.path.basename(source_filenames[0]))[0],
    executable_filename]

    and re-installed.

    but when I submit a python3 solution, compilation fails with:
    /bin/mv: cannot stat ‘__pycache__/p1.*.pyc’: No such file or directory

    cmsLogService reports:
    2016/02/19 10:44:29 - WARNING [Worker,1] Couldn't delete sandbox.
    Traceback (most recent call last):
      File
    
"/usr/local/lib/python2.7/dist-packages/cms-1.1.0-py2.7.egg/cms/grading/TaskType.py",
    line 80, in delete_sandbox
        sandbox.delete()
      File
    
"/usr/local/lib/python2.7/dist-packages/cms-1.1.0-py2.7.egg/cms/grading/Sandbox.py",
    line 1246, in delete
        rmtree(self.outer_temp_dir)
      File
    
"/usr/local/lib/python2.7/dist-packages/cms-1.1.0-py2.7.egg/cms/io/GeventUtils.py",
    line 228, in rmtree
        rmtree(fullname, ignore_errors, onerror)
      File
    
"/usr/local/lib/python2.7/dist-packages/cms-1.1.0-py2.7.egg/cms/io/GeventUtils.py",
    line 228, in rmtree
        rmtree(fullname, ignore_errors, onerror)
      File
    
"/usr/local/lib/python2.7/dist-packages/cms-1.1.0-py2.7.egg/cms/io/GeventUtils.py",
    line 234, in rmtree
        onerror(os.remove, fullname, sys.exc_info())
      File
    
"/usr/local/lib/python2.7/dist-packages/cms-1.1.0-py2.7.egg/cms/io/GeventUtils.py",
    line 232, in rmtree
        os.remove(fullname)
    OSError: [Errno 13] Permission denied:
    '/tmp/tmpq8a_bD/tmp/__pycache__/p1.cpython-34.pyc'

    This pyc file has unknown id:
    localadm@aipo-cms3:~$ lsl
    /tmp/tmpq8a_bD/tmp/__pycache__/p1.cpython-34.pyc
    -rw-r--r-- 1 60020 60020 542 Feb 19 10:44
    /tmp/tmpq8a_bD/tmp/__pycache__/p1.cpython-34.pyc
    localadm@aipo-cms3:~$ id cmsuser
    uid=999(cmsuser) gid=999(cmsuser) groups=999(cmsuser)
    localadm@aipo-cms3:~$ id 60020
    id: 60020: no such user

    Please advice!!






Other related posts: