juanmcasillas / gopro2gpx

Parse the gpmd stream for GOPRO moov track (MP4) and extract the GPS info into a GPX (and kml) file.
GNU General Public License v3.0
181 stars 50 forks source link

Call `main` directly to avoid double invocation #32

Closed stakita closed 1 year ago

stakita commented 1 year ago

The console_scripts configuration appears to be incorrect causing a double invocation of the main function. The way this works is that the __main__.py file contains the following:

from .gopro2gpx import main

main()

This imports the main function symbol into the __main__.py namespace which is a callable symbol. Next the module calls the symbol invoking the main() function. However, this is all happening at import stage.

The gopro2gpx entry point is configured in the following way (setup.py):

    entry_points = {
        'console_scripts': ['gopro2gpx = gopro2gpx.__main__:main']
    }

This both imports the module (gopro2gpx.__main__) causing main to be invoked during import, and then it explicitly calls the main function symbol (console_scripts needs to provide a callable). This results in a double invocation of the main function when invoked from the command line.

This PR invokes the originating main() definition in the module directly, for a 2x speed up. 😉