Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python 2.* Compatibility #46

Open
brandonwillard opened this issue Aug 13, 2016 · 9 comments
Open

Python 2.* Compatibility #46

brandonwillard opened this issue Aug 13, 2016 · 9 comments

Comments

@brandonwillard
Copy link

Looks like some of the current syntax requires Python 3, i.e.

(pweave-env)$ python setup.py develop
Traceback (most recent call last):
  File "setup.py", line 4, in <module>
    import pweave
  File "/home/bwillar0/projects/python/Pweave/pweave/__init__.py", line 7, in <module>
    from .pweb import *
  File "/home/bwillar0/projects/python/Pweave/pweave/pweb.py", line 26
    def __init__(self, source, doctype = None, *, informat = None, kernel = "python3",
                                                ^
SyntaxError: invalid syntax

Is there no longer Python 2.* compatibility?

@mpastell
Copy link
Owner

Current master is Python 3 only and so will be the next 0.3 release. I haven't updated the setup.py yet.

You can still run documents with Python 2 code with the --kernel option.

@abukaj
Copy link
Collaborator

abukaj commented Jun 7, 2017

I started working on a generic branch (both Python 2 and 3 compatible).

When run in Python 2.7 environment, it switches to Python 2 kernel.

@brandonwillard
Copy link
Author

This version compatibility question was exclusively in reference to the source/development version of Python, which has already been addressed.

@abukaj
Copy link
Collaborator

abukaj commented Aug 23, 2017

@mpastell Just crossed my mind: have you definitively decided to abandon support for Python 2, or is this still possible in the project to support it?

I am thinking either about making the code P2/3 compatible or keeping P2 branch in sync with master.

@mpastell
Copy link
Owner

mpastell commented Aug 24, 2017

I have three reasons for wanting to drop Python 2:

  • The project is now tightly coupled with IPython and new versions of IPython are Python 3 only: http://ipython.readthedocs.io/en/stable/whatsnew/version6.html
  • Not supporting Python 2 means I can focus on new features, because I only need to test on one version
  • I haven't used Python 2 during the last 2 years and I'm very used to coding using only Python 3

So personally I find this a good time to drop it, if it would be included in the release it means I feel the need to support it. Python 2 users can still use new version of Pweave with Python 2 kernel.

See also: http://www.python3statement.org/

@mpastell mpastell reopened this Aug 24, 2017
@abukaj
Copy link
Collaborator

abukaj commented Aug 25, 2017

I see. My approach is slightly different - I try to keep my code both P2/3 compatible, so I can maintain the support with minimal effort.

The only drawback I can see of abandoning Python 2 is referencing the used Pweave version pweave.__version__. I can see two solutions to fix that:

  • either inject __pweave_version__ variable into the global namespace of the kernel before weaving,
  • or define a tag to be substituted with version string when parsing the source file.
    Personally I am for the former option.

@JamesLarkinWhite
Copy link

Dear all... i just installed Peweave only to realize that it doesn´t support python 2. There is a comment here that i can change the kernel settings but i have no clue what this means. Would someone be willing to guide me? Thank you in advance

@JamesLarkinWhite
Copy link

IF i try to trun one of the test documents like:
pweave -f md2html --kernel python2 FIR_designp.pmd
or
pweave -f md2html -k python2 FIR_designp.pmd

I still get this error:

Traceback (most recent call last):
File "C:\Program Files (x86)\Python27\Lib\runpy.py", line 162, in run_module_as_main
"main", fname, loader, pkg_name)
File "C:\Program Files (x86)\Python27\Lib\runpy.py", line 72, in run_code
exec code in run_globals
File "C:\Program Files (x86)\Python27\Scripts\pweave.exe_main
.py", line 5, in
File "c:\program files (x86)\python27\lib\site-packages\pweave_init
.py", line 6, in
from . import readers
File "c:\program files (x86)\python27\lib\site-packages\pweave\readers.py", line 8, in
from urllib import request, parse
ImportError: cannot import name request

I would really appreciate any help you are willing to offer.
At the moment i can not install python3 on this mashine

@piccolbo
Copy link
Collaborator

Python 2 will be a dead language in two years' time. The dependencies like ipython going away it the other nail in the coffin. I think @mpastell made the right call when he closed this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants