If a resource is included along with the code, just copy it over during compilation
See original GitHub issueDESCRIPTION: 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:
- Created 3 years ago
- Comments:7 (5 by maintainers)
Top GitHub Comments
@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.
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
--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.