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

SyntaxError: invalid syntax when installing with setuptools >= 60.0.0 #244

Closed
KORraNpl opened this issue Dec 22, 2021 · 8 comments
Closed
Labels
bug Something isn't working

Comments

@KORraNpl
Copy link

KORraNpl commented Dec 22, 2021

Win10 64bit
Python 3.9.9 64bit
setuptools >= 60.0.0

Steps

  1. Install comtypes via pip install comtypes
  2. Launch python and execute import comtypes

Expected

  • comtypes imported

Actual

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\KORraN\Desktop\da_tests\venv\lib\site-packages\comtypes\__init__.py", line 375
    except COMError, err:
                   ^
SyntaxError: invalid syntax

Additional notes
setup.py:

try:
    from distutils.command.build_py import build_py_2to3 as build_py
except ImportError:
    from distutils.command.build_py import build_py

Importing build_py_2to3 fails and I believe that results in code not being translated to Python 3.

It works fine with setuptools 59.8.0, although already in version 58.0.0 I found information (I'm not sure if it's 100% related):

#2086: Removed support for 2to3 during builds. Projects should port to a unified codebase or pin to an older version of Setuptools using PEP 518 build-requires.

@KORraNpl
Copy link
Author

KORraNpl commented Dec 23, 2021

After a bit of looking around, here's what I've found:

  • support for 2to3 was indeed dropped in setuptools 58.0.0
  • but until version 60.0 it was using distutils from Python installation (which contains build_py_2to3 in 3.9.9 and 3.10.1), now it uses its own copy of the library without this class - https://setuptools.pypa.io/en/latest/history.html#v60-0-0
  • as mentioned in the change log, setting SETUPTOOLS_USE_DISTUTILS=stdlib helps work around the issue.

I have no idea how to fix the issue on comtypes's side though.

@mworion
Copy link
Contributor

mworion commented Dec 27, 2021

Run into same issue using pywinauto.

@PhilippSelenium
Copy link

PhilippSelenium commented Dec 29, 2021

Running into the same problem with python 3.8 ... this is a real blocker.

Some thoughts on fixing this:

  • Freeze and maintain a version/branch for python2 support (urgent fixes can be backported)
  • Remove python 2 support

@Darkstepan
Copy link

I have the same issue while using pywinauto.

Ghostkeeper added a commit to Ultimaker/cura-build-environment that referenced this issue Jan 4, 2022

Verified

This commit was signed with the committer’s verified signature.
bosesuneha Suneha Bose
This package is not compatible with setuptools>=58, since it's Python 2 code and setuptools dropped support for translating Python 2 to Python 3.
See also this issue: enthought/comtypes#244

Contributes to issue CURA-8592.
Ghostkeeper added a commit to Ultimaker/cura-build that referenced this issue Jan 4, 2022
This package is not compatible with setuptools>=58, since it's Python 2 code and setuptools dropped support for translating Python 2 to Python 3.
See also this issue: enthought/comtypes#244

Contributes to issue CURA-8592.
@YoungMan3281
Copy link

hmmm...Wondered if there will be a verion support python3 by installed with pip.

@DH-MP
Copy link

DH-MP commented Jan 11, 2022

see for workaround (#180 (comment))

@vasily-v-ryabov vasily-v-ryabov added the bug Something isn't working label Jan 30, 2022
@kdschlosser
Copy link
Contributor

https://github.com/enthought/comtypes/releases/tag/1.1.11

@KORraNpl
Copy link
Author

I can confirm that importing 1.1.11 works fine with setuptools 60.9.0, so I'm closing this ticket. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

8 participants