Skip to content

Add sample code for Nuitka standalone executable tutorial - #805

Open
shabnomm wants to merge 19 commits into
masterfrom
shabnomm-patch-1
Open

Add sample code for Nuitka standalone executable tutorial#805
shabnomm wants to merge 19 commits into
masterfrom
shabnomm-patch-1

Conversation

@shabnomm

Copy link
Copy Markdown

Sample code for the "Nuitka: Compile Your Python Code Into a Standalone Executable" tutorial.

  • wordcount.py: command-line word-count tool used throughout the tutorial
  • cpu_benchmark.py: CPU-bound benchmark script used in the performance section
  • sample.txt: sample input file for wordcount.py

@realpython-bot realpython-bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@shabnomm Relaying from @bzaczynski: two fixes are needed before this can merge, both found while checking the sample code against the tutorial.

  1. sample.txt starts with a UTF-8 byte-order mark (bytes EF BB BF). Because wordcount.py reads the file with encoding="utf-8" rather than utf-8-sig, the first token becomes python, and the output is is: 3, popular: 2, python: 2, … instead of the python: 3, is: 3, … shown in the article. Please re-save the file without the BOM (in VS Code, click the encoding in the status bar, choose "Save with Encoding", then "UTF-8" rather than "UTF-8 with BOM").
  2. README run command: ./wordcount.dist/wordcount should be ./wordcount.dist/wordcount.bin, matching the tutorial. While you're there, consider pinning python -m pip install nuitka==4.2.1 to match the article.

Nothing else needed. wordcount.py and cpu_benchmark.py match the tutorial exactly.

@shabnomm

Copy link
Copy Markdown
Author

@bzaczynski Hi, I’ve fixed the sample.txt encoding and updated the README commands accordingly. Thank you.

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.

3 participants