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 building for python2 #77

Closed
fryfrog opened this issue Jul 23, 2019 · 7 comments
Closed

SyntaxError building for python2 #77

fryfrog opened this issue Jul 23, 2019 · 7 comments

Comments

@fryfrog
Copy link

fryfrog commented Jul 23, 2019

I own the Arch Linux AUR python-backoff package and was hoping you might be able to help me figure out why it doesn't build for python2 (its fine for python 3).

==> Starting package_python2-backoff()...
/usr/lib/python2.7/distutils/dist.py:267: UserWarning: Unknown distribution option: 'python_requires'
  warnings.warn(msg)
running install
running build
running build_py
file README.py (for module README) not found
file LICENSE.py (for module LICENSE) not found
creating build
creating build/lib
creating build/lib/backoff
copying backoff/_decorator.py -> build/lib/backoff
copying backoff/_wait_gen.py -> build/lib/backoff
copying backoff/_async.py -> build/lib/backoff
copying backoff/_common.py -> build/lib/backoff
copying backoff/__init__.py -> build/lib/backoff
copying backoff/_jitter.py -> build/lib/backoff
copying backoff/_sync.py -> build/lib/backoff
file README.py (for module README) not found
file LICENSE.py (for module LICENSE) not found
running install_lib
creating /home/fryfrog/aur/python-backoff/pkg/python2-backoff/usr
creating /home/fryfrog/aur/python-backoff/pkg/python2-backoff/usr/lib
creating /home/fryfrog/aur/python-backoff/pkg/python2-backoff/usr/lib/python2.7
creating /home/fryfrog/aur/python-backoff/pkg/python2-backoff/usr/lib/python2.7/site-packages
creating /home/fryfrog/aur/python-backoff/pkg/python2-backoff/usr/lib/python2.7/site-packages/backoff
copying build/lib/backoff/_sync.py -> /home/fryfrog/aur/python-backoff/pkg/python2-backoff/usr/lib/python2.7/site-packages/backoff
copying build/lib/backoff/__init__.py -> /home/fryfrog/aur/python-backoff/pkg/python2-backoff/usr/lib/python2.7/site-packages/backoff
copying build/lib/backoff/_common.py -> /home/fryfrog/aur/python-backoff/pkg/python2-backoff/usr/lib/python2.7/site-packages/backoff
copying build/lib/backoff/_jitter.py -> /home/fryfrog/aur/python-backoff/pkg/python2-backoff/usr/lib/python2.7/site-packages/backoff
copying build/lib/backoff/_async.py -> /home/fryfrog/aur/python-backoff/pkg/python2-backoff/usr/lib/python2.7/site-packages/backoff
copying build/lib/backoff/_decorator.py -> /home/fryfrog/aur/python-backoff/pkg/python2-backoff/usr/lib/python2.7/site-packages/backoff
copying build/lib/backoff/_wait_gen.py -> /home/fryfrog/aur/python-backoff/pkg/python2-backoff/usr/lib/python2.7/site-packages/backoff
byte-compiling /home/fryfrog/aur/python-backoff/pkg/python2-backoff/usr/lib/python2.7/site-packages/backoff/_sync.py to _sync.pyc
byte-compiling /home/fryfrog/aur/python-backoff/pkg/python2-backoff/usr/lib/python2.7/site-packages/backoff/__init__.py to __init__.pyc
byte-compiling /home/fryfrog/aur/python-backoff/pkg/python2-backoff/usr/lib/python2.7/site-packages/backoff/_common.py to _common.pyc
byte-compiling /home/fryfrog/aur/python-backoff/pkg/python2-backoff/usr/lib/python2.7/site-packages/backoff/_jitter.py to _jitter.pyc
byte-compiling /home/fryfrog/aur/python-backoff/pkg/python2-backoff/usr/lib/python2.7/site-packages/backoff/_async.py to _async.pyc
  File "/usr/lib/python2.7/site-packages/backoff/_async.py", line 22
    async def _call_handlers(hdlrs, target, args, kwargs, tries, elapsed, **extra):
            ^
SyntaxError: invalid syntax

byte-compiling /home/fryfrog/aur/python-backoff/pkg/python2-backoff/usr/lib/python2.7/site-packages/backoff/_decorator.py to _decorator.pyc
byte-compiling /home/fryfrog/aur/python-backoff/pkg/python2-backoff/usr/lib/python2.7/site-packages/backoff/_wait_gen.py to _wait_gen.pyc
writing byte-compilation script '/tmp/tmpuUGdlI.py'
/usr/bin/python2 -O /tmp/tmpuUGdlI.py
  File "/usr/lib/python2.7/site-packages/backoff/_async.py", line 22
    async def _call_handlers(hdlrs, target, args, kwargs, tries, elapsed, **extra):
            ^
SyntaxError: invalid syntax

removing /tmp/tmpuUGdlI.py
running install_egg_info
Writing /home/fryfrog/aur/python-backoff/pkg/python2-backoff/usr/lib/python2.7/site-packages/backoff-1.8.0-py2.7.egg-info
@bgreen-litl
Copy link
Member

What command is generating this output? There is python 3 syntax in backoff/_async.py and that module should not be imported or compiled under python 2.7.

@fryfrog
Copy link
Author

fryfrog commented Jul 24, 2019

The PKGBUILD runs python2 setup.py install --root="$pkgdir" --optimize=1, I've included the output of a manual run below.

0 ✓ fryfrog@apollo ~/aur/python-backoff/src/backoff-1.8.0 $[master] python2 setup.py install --root="../../pkg/python2-backoff/" --optimize=1
/usr/lib/python2.7/distutils/dist.py:267: UserWarning: Unknown distribution option: 'python_requires'
  warnings.warn(msg)
