1

I have a program, that performs (in logical terms) 3 different operations. So far i've written a module and a main.py script that imports module's files and executes. Structure:

── jasper
│   ├── crispr.py
│   ├── database.py
│   ├── __init__.py
│   ├── io.py
│   ├── __pycache__
│   ├── trna.py
│   └── utils.py
├── lib
│   └── python3.8
├── lib64 -> lib
├── LICENSE
├── main.py
├── pyvenv.cfg
├── README.md
├── requirements.txt

I call it like that python main.py --args. What I would like to be able is to do something like this python jasper.database --args, python jasper.crispr --args etc. Every single file would have it's own argparse and would perform different task. I would like to do it also after setuptools installation, so the part python jasper.database --args would be executed without python part, like this: $ jasper crispr --args or $ jasper.crispr --args

7
  • Do you need to call the functions from CLI or would it be acceptable to call them from within a python shell? Commented Jan 14, 2021 at 12:53
  • @Dschoni I have to run the files from CLI. The program will be configured with setuptools and so it has to work like this $ jasper.crispr --args after installation. Commented Jan 14, 2021 at 12:56
  • 1
    To execute without python, you need to make an executable out of the module, which is in most cases platform dependend. So which OS are you on? Commented Jan 14, 2021 at 12:56
  • 1
    Instead a workaround would be to register an alias for each call so e.g. python main.py --jasper.crispr becomes jasper-crisper --args Commented Jan 14, 2021 at 13:04
  • 1
    I think you really want to distribute your module as a package instead of producing an executable for every sub-module. You should define an entry-point that makes sense and probably define an API that is a little more transparent then calling python modules. Commented Jan 14, 2021 at 14:02

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.