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

Fix syntax error when building with nuitka #2635

Merged
merged 3 commits into from
Mar 4, 2023
Merged

Fix syntax error when building with nuitka #2635

merged 3 commits into from
Mar 4, 2023

Conversation

cilki
Copy link
Contributor

@cilki cilki commented Nov 9, 2022

Type of changes

  • Bug fix
  • New feature
  • Documentation / docstrings
  • Tests
  • Other

Checklist

  • I've run the latest black with default args on new code.
  • I've updated CHANGELOG.md and CONTRIBUTORS.md where appropriate.
  • I've added tests for new code.
  • I accept that @willmcgugan may be pedantic in the code review.

Description

Nuitka throws a syntax error when building the rich.pretty module because of the missing symbol get_ipython. Instead of using try/except as control flow, it's better to explicitly check for the existence of this global function.

Otherwise, rich works well when converted into C with Nuitka. Thanks!

@willmcgugan
Copy link
Collaborator

Interesting. Did you notice any difference with Rich as compiled C?

@codecov-commenter
Copy link

codecov-commenter commented Dec 4, 2022

Codecov Report

Base: 98.38% // Head: 98.25% // Decreases project coverage by -0.12% ⚠️

Coverage data is based on head (34a3935) compared to base (c3a2450).
Patch coverage: 94.73% of modified lines in pull request are covered.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2635      +/-   ##
==========================================
- Coverage   98.38%   98.25%   -0.13%     
==========================================
  Files          64       64              
  Lines        6807     6816       +9     
==========================================
  Hits         6697     6697              
- Misses        110      119       +9     
Flag Coverage Δ
unittests 98.25% <94.73%> (-0.13%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
rich/_export_format.py 100.00% <ø> (ø)
rich/spinner.py 100.00% <ø> (ø)
rich/text.py 99.48% <ø> (ø)
rich/progress.py 92.92% <83.33%> (+0.12%) ⬆️
rich/color.py 100.00% <100.00%> (ø)
rich/console.py 98.01% <100.00%> (ø)
rich/file_proxy.py 97.50% <100.00%> (ø)
rich/json.py 100.00% <100.00%> (ø)
rich/markdown.py 100.00% <100.00%> (ø)
rich/pretty.py 96.52% <100.00%> (-2.46%) ⬇️
... and 5 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@cilki
Copy link
Contributor Author

cilki commented Dec 4, 2022

I've only tried a few components (Markdown, Table, Progress, Console), but they all seem to work exactly the same after fixing the get_ipython thing. My command line for posterity:

nuitka3 \
        --follow-imports \
        --remove-output \
        --lto=yes \
        --static-libpython=no \
        --include-package=pygments \
        -o output \
        main.py

There may be minor performance differences, but I'm not pushing it hard enough yet to tell.

@@ -272,7 +272,7 @@ def __call__(self, value: Any) -> Any:
# replace plain text formatter with rich formatter
rich_formatter = RichFormatter()
ip.display_formatter.formatters["text/plain"] = rich_formatter
except Exception:

Choose a reason for hiding this comment

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

While I never used nuitka, I know enough to solute removal of "except Exception" ;)

@willmcgugan willmcgugan merged commit 13e238b into Textualize:master Mar 4, 2023
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.

4 participants