google / google/openhtf

Document considerations when deploying tests using Pyinstaller

Open
#1,219 3 comments 0 reactions 0 assignees View on GitHub
documentation
Dominant language
Python
Stars
722
Forks
237
Avg merge
11h 31m
Merged PRs (30d)
4

Description

I have a small application based on openhtf that I want to distribute to some non-technical people in my company, so to makes things easier, providing a single executable is preferable. Currently, I am looking into pyinstaller, but having some issues.

Essentially, I am able to create an executable in pyinstaller with `pyinstaller --collect-data=openhtf --paths=production-tester --onedir production-tester/tester.py`, but when running the executable, I get the following exception:

```sh
❯ ./dist/tester/tester --help
Traceback (most recent call last):
File "tester.py", line 11, in
File "", line 1360, in _find_and_load
File "", line 1331, in _find_and_load_unlocked
File "", line 935, in _load_unlocked
File "PyInstaller/loader/pyimod02_importers.py", line 450, in exec_module
File "targets/chamber.py", line 68, in
File "openhtf/plugs/__init__.py", line 110, in result
phase = phase_descriptor.PhaseDescriptor.wrap_or_copy(func)
File "openhtf/core/phase_descriptor.py", line 259, in wrap_or_copy
retval = cls(func)
File "", line 6, in __init__
self.func_location = __attr_factory_func_location(self)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
File "openhtf/core/phase_descriptor.py", line 219, in _func_location
line_number = inspect.getsourcelines(obj)[1]
~~~~~~~~~~~~~~~~~~~~~~^^^^^
File "inspect.py", line 1238, in getsourcelines
File "inspect.py", line 1078, in findsource
OSError: could not get source code
[PYI-2911318:ERROR] Failed to execute script 'tester' due to unhandled exception!
```

It seems that openhtf does some runtime introspection that isn't "captured" by pyinstaller.

I realize that this might not be a openhtf issue as much as it is a pyinstaller issue, but I am asking in the hope that someone else might have had the same problem and found a solution.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.