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

Brotli 1.1.0 breaks Python 2 compatibility #1074

Open
nonatomiclabs opened this issue Sep 8, 2023 · 3 comments
Open

Brotli 1.1.0 breaks Python 2 compatibility #1074

nonatomiclabs opened this issue Sep 8, 2023 · 3 comments

Comments

@nonatomiclabs
Copy link

nonatomiclabs commented Sep 8, 2023

The latest release of Brotli breaks compatibility with Python 2, due to using f-strings in the setup.py:

> python --version
Python 2.7.18
> pip install brotli

DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. pip 21.0 will drop support for Python 2.7 in January 2021. More details about Python 2 support in pip can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support pip 21.0 will remove support for this functionality.
Collecting brotli
  Downloading Brotli-1.1.0.tar.gz (7.4 MB)
     |████████████████████████████████| 7.4 MB 3.9 MB/s 
  Installing build dependencies ... done
  Getting requirements to build wheel ... error
  ERROR: Command errored out with exit status 1:
   command: /Users/jean/Desktop/venv2/bin/python /Users/jean/Desktop/venv2/lib/python2.7/site-packages/pip/_vendor/pep517/_in_process.py get_requires_for_build_wheel /var/folders/3q/mfpgkgl960xcdx3y00zd46hm0000gp/T/tmpYNqwFZ
       cwd: /private/var/folders/3q/mfpgkgl960xcdx3y00zd46hm0000gp/T/pip-install-N9sWxP/brotli
  Complete output (17 lines):
  Traceback (most recent call last):
    File "/Users/jean/Desktop/venv2/lib/python2.7/site-packages/pip/_vendor/pep517/_in_process.py", line 280, in <module>
      main()
    File "/Users/jean/Desktop/venv2/lib/python2.7/site-packages/pip/_vendor/pep517/_in_process.py", line 263, in main
      json_out['return_val'] = hook(**hook_input['kwargs'])
    File "/Users/jean/Desktop/venv2/lib/python2.7/site-packages/pip/_vendor/pep517/_in_process.py", line 114, in get_requires_for_build_wheel
      return hook(config_settings)
    File "/private/var/folders/3q/mfpgkgl960xcdx3y00zd46hm0000gp/T/pip-build-env-1DHL2I/overlay/lib/python2.7/site-packages/setuptools/build_meta.py", line 146, in get_requires_for_build_wheel
      return self._get_build_requires(config_settings, requirements=['wheel'])
    File "/private/var/folders/3q/mfpgkgl960xcdx3y00zd46hm0000gp/T/pip-build-env-1DHL2I/overlay/lib/python2.7/site-packages/setuptools/build_meta.py", line 127, in _get_build_requires
      self.run_setup()
    File "/private/var/folders/3q/mfpgkgl960xcdx3y00zd46hm0000gp/T/pip-build-env-1DHL2I/overlay/lib/python2.7/site-packages/setuptools/build_meta.py", line 142, in run_setup
      exec(compile(code, __file__, 'exec'), locals())
    File "setup.py", line 30
      m = re.match(rf'#define\s{macro}\s+(.+)', line)
                                             ^
  SyntaxError: invalid syntax
  ----------------------------------------
ERROR: Command errored out with exit status 1: /Users/jean/Desktop/venv2/bin/python /Users/jean/Desktop/venv2/lib/python2.7/site-packages/pip/_vendor/pep517/_in_process.py get_requires_for_build_wheel /var/folders/3q/mfpgkgl960xcdx3y00zd46hm0000gp/T/tmpYNqwFZ Check the logs for full command output.

I'm not sure of the correct way to solve the issue:

  • If the decision is to keep the compatibility, I can confirm that removing the two f-strings fixes the issue and that the package can then be installed with Python 2.
  • Otherwise, it would be nice if the Python 2 classifiers were removed and if the python_requires field was used to specify that the package needs at least Python 3.6+.
rouilj added a commit to roundup-tracker/roundup that referenced this issue Sep 11, 2023
temporarily fix by pinning to brotli 1.0.9.

google/brotli#1074
nishanthmerwin added a commit to solvebio/solvebio-python that referenced this issue Sep 11, 2023
davecap pushed a commit to solvebio/solvebio-python that referenced this issue Sep 11, 2023
* Fixed bug by creating a new client for each process instead of trying to reuse a global client

