Simplify the in-source launcher script (#660)

The nanovna-saver.py script is ignored by setup.cfg, its only purpose
is to test the version in the source directory.

According to https://setuptools.pypa.io/en/latest/history.html,
pkg_resources.py2warn has been removed from setuptools in 2020
pull/662/head
Name 2023-07-17 14:21:16 +02:00 zatwierdzone przez GitHub
rodzic eff83097f8
commit 21ba0ef665
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
1 zmienionych plików z 15 dodań i 15 usunięć

Wyświetl plik

@ -16,23 +16,23 @@
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>. # along with this program. If not, see <https://www.gnu.org/licenses/>.
from contextlib import suppress # This launcher is ignored by setuptools. Its only purpose is direct
import os # execution from a source tree.
# noinspection PyUnresolvedReferences import os.path
with suppress(ImportError): import sys
# pylint: disable=no-name-in-module,import-error,unused-import
# pyright: reportMissingImports=false
import pkg_resources.py2_warn
try: # Ignore the current working directory.
from NanoVNASaver.__main__ import main src = os.path.join(os.path.dirname(__file__), "src")
except ModuleNotFoundError:
import sys
sys.path.append(os.path.join(os.path.dirname(__file__), "src")) # Ignore previously installed versions.
from NanoVNASaver.__main__ import main sys.path.insert(0, src)
assert os.path.exists(src)
# pylint: disable-next=wrong-import-position
import NanoVNASaver.__main__
if __name__ == "__main__": # The traditional test does not make sense here.
main() assert __name__ == '__main__'
NanoVNASaver.__main__.main()