Skip to content

Commit

Permalink
Merge pull request #30 from agrenott/dev
Browse files Browse the repository at this point in the history
Fix entry point for packaging
  • Loading branch information
agrenott authored Nov 6, 2023
2 parents 5b1add0 + 8bfcbbf commit fec6523
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
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

0 comments on commit fec6523

Please sign in to comment.