* Removed debug param

* Downgraded brotli due to breaking change: google/brotli#1074

* Updated brotli
@Vangelis66
Copy link

... The same underlying root cause (no support for f-strings) also breaks compatibility with py3.4:

python -m pip install -U brotli =>

Collecting brotli
  Downloading https://files.pythonhosted.org/packages/2f/c2/f9e977608bdf958650638c3f1e28f85a1b075f075ebbe77db8555463787b/Brotli-1.1.0.tar.gz (7.4MB)
     |████████████████████████████████| 7.4MB 386kB/s
  Installing build dependencies ... done
  Getting requirements to build wheel ... error
  ERROR: Complete output from command 'C:\Python3410-32\python.exe' 'C:\Python3410-32\lib\site-packages\pip\_vendor\pep517\_in_process.py' get_requires_for_build_wheel 'C:\Users\<redacted>\AppData\Local\Temp\tmpgh2zno9_':
  ERROR: Traceback (most recent call last):
    File "C:\Python3410-32\lib\site-packages\pip\_vendor\pep517\_in_process.py", line 207, in <module>
      main()
    File "C:\Python3410-32\lib\site-packages\pip\_vendor\pep517\_in_process.py", line 197, in main
      json_out['return_val'] = hook(**hook_input['kwargs'])
    File "C:\Python3410-32\lib\site-packages\pip\_vendor\pep517\_in_process.py", line 54, in get_requires_for_build_wheel
      return hook(config_settings)
    File "C:\Users\<redacted>\AppData\Local\Temp\pip-build-env-hltq7py2\overlay\Lib\site-packages\setuptools\build_meta.py", line 146, in get_requires_for_build_wheel
      return self._get_build_requires(config_settings, requirements=['wheel'])
    File "C:\Users\<redacted>\AppData\Local\Temp\pip-build-env-hltq7py2\overlay\Lib\site-packages\setuptools\build_meta.py", line 127, in _get_build_requires
      self.run_setup()
    File "C:\Users\<redacted>\AppData\Local\Temp\pip-build-env-hltq7py2\overlay\Lib\site-packages\setuptools\build_meta.py", line 142, in run_setup
      exec(compile(code, __file__, 'exec'), locals())
    File "setup.py", line 30
      m = re.match(rf'#define\s{macro}\s+(.+)', line)
                                             ^
  SyntaxError: invalid syntax
  ----------------------------------------
ERROR: Command "'C:\Python3410-32\python.exe' 'C:\Python3410-32\lib\site-packages\pip\_vendor\pep517\_in_process.py' get_requires_for_build_wheel 'C:\Users\<redacted>\AppData\Local\Temp\tmpgh2zno9_'" failed with error code 1 in C:\Users\<redacted>\AppData\Local\Temp\pip-install-e18xc5rq\brotli

PyPI, on the Brotli-1.1.0 page, advertises:

brotlipypi

I can confirm that removing the two f-strings fixes the issue and that the package can then be installed with Python 2.

For those not fluent in Python 😉 , what was the exact code you used in lieu of L30+L44 of current setup.py ? FWIW, f-strings inside setup.py were first introduced in 27a9a80 ...

Thanks 😄

@rouilj
Copy link

rouilj commented Sep 17, 2023

... The same underlying root cause (no support for f-strings) also breaks compatibility with py3.4:
[...]
File "setup.py", line 30
m = re.match(rf'#define\s{macro}\s+(.+)', line)
^
SyntaxError: invalid syntax
[...]
For those not fluent in Python 😉 , what was the exact code you used in lieu of L30+L44 of current setup.py ? FWIW, f-strings inside setup.py were first introduced in 27a9a80 ...

Can you try:

m = re.match(r'#define\s%s\s+(.+)' % macro, line)

and see if that works. If so the other rf line can be similarly munged by:

  • replace rf' with r'
  • replace {variable} in the r string with %s and add % varname as above.
    If there is more than 1 variable in the r string, use % ( var1, var2, ...) matching the varX and the %s
    tokens 1 for 1.

@JacobChrist
Copy link

JacobChrist commented Sep 30, 2023

This is affecting me too, how can I help? I'm trying to install in Python 2.7.18 venv on a rPi. I can successfully install version 1.0.9
pip install brotli==1.0.9

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

4 participants