running install
running build
running build_py
file README.py (for module README) not found
file LICENSE.py (for module LICENSE) not found
file README.py (for module README) not found
file LICENSE.py (for module LICENSE) not found
running install_lib
creating ../../pkg
creating ../../pkg/python2-backoff
creating ../../pkg/python2-backoff/usr
creating ../../pkg/python2-backoff/usr/lib
creating ../../pkg/python2-backoff/usr/lib/python2.7
creating ../../pkg/python2-backoff/usr/lib/python2.7/site-packages
creating ../../pkg/python2-backoff/usr/lib/python2.7/site-packages/backoff
copying build/lib/backoff/_wait_gen.py -> ../../pkg/python2-backoff/usr/lib/python2.7/site-packages/backoff
copying build/lib/backoff/_sync.py -> ../../pkg/python2-backoff/usr/lib/python2.7/site-packages/backoff
copying build/lib/backoff/_async.py -> ../../pkg/python2-backoff/usr/lib/python2.7/site-packages/backoff
copying build/lib/backoff/_decorator.py -> ../../pkg/python2-backoff/usr/lib/python2.7/site-packages/backoff
copying build/lib/backoff/__init__.py -> ../../pkg/python2-backoff/usr/lib/python2.7/site-packages/backoff
copying build/lib/backoff/_common.py -> ../../pkg/python2-backoff/usr/lib/python2.7/site-packages/backoff
copying build/lib/backoff/_jitter.py -> ../../pkg/python2-backoff/usr/lib/python2.7/site-packages/backoff
byte-compiling ../../pkg/python2-backoff/usr/lib/python2.7/site-packages/backoff/_wait_gen.py to _wait_gen.pyc
byte-compiling ../../pkg/python2-backoff/usr/lib/python2.7/site-packages/backoff/_sync.py to _sync.pyc
byte-compiling ../../pkg/python2-backoff/usr/lib/python2.7/site-packages/backoff/_async.py to _async.pyc
  File "usr/lib/python2.7/site-packages/backoff/_async.py", line 22
    async def _call_handlers(hdlrs, target, args, kwargs, tries, elapsed, **extra):
            ^
SyntaxError: invalid syntax

byte-compiling ../../pkg/python2-backoff/usr/lib/python2.7/site-packages/backoff/_decorator.py to _decorator.pyc
byte-compiling ../../pkg/python2-backoff/usr/lib/python2.7/site-packages/backoff/__init__.py to __init__.pyc
byte-compiling ../../pkg/python2-backoff/usr/lib/python2.7/site-packages/backoff/_common.py to _common.pyc
byte-compiling ../../pkg/python2-backoff/usr/lib/python2.7/site-packages/backoff/_jitter.py to _jitter.pyc
writing byte-compilation script '/tmp/tmpNyY1G1.py'
/usr/bin/python2 -O /tmp/tmpNyY1G1.py
  File "usr/lib/python2.7/site-packages/backoff/_async.py", line 22
    async def _call_handlers(hdlrs, target, args, kwargs, tries, elapsed, **extra):
            ^
SyntaxError: invalid syntax

removing /tmp/tmpNyY1G1.py
running install_egg_info
Writing ../../pkg/python2-backoff/usr/lib/python2.7/site-packages/backoff-1.8.0-py2.7.egg-info

@bgreen-litl
Copy link
Member

Backoff doesn't ship with a setup.py anymore so I'm not clear what one your example is referencing.

Instead there is a pyproject.toml as specified by PEP 517. https://www.python.org/dev/peps/pep-0517/

I'm currently using poetry for building and publishing backoff

@fryfrog
Copy link
Author

fryfrog commented Jul 24, 2019

The setup.py comes out of the .tar.gz that pypi hosts for you at https://files.pythonhosted.org/packages/source/b/backoff/backoff-1.8.0.tar.gz, I'll do a little digging and see what I can figure out too.

0 ✓ fryfrog@apollo ~/aur/python-backoff/src/backoff-1.8.0 $[master] ls -alh
total 49K
drwxr-xr-x 4 fryfrog fryfrog    9 Jul 24 13:25 .
drwxr-xr-x 4 fryfrog fryfrog    5 Jul 24 13:25 ..
drwxr-xr-x 2 fryfrog fryfrog    9 Jul 24 13:25 backoff
drwxr-xr-x 3 fryfrog fryfrog    3 Jul 24 13:25 build
-rw-r--r-- 1 fryfrog fryfrog 1.1K Mar 10  2018 LICENSE
-rw-r--r-- 1 fryfrog fryfrog 1.1K Dec 31  1969 PKG-INFO
-rw-r--r-- 1 fryfrog fryfrog 1.6K Dec 20  2018 pyproject.toml
-rw-r--r-- 1 fryfrog fryfrog  12K Dec 15  2018 README.rst
-rw-r--r-- 1 fryfrog fryfrog  13K Dec 31  1969 setup.py

@fryfrog
Copy link
Author

fryfrog commented Jul 24, 2019

python-poetry/poetry#866

^ Looks like this is promising.

@bgreen-litl
Copy link
Member

Okay that makes sense. I didn't remember that poetry is generating a setup.py.

The fundamental issue is that on python 2.7, you do not want it to byte compile the _async submodule as it is necessarily python 3 syntax.

It looks like you can specify files to exclude in pyproject.toml but I'm not sure how to exclude them for only one version of python...

Maybe there's a way when invoking setup.py to exclude that file from being compiled?

@fryfrog
Copy link
Author

fryfrog commented Jul 24, 2019

So it doesn't actually cause any problems, I'm just gonna ignore it. :)

@fryfrog fryfrog closed this as completed Jul 24, 2019
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

2 participants