Skip to content

Split out the "executable" part of the source #85

Open
@lw

Description

@lw

Right now in the module for each service there's a global 'main' function that gets executed when the module is launched from the command line as a Python script. We then instruct setuptools to automatically create and install console scripts as entry points for these functions. I don't think it's the correct approach.

I suggest to move out all these 'main' functions from their modules and put them each in a separate file inside a new $REPO/bin directory and tell setuptools to just use these scripts as "entry points" (thus installing them in /usr/bin) instead of creating its own ones. This is possible using the 'scripts' keyword of the 'setup' function. (This keyword is already defined by distutils, and is not an extension introduced by setuptools like 'entry_points' is) (The distutils documentation suggests the $REPO/scripts directory, yet I prefer 'bin'...)

This approach has no clear practical advantage: I propose it just to separate the code that "does things" from the code needed to initialize it (e.g. parsing command line arguments, etc.). One small practical advantage would be a simpler and more robust solution for issue #79, since all executable files would be in the same directory.

This change doesn't only apply to services. Other tools, like the ones in cmscontrib, could be moved to 'bin'. We could for example have YamlImporter and Reimporter become simple executable scripts which call, in slightly different ways, functions and classes in a new module (called for example YamlLoader) placed in cmscontrib, which does all the dirty work. (This is related to the change I proposed in #71)

What do you think?

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions