cms-dev / cms-dev/cms

Split out the "executable" part of the source

Open
#85 5 comments 0 reactions 1 assignee View on GitHub

@lw is already working on this.

Since Jan 13, 2013.

programming_style
Dominant language
Python
Stars
1k
Forks
412
Avg merge
6d 10h
Merged PRs (30d)
3

Description

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?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.