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

Add Django 4.0+ compatibility #400

Merged
merged 3 commits into from
Jan 20, 2022
Merged

Add Django 4.0+ compatibility #400

merged 3 commits into from
Jan 20, 2022

Conversation

ezarowny
Copy link
Contributor

@ezarowny ezarowny commented Jan 18, 2022

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

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Maintenance
  • New release

Related Issues

Checklists

Development

  • Lint rules pass locally
  • The code changed/added as part of this pull request has been covered with tests
  • All tests related to the changed code pass in development

Code review

  • This pull request has a descriptive title and information useful to a reviewer. There may be a screenshot or screencast attached
  • "Ready for review" label attached to the PR and reviewers assigned
  • Issue from task tracker has a link to this pull request
  • Changes have been reviewed by at least one other engineer

@ezarowny
Copy link
Contributor Author

ezarowny commented Jan 18, 2022

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
Copy link
Contributor

bxsx commented Jan 19, 2022

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
Copy link
Contributor Author

@bxsx got the tests running. Thanks!

Copy link
Contributor

@bxsx bxsx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great job @ezarowny 👍
Thanks for the contribution!

@bxsx bxsx merged commit 968bb51 into rollbar:master Jan 20, 2022
@ezarowny ezarowny deleted the django-4.0 branch January 21, 2022 17:25
@mjhanke
Copy link

mjhanke commented May 16, 2022

Can you guys release a version with this fix?

@danielmorell
Copy link
Collaborator

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

@brettdh
Copy link

brettdh commented May 27, 2022

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

@danielmorell
Copy link
Collaborator

@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
Copy link

brettdh commented Jun 7, 2022

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

@danielmorell
Copy link
Collaborator

Sorry about the delay! Almost there see #409.

@danielmorell
Copy link
Collaborator

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

@brettdh
Copy link

brettdh commented Jun 8, 2022

Thanks!

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

Successfully merging this pull request may close these issues.

None yet

5 participants