sreeramkannan / Shannon

RNA-Seq
24 stars 13 forks source link

Python 2 default incompatibility #9

Closed lmmx closed 8 years ago

lmmx commented 8 years ago

My computer has Python 3 as the system default, as managed by anaconda. Even when invoked with python2.7, Shannon's internal run_cmd calls to python pick up python3 from my environment (aliases don't override it).

In my fork I've added a python_path variable,

and a verification for the version number:

if test_suite.which(python_path):
    print('Using Python (2.7+) in ' + test_suite.which(python_path))
    vmaj = subprocess.check_output([python_path, '-c', 'import sys; sys.stdout.write(str(sys.version_info.major))'])
    if int(vmaj) != 2:
        print('ERROR: System Python version does not seem to be version 2.7.0 or greater. Please change the python_path varible in shannon.py to the Python 2.7 path')
        exit_now = True
    else:
        vmin = subprocess.check_output([python_path, '-c', 'import sys; sys.stdout.write(str(sys.version_info.minor))'])
        if int(vmin) < 7:
            print('ERROR: System Python 2 version does not seem to be 2.7.0 or greater. Please change the python_path varible in shannon.py to the Python 2.7 path.')
            exit_now = True
else:
    print('ERROR: Python 2.7 not found. Set variable python_path correctly')
    exit_now = True

There was also a mix of tabs and spaces and in fixing that (with the autopep8 tool*) my git diffs don't show the per-line changes now, but 3 files had to be changed to use python_path: shannon.py, run_MB_SF.py, tester.py

As for gpmetis and jellyfish, the sensible default of python2.7 is used for the value of python_path.

* autopep8 was used as: autopep8 --in-place --aggressive --aggressive *.py ./testSuite/*.py

The examples on the Getting started page now run successfully.

I can squash these changes into a single commit if you'd like to review as a pull request.

sreeramkannan commented 8 years ago

Dear Louis, Thanks very much for your work in making Shannon more usable. I will be happy to review the pull request.

Thanks again for your comments! Sreeram

On Fri, Feb 19, 2016 at 8:21 AM, Louis Maddox notifications@github.com wrote:

My system has Python 3 as the system default, as managed by anaconda. Even when invoked with python2.7, Shannon's internal run_cmd calls to python pick up python3 from my environment (aliases don't override it).

In my fork I've added a python_path variable,

  • python run_cmd('python ./Read_Simulator/splitfasta_file.py -o ' + reads_file) becomes python run_cmd(python_path + ' ./Read_Simulator/splitfasta_file.py -o ' + reads_file)

and a verification for the version number:

if test_suite.which(python_path): print('Using Python (2.7+) in ' + test_suite.which(python_path)) vmaj = subprocess.check_output([python_path, '-c', 'import sys; sys.stdout.write(str(sys.version_info.major))']) if int(vmaj) != 2: print('ERROR: System Python version does not seem to be version 2.7.0 or greater. Please change the python_path varible in shannon.py to the Python 2.7 path') exit_now = True else: vmin = subprocess.check_output([python_path, '-c', 'import sys; sys.stdout.write(str(sys.version_info.minor))']) if int(vmin) < 7: print('ERROR: System Python 2 version does not seem to be 2.7.0 or greater. Please change the python_path varible in shannon.py to the Python 2.7 path.') exit_now = Trueelse: print('ERROR: Python 2.7 not found. Set variable python_path correctly') exit_now = True

There was also a mix of tabs and spaces and in fixing that (with the autopep8 tool*) my git diffs don't show the per-line changes now, but 3 files had to be changed to use python_path: shannon.py https://github.com/lmmx/Shannon/blob/b0de484401b33c9d01b0be6614f019a4c9490c15/shannon.py#L20, run_MB_SF.py https://github.com/lmmx/Shannon/blob/b0de484401b33c9d01b0be6614f019a4c9490c15/run_MB_SF.py#L79-L80, tester.py https://github.com/lmmx/Shannon/blob/b0de484401b33c9d01b0be6614f019a4c9490c15/tester.py

As for gpmetis and jellyfish, the sensible default of python2.7 is used for the value of python_path.

  • autopep8 was used as: autopep8 --in-place --aggressive --aggressive _.py ./testSuite/_py

I can squash these into a single commit if you'd like to review as a pull request.

— Reply to this email directly or view it on GitHub https://github.com/sreeramkannan/Shannon/issues/9.

sreeramkannan commented 8 years ago

Thanks very much for your feedback. Shannon now has a python_path variable in shannon.py which can be set.