-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Silent fail when use use_2to3 but not available #1120
Comments
I'm seeing behavior consistent with this when trying to install the anyjson 0.3.3 package on Python 3.6.1 x64 on Azure App Service (Kudu) with setuptools 36.2.7 and pip 9.0.1 The Here's the pip log. What should the log look like if 2to3 runs successfully?
|
Running
|
I think setuptools directly uses |
Thanks, @benoit-pierre. Is there a chance that setuptools is detecting a different Python version to determine which fixes should be run? Trying to run install without a venv as
The official Azure site extensions don't come with |
There's a test for the Python version in Setuptools however, will silently ignore an import error for its lib2to3 support module. What are the outputs for:
|
Looks like importing Mixin2to3 works OK, but it's not finding any fixes:
The lib2to3 fixes directory does contain fixes (I cut off the console output):
|
The problem is with def get_all_fix_names(fixer_pkg, remove_prefix=True):
"""Return a sorted list of all available fix names in the given package."""
pkg = __import__(fixer_pkg, [], [], ["*"])
fixer_dir = os.path.dirname(pkg.__file__)
fix_names = []
for name in sorted(os.listdir(fixer_dir)):
if name.startswith("fix_") and name.endswith(".py"):
if remove_prefix:
name = name[4:]
fix_names.append(name[:-3])
return fix_names As you can see, the list of available fixes is determined by looking for source files starting with |
Thanks for investigating. I'll follow up with the Azure package maintainer and the 2to3 library maintainer on the expected behavior. From a setuptools perspective, might be good idea to issue a warning if 2to3 is enabled but no fixes are found. A library maintainer that enables 2to3 probably expects at least 1 fix to be applied during the install |
As a workaround, you could use the following Python code to create fake source files: from pathlib import Path
import lib2to3.fixes
fixes_dir = Path(lib2to3.fixes.__file__).parent
for pyc in fixes_dir.glob('*.pyc'):
py = pyc.parent / (pyc.name + '.py')
if not py.exists():
print('creating fake', py)
py.touch()
pyc.touch() Just a create a backup of the lib2to3 directory before. |
Thanks, I think the script might need to strip the
After running the script, I then get the following error during the anyjson installation:
Relevant function is here: https://github.com/python/cpython/blob/master/Lib/lib2to3/refactor.py#L215 My guess is the import loads the blank |
Another solution is to simply retrieve the lib2to3 sources: > wget https://www.python.org/ftp/python/3.6.1/Python-3.6.1.tgz
> unzip python-3.6.2-embed-amd64.zip python36.zip
> tar xvf Python-3.6.1.tgz --strip-components=2 Python-3.6.1/Lib/lib2to3 |
Note you can use the |
Thanks for the workarounds. For reference, here's the discussion on the Python bug tracker: https://bugs.python.org/issue31143 |
This issue is obsolete now that use_2to3 is removed and errors actively if the parameter is supplied (v58.0.2). |
I am still getting the syntax error from anyjson==0.3.3 when using Python 3.6 any workarounds? |
The proper fix will be for I'd welcome a fix for Setuptools I'd be willing to advise on the anyjson project to help modernize that codebase. I'd recommend to contact the author and find out if they have any intention of maintaining the project or if they wish to hand off maintenance. I found I was able to create a wheel for anyjson thus:
|
I am not using docker, I was trying to do normal anyjson wheel file installation into my wheelhouse directory and getting the error while run "python3 setup.py sdist bdist_wheel" after anyjson.tar.gz extraction |
The main reason I used docker was because I needed something with Python 3.6 to demonstrate the usage. I would recommend getting away from |
python-anyjson (0.3.3-2) unstable; urgency=medium . [ Ondřej Nový ] * Fixed homepage (https) * Fixed VCS URL (https) * d/control: Set Vcs-* to salsa.debian.org * d/copyright: Use https protocol in Format field * d/control: Remove ancient X-Python-Version field * d/control: Remove ancient X-Python3-Version field * Convert git repository from git-dpm to gbp layout . [ Piotr Ożarowski ] * Add dh-python to Build-Depends . [ Sandro Tosi ] * Drop python2 support; Closes: #937576 * Add python3-nose to b-d, needed by tests * Simplify debian/rules * debian/patches/py3k.patch - run 2to3 by hand as `use_2to3=True` doesnt seem to work when running setup.py, see pypa/setuptools#1120
Hello,
I recently had issues with an hand made docker image. When installing some package with python3, installed code was python2 code instead python3 code. Explanation of this issue is:
Problem here is pip install successfully the package while 2to3 is not available. It should crash no ?
Thank's,
Bux.
The text was updated successfully, but these errors were encountered: