diff --git a/orekit_jpype/_pyinstaller/entry_points.py b/orekit_jpype/_pyinstaller/entry_points.py new file mode 100644 index 0000000000000000000000000000000000000000..aae4219f7ae98a31a2217f3660b65f55ab395111 --- /dev/null +++ b/orekit_jpype/_pyinstaller/entry_points.py @@ -0,0 +1,16 @@ +import os +from pathlib import Path + + +fspath = getattr(os, 'fspath', str) + + +_pyinstaller_path = Path(__file__).parent + + +def get_hook_dirs(): + return [fspath(str(_pyinstaller_path))] + + +def get_PyInstaller_tests(): + return [fspath(_pyinstaller_path)] diff --git a/orekit_jpype/_pyinstaller/hook-orekit_jpype.py b/orekit_jpype/_pyinstaller/hook-orekit_jpype.py new file mode 100644 index 0000000000000000000000000000000000000000..bb26057d21e6319ce70b0171c226f0a20c1014b5 --- /dev/null +++ b/orekit_jpype/_pyinstaller/hook-orekit_jpype.py @@ -0,0 +1,10 @@ +import os +from pathlib import Path + +import orekit_jpype + +fspath = getattr(os, 'fspath', str) + +jar_path_glob = Path(orekit_jpype.__file__).parent.joinpath("jars", "*.jar") + +datas = [[fspath(jar_path_glob), os.path.join("orekit_jpype", "jars")]] diff --git a/orekit_jpype/_pyinstaller/orekit_data_load_example.py b/orekit_jpype/_pyinstaller/orekit_data_load_example.py new file mode 100644 index 0000000000000000000000000000000000000000..d5bda9c4c1bea50d807466212d1c67b6c2beaf04 --- /dev/null +++ b/orekit_jpype/_pyinstaller/orekit_data_load_example.py @@ -0,0 +1,8 @@ +import orekit_jpype as orekit +orekit.initVM() + +from orekit_jpype.pyhelpers import setup_orekit_data +setup_orekit_data(from_pip_library=True) + +from org.orekit.utils import Constants +assert(Constants.WGS84_EARTH_EQUATORIAL_RADIUS == 6378137.0) diff --git a/orekit_jpype/_pyinstaller/test_orekit_jpype_pyinstaller.py b/orekit_jpype/_pyinstaller/test_orekit_jpype_pyinstaller.py new file mode 100644 index 0000000000000000000000000000000000000000..e4fd310f489e4ffd02cd8cc8b6a88bffa403d4c3 --- /dev/null +++ b/orekit_jpype/_pyinstaller/test_orekit_jpype_pyinstaller.py @@ -0,0 +1,27 @@ +import os +from pathlib import Path +from subprocess import run + +import PyInstaller.__main__ + + +fspath = getattr(os, 'fspath', str) + + +test_file = Path(__file__).parent.joinpath('orekit_data_load_example.py') + + +def test_start_and_stop(tmp_path): + name = 'orekit_jpype_test_app' + dist = tmp_path.joinpath('dist') + work = tmp_path.joinpath('build') + + PyInstaller.__main__.run([ + '--name', name, + '--distpath', fspath(dist), + '--workpath', fspath(work), + '--collect-data', 'orekitdata', + fspath(test_file) + ]) + + run([str(dist / name / name)], check=True) diff --git a/pyproject.toml b/pyproject.toml index fa32798aa7c46e2593d14386466c9dd44d5304e7..7348e31de04fa7dfa06e7b134c9a13bab6bbafa1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -40,5 +40,11 @@ tests = [ ] [pytest] -testpaths = "test" +testpaths = [ + "test", + "orekit_jpype/_pyinstaller" +] +[project.entry-points.pyinstaller40] +"hook-dirs" = "orekit_jpype._pyinstaller.entry_points:get_hook_dirs" +"tests" = "orekit_jpype._pyinstaller.entry_points:get_PyInstaller_tests"