rollbar / pyrollbar

Error tracking and logging from Python to Rollbar
https://docs.rollbar.com/docs/python/
MIT License
213 stars 135 forks source link

Add Django 4.0+ compatibility #400

Closed ezarowny closed 2 years ago

ezarowny commented 2 years ago

Description of the change

Django 4.0 introduces some changes designed to better handle frozen environments (see here) which broke the pyrollbar Django middleware. This change should allow pyrollbar to properly patch ExceptionReporter.get_traceback_html in django.views.debug for Django 4.0+.

Type of change

Related Issues

Checklists

Development

Code review

ezarowny commented 2 years ago

I can't quite get the tests to run on my machine.

I'm running macOS 12.1 with Python 3.9.10 and 3.10.1 built via pyenv.

Here's the output of python setup.py test on 3.9.10:

running test
WARNING: Testing via this command is deprecated and will be removed in a future version. Users looking for a generic test entry point independent of test runner are encouraged to use tox.
/Users/ezarowny/Development/pyrollbar/venv/lib/python3.9/site-packages/setuptools/installer.py:27: SetuptoolsDeprecationWarning: setuptools.installer is deprecated. Requirements should be satisfied by a PEP 517 installer.
  warnings.warn(
WARNING: The wheel package is not available.
WARNING: The wheel package is not available.
WARNING: The wheel package is not available.
  ERROR: Command errored out with exit status 1:
   command: /Users/ezarowny/Development/pyrollbar/venv/bin/python -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/yt/3213ptzd3dl61v_ll7614h0w0000gn/T/pip-wheel-a9iszsfa/blinker_e7d38acb0d9f4dd3beb2438cb7d4d283/setup.py'"'"'; __file__='"'"'/private/var/folders/yt/3213ptzd3dl61v_ll7614h0w0000gn/T/pip-wheel-a9iszsfa/blinker_e7d38acb0d9f4dd3beb2438cb7d4d283/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /private/var/folders/yt/3213ptzd3dl61v_ll7614h0w0000gn/T/pip-wheel-jeobrt__
       cwd: /private/var/folders/yt/3213ptzd3dl61v_ll7614h0w0000gn/T/pip-wheel-a9iszsfa/blinker_e7d38acb0d9f4dd3beb2438cb7d4d283/
  Complete output (8 lines):
  /Users/ezarowny/Development/pyrollbar/venv/lib/python3.9/site-packages/setuptools/dist.py:723: UserWarning: Usage of dash-separated 'upload-dir' will not be supported in future versions. Please use the underscore name 'upload_dir' instead
    warnings.warn(
  usage: setup.py [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
     or: setup.py --help [cmd1 cmd2 ...]
     or: setup.py --help-commands
     or: setup.py cmd --help

  error: invalid command 'bdist_wheel'
  ----------------------------------------
  ERROR: Failed building wheel for blinker
ERROR: Failed to build one or more wheels
error: Command '['/Users/ezarowny/Development/pyrollbar/venv/bin/python', '-m', 'pip', '--disable-pip-version-check', 'wheel', '--no-deps', '-w', '/var/folders/yt/3213ptzd3dl61v_ll7614h0w0000gn/T/tmpou_be_4k', '--quiet', 'blinker']' returned non-zero exit status 1.

Here's the output on 3.10.1:

running test
WARNING: Testing via this command is deprecated and will be removed in a future version. Users looking for a generic test entry point independent of test runner are encouraged to use tox.
WARNING: The wheel package is not available.
WARNING: The wheel package is not available.
WARNING: The wheel package is not available.
WARNING: The wheel package is not available.
  ERROR: Command errored out with exit status 1:
   command: /Users/ezarowny/Development/pyrollbar/venv/bin/python -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/yt/3213ptzd3dl61v_ll7614h0w0000gn/T/pip-wheel-m_pnzsqq/blinker_95403e0ccf744369ae9bb5b0b112731c/setup.py'"'"'; __file__='"'"'/private/var/folders/yt/3213ptzd3dl61v_ll7614h0w0000gn/T/pip-wheel-m_pnzsqq/blinker_95403e0ccf744369ae9bb5b0b112731c/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /private/var/folders/yt/3213ptzd3dl61v_ll7614h0w0000gn/T/pip-wheel-2i81mxbw
       cwd: /private/var/folders/yt/3213ptzd3dl61v_ll7614h0w0000gn/T/pip-wheel-m_pnzsqq/blinker_95403e0ccf744369ae9bb5b0b112731c/
  Complete output (8 lines):
  /Users/ezarowny/Development/pyrollbar/venv/lib/python3.10/site-packages/setuptools/dist.py:717: UserWarning: Usage of dash-separated 'upload-dir' will not be supported in future versions. Please use the underscore name 'upload_dir' instead
    warnings.warn(
  usage: setup.py [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
     or: setup.py --help [cmd1 cmd2 ...]
     or: setup.py --help-commands
     or: setup.py cmd --help

  error: invalid command 'bdist_wheel'
  ----------------------------------------
  ERROR: Failed building wheel for blinker
ERROR: Failed to build one or more wheels
error: Command '['/Users/ezarowny/Development/pyrollbar/venv/bin/python', '-m', 'pip', '--disable-pip-version-check', 'wheel', '--no-deps', '-w', '/var/folders/yt/3213ptzd3dl61v_ll7614h0w0000gn/T/tmp8oc86fnb', '--quiet', 'blinker']' returned non-zero exit status 1.
bxsx commented 2 years ago

Hi @ezarowny

Thanks for the PR! I understand you want to add tests, but you have an issue with running the tests suite locally. Sorry for the confusion but I can help you with it!

First, blinker is not distributed as a wheel package and therefore setuptools tries to build the package. For that to happen you must install the wheel package.[1]

Second, I don't think PyEnv supports CPython 3.9.10 at the moment. The last version supported is 3.9.9 added in v2.2.1.

Here is a list of all the steps required to run the test suite with Python provided by PyEnv and virtualenv (you can tune it to your taste):

git clone https://github.com/rollbar/pyrollbar
cd pyrollbar

pyenv install 3.9.9
pyenv virtualenv pyrollbar-py3.9
pyenv local pyrollbar-py3.9

pip install wheel

python setup.py test

Finally, since Python 2 is no longer supported, Python 3.10 has removed the Python 2 backward compatibility layers. Therefore Pyrollbar does not support Python 3.10 at the moment (it's on our roadmap).

[1] We are aware that this is not the best solution. We plan to refactor test management and package builder.

ezarowny commented 2 years ago

@bxsx got the tests running. Thanks!

mjhanke commented 2 years ago

Can you guys release a version with this fix?

danielmorell commented 2 years ago

Yes. I just got access to our PyPI package. I will work on this.

brettdh commented 2 years ago

@danielmorell any updates? Just got bit by #399 today.

danielmorell commented 2 years ago

@brettdh I am working on resolving some issues with our CI test suite. Once those are resolved, I will get a release published to PyPI. It should happen today.

brettdh commented 2 years ago

@danielmorell just another check-in, as I lost some time to this again today.

danielmorell commented 2 years ago

Sorry about the delay! Almost there see #409.

danielmorell commented 2 years ago

Version 0.16.3 has been published to PyPI https://pypi.org/project/rollbar/. Again, sorry that took longer than expected!

brettdh commented 2 years ago

Thanks!