From c9db3eebe7a674d6e27e4b16b68a0f6d754d7496 Mon Sep 17 00:00:00 2001 From: John Kristensen Date: Mon, 29 Mar 2021 22:38:07 +1100 Subject: [PATCH 2/3] Use entry_point console_scripts for installing scripts Use the setuptools preferred method for install scripts using setup.py. This also enables scripts to be correctly installed with using the setuptools develop command (issue2550866 & issue2550898). --- setup.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/setup.py b/setup.py index da9dc218cb..b51e27dda1 100755 --- a/setup.py +++ b/setup.py @@ -41,13 +41,15 @@ def include(d, e): return (d, [f for f in glob('%s/%s'%(d, e)) if os.path.isfile(f)]) -def scriptname(path): + +def mapscript(path): """ Helper for building a list of script names from a list of module files. """ - script = os.path.splitext(os.path.basename(path))[0] - script = script.replace('_', '-') - return script + module = os.path.splitext(os.path.basename(path))[0] + script = module.replace('_', '-') + return '%s = roundup.scripts.%s:run' % (script, module) + def main(): # template munching @@ -63,7 +65,7 @@ def main(): ] # build list of scripts from their implementation modules - scripts = [scriptname(f) for f in glob('roundup/scripts/[!_]*.py')] + scripts = [mapscript(f) for f in glob('roundup/scripts/[!_]*.py')] data_files = [ ('share/roundup/cgi-bin', ['frontends/roundup.cgi']), @@ -159,7 +161,9 @@ def main(): 'install_lib': install_lib, }, packages=packages, - scripts=scripts, + entry_points={ + 'console_scripts': scripts + }, data_files=data_files) if __name__ == '__main__': -- 2.30.1