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

Fix entry point for packaging #30

Merged
merged 1 commit into from
Nov 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .github/workflows/pythonpackage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@ jobs:
hatch run geotiff:all
- name: Run unit test without Geotiff dependencies
run: |
hatch run test
hatch run test
- name: Ensure script entrypoint is executable
run: |
hatch run pyhgtmap -v
- name: Report test-coverage to DeepSource
# Deepsource doesn't seem super stable
continue-on-error: true
Expand Down
10 changes: 8 additions & 2 deletions pyhgtmap/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -554,7 +554,7 @@ def parseCommandLine(sys_args: List[str]) -> Tuple[Values, List[str]]:
return opts, args


def main(sys_args: List[str]) -> None:
def main_internal(sys_args: List[str]) -> None:
opts, args = parseCommandLine(sys_args)
configure_logging(opts.logLevel)

Expand Down Expand Up @@ -589,5 +589,11 @@ def main(sys_args: List[str]) -> None:
)


def main() -> None:
"""Parameter-less entry point, required for python packaging scripts"""
# https://packaging.python.org/en/latest/specifications/entry-points/#use-for-scripts
main_internal(sys.argv[1:])


if __name__ == "__main__":
main(sys.argv[1:])
main()
6 changes: 3 additions & 3 deletions tests/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def test_main_download_from_poly(HgtFilesProcessor_mock, NASASRTMUtil_mock) -> N
]

# Test
main.main(sys_args)
main.main_internal(sys_args)

# Check
NASASRTMUtil_mock.getFiles.assert_called_once()
Expand Down Expand Up @@ -65,7 +65,7 @@ def test_main_manual_input_poly(HgtFilesProcessor_mock, NASASRTMUtil_mock) -> No
]

# Test
main.main(sys_args)
main.main_internal(sys_args)

# Check
NASASRTMUtil_mock.getFiles.assert_not_called()
Expand Down Expand Up @@ -93,7 +93,7 @@ def test_main_manual_input_no_poly(HgtFilesProcessor_mock, NASASRTMUtil_mock) ->
]

# Test
main.main(sys_args)
main.main_internal(sys_args)

# Check
NASASRTMUtil_mock.getFiles.assert_not_called()
Expand Down