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

fast-export fails if python3 is sytem-wide default #11

Closed
houseofsuns opened this issue Jun 4, 2013 · 9 comments
Closed

fast-export fails if python3 is sytem-wide default #11

houseofsuns opened this issue Jun 4, 2013 · 9 comments

Comments

@houseofsuns
Copy link

If the system default python is python3 (i.e. the symlink is /usr/bin/python -> /usr/bin/python3) then fast-export fails as it is python2 only. The error is in this case rather confusingly

veelai@zaphod ~/fast-export $ python3 hg-fast-export.py 
Traceback (most recent call last):
  File "fast-export/hg-fast-export.py", line 6, in 
    from mercurial import node
ImportError: No module named mercurial

A possible solution is to replace PYTHON=${PYTHON:-python} by PYTHON=${PYTHON:-python2} in the shell scripts and '#!/usr/bin/env python' by '#!/usr/bin/env python2' in the python scripts. This should work in most environments, with one caveat: Debian as greatest distribution under the sky decided to be extravagant and does not ship a python2 symlink, but only python2.6 and similar.

@frej
Copy link
Owner

frej commented Sep 30, 2016

Is this still a problem?

@bigbn
Copy link

bigbn commented Oct 2, 2016

Still. Python3 can't use package mercurial, because it is not ported from python 2.
http://stackoverflow.com/questions/16904468/cant-install-mercurial-package-with-pip-under-python-3-2

@frej
Copy link
Owner

frej commented Oct 2, 2016

Ok. I'll leave it open then...

@mathben
Copy link

mathben commented Jul 27, 2017

It's supported now!

> pip3 show mercurial
Name: mercurial
Version: 4.2.2
Summary: Fast scalable distributed SCM (revision control, version control) system
Home-page: https://mercurial-scm.org/
Author: Matt Mackall and many others
Author-email: mercurial@mercurial-scm.org
License: GNU GPLv2 or any later version
Location: /usr/lib/python3.6/site-packages
Requires:

But I got this error in execution :

> ../fast-export/hg-fast-export.sh -r ../eigen
Traceback (most recent call last):
File "~/fast-export/hg2git.py", line 31, in setup_repo
myui=ui.ui(interactive=False)
TypeError: init() got an unexpected keyword argument 'interactive'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/fast-export/hg-fast-export.py", line 505, in
notes=options.notes,encoding=encoding,fn_encoding=fn_encoding))
File "
/fast-export/hg-fast-export.py", line 381, in hg2git
ui,repo=setup_repo(repourl)
File "~/fast-export/hg2git.py", line 34, in setup_repo
myui.setconfig('ui', 'interactive', 'off')
File "/usr/lib/python3.6/site-packages/mercurial/ui.py", line 388, in setconfig
cfg.set(section, name, value, source)
File "/usr/lib/python3.6/site-packages/mercurial/config.py", line 75, in set
'config values may not be unicode strings on Python 3')
AssertionError: b'config values may not be unicode strings on Python 3'

@nobody93
Copy link

nobody93 commented Jul 18, 2018

Hi,

I thought I wrote following comments yesterday, but could not see it. Sorry I have to write it again, I've clone it from the master branch but I still have following errors, it runs python 2. Anyway, is it fixed in any branch? Or should I install python extra modules manually?

File "/storage/data/SolarAnalytics/HAN/fast-export/hg-fast-export.py", line 7, in
from mercurial.scmutil import revsymbol
ImportError: cannot import name revsymbol

@frej
Copy link
Owner

frej commented Jul 20, 2018

@nobody93: Looks like a duplicate of #132.

@jeandersonbc
Copy link

@houseofsuns if you change PYTHON=${PYTHON:-python} to PYTHON=${PYTHON:-python2} at this location, will it work?

@jeandersonbc
Copy link

@houseofsuns My bad, I didn't notice you mentioned this solution. I tried it here and it works too. If the scripts have a dependency on Python2, perhaps it should be clearly specified on the scripts but I do agree this project should consider moving to Python3.

frej added a commit that referenced this issue Aug 11, 2018
From PEP 394 [1]:

* python2 will refer to some version of Python 2.x.

* end users should be aware that python refers to python3 on at least
  Arch Linux (that change is what prompted the creation of this PEP),
  so python should be used in the shebang line only for scripts that
  are source compatible with both Python 2 and 3.

So to make sure that we run correctly on a system where python refers
to python3 and avoid problems like issue #11 we change the shebangs.

[1] https://www.python.org/dev/peps/pep-0394/
@frej
Copy link
Owner

frej commented Aug 11, 2018

@jeandersonbc: As long as Mercurial does not fully support Python >= 3 porting fast-export to Python 3 is pretty pointless.

Commit ac60034 should make it clear that Python 3 is not supported even if the requirements section in the readme is ignored. With PEP 394 now providing guidance on what a Python script should assume, I believe this bug is finally fixed.

@frej frej closed this as completed Aug 11, 2018
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

6 participants