question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

If a resource is included along with the code, just copy it over during compilation

See original GitHub issue

DESCRIPTION: It’s an encumbrance to have to copy non-Python resources from my source directory tree to my output directory tree after using Nuitka. Resources that are found among the Python source files ought just be copied over as part of building the output.

ENVIRONMENT:

  • My employer’s flavor of gmacOS 10.15.6
  • Python 3.6.8
  • Nuitka 0.6.8.4

STEPS TO REPRODUCE:

  • python -m pip install --upgrade importlib_resources nuitka paramiko requests zeroconf
  • Unzip, untar, and cd into this code
  • python -m nuitka --output=2020-08-21 --standalone --show-progress --show-scons --python-flag=no_site representative/__main__.py
  • python -m nuitka --output=2020-08-21 --standalone --show-progress --show-scons --python-flag=no_site representative/__main__.py
  • ./2020-08-21/__main__.dist/__main__

EXPECTED RESULT: ./2020-08-21/__main__.dist/__main__ will show the same output as would have been shown by installing the representative sdist and then running python -m representative:

Embedded text is 47 long!
Instantiated an SSHClient: <something that looks like an object instance at a memory location>

OBSERVED RESULT: FileNotFoundError: 'resource.txt' resource not found in 'representative.util' (plus other stack bits).

WORKAROUND: After using Nuitka to build, mkdir -p fct-2020-08-21/__main__.dist/representative/util && cp representative/util/resource.txt fct-2020-08-21/__main__.dist/representative/util.

ADDITIONAL INFORMATION: There’s some related discussion in this earlier issue but the offered solution seems heavyweight (learn the plugin system and author a plugin?); simply including the data resources found among the Python source files strikes me as likely good ergonomics.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
kayhayencommented, Jan 25, 2021

@ThatXliner the manifest file will be used if you create a wheel already. For binaries, it tends to be unused, but I would definitely welcome a PR, that attempts to copy files from there automatically.

0reactions
kayhayencommented, Jan 25, 2021

So, the latest release has an option --include-package-data that accepts patterns, e.g. * would include everything that is found, which might not be limited enough yet though. But it’s considered the solution.

Changelog says

  • Onefile: Added command line options to include data files. These are --include-package-data which will copy all non-DLLs and non-Python files of package names matching the pattern given. And --include-data-file takes source and relative target file paths and copies them. For onefile this is the only way to include files, for standalone mode they are mostly a convenience function.
Read more comments on GitHub >

github_iconTop Results From Across the Web

What is Source Code in Programming and How Does It ...
Source code is the fundamental component of a computer program that is created by a programmer. It can be read and easily understood...
Read more >
How does one copy a dialog resource from one project to ...
RC files are simple text files. You can simply copy/paste the DIALOG text from one .RC file to the other. Make sure that...
Read more >
GCC and Make - A Tutorial on how to compile, link ...
When your program is linked against a static library, the machine code of external functions used in your program is copied into the...
Read more >
Code of Federal Regulations
Help accessing the Code of Federal Regulations within govinfo, including searching and browsing tips as well as contextual information, ...
Read more >
Object lifetime and resource management (RAII)
Its only member g is itself declared on the stack, and simply goes out of scope along with w . No special code...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found