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

nanovna-saver.py: fix execution from outside source directory #632

Merged
merged 1 commit into from
May 2, 2023

Conversation

silbe
Copy link
Contributor

@silbe silbe commented May 2, 2023

nanovna-saver.py can be called from outside the source directory. The module import path needs to be resolved relative to the source directory, not relative to the current working directory of the process.

Fixes: b011000 ("moved to pyscaffold directory structure")

This branch is based on the commit before the transition to PyQt6 as the latter is not available in Debian stable (Bullseye).

Pull Request type

Please check the type of change your PR introduces:

  • Bugfix
  • Feature
  • Code style update (formatting, renaming)
  • Refactoring (no functional changes, no API changes)
  • Build-related changes
  • Documentation content changes
  • Other (please describe):

What is the current behavior?

When executing nanovna-saver.py from outside the source directory but without installing it, importing main fails:

I have no name!@nanovna:~/nanovna-data$ cd ~/nanovna-data && python3 ~/nanovna-saver/nanovna-saver.py -d
Traceback (most recent call last):
  File "/home/sascha/nanovna-saver/nanovna-saver.py", line 29, in <module>
    from NanoVNASaver.__main__ import main
ModuleNotFoundError: No module named 'NanoVNASaver.__main__'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/sascha/nanovna-saver/nanovna-saver.py", line 35, in <module>
    from NanoVNASaver.__main__ import main
ModuleNotFoundError: No module named 'NanoVNASaver.__main__'

Issue Number: N/A

What is the new behavior?

Running nanovna-saver.py from outside the source directory (but without installing it first) works again.

Does this introduce a breaking change?

  • Yes
  • No

Other information

nanovna-saver.py can be called from outside the source directory. The
module import path needs to be resolved relative to the source
directory, not relative to the current working directory of the
process.

Fixes: b011000 ("moved to pyscaffold directory structure")
@silbe silbe requested a review from zarath as a code owner May 2, 2023 09:09
@zarath zarath merged commit 9b4575e into NanoVNA-Saver:main May 2, 2023
@silbe
Copy link
Contributor Author

silbe commented May 2, 2023

Wow, that was quick. Thanks for review & merge!

@silbe silbe deleted the fix-main-import-path branch May 2, 2023 09:16
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.

None yet

2 participants