Python packaging: catering to different audiences -


I am working on a Python package that includes two scripts using library modules and libraries. One of the scripts is a command line tool, which is printing some text and the other is a JSON API server.

Looking at this situation, I look at three main audiences or use cases for the package:

  1. Library users: The main module is required module Want to test and slate for your code and access the script as an example.

  2. CLI User: The CLI scripts want to run the script every time and then do not need the API server, and probably do not care to access the script source.

  3. API Provider: Similar to CII user, but with API server script. Need a CLI script for quick testing.

How can I structure this in a directory tree and in one or more delivery packages (possibly using setuptools)?

The current source layout is as follows:

  main_folder README setup.py mypackage __init__.py # library function mymodule.py # for easy import into script __init__.py includes cli.py api_server.py  

It is now that I What has happened.

I saw PEPI looking for similar packages, then looked at that directory and its structure.

There I entry points found out about the parameters, which allows you to specify a function module, which will be converted into scripts to the build time. These scripts may also have additional dependencies.

changed related __ main __ blocks functions designated I-related functions to work with it and have marked them as entry points. Related blocks (all setuptools.setup () parameter) looks like this:

  [...] requires = [ 'pyswisseph', 'numpy' ], Extras_require = { 'flask' [ 'flask']}, Antry_points = { 'Kansol_skripts' [ 'Sserridven = Siridvenkcli main' Sserridven-server = Sseridven. API_server: main [flask] ']} [. ..] The  

Get everyone modules and scripts, but optional dependencies will be installed only if they are required to run the first time. Script lock will also be installed as part of the main module so that everyone can use their own helpful tasks as needed.

To be a script as an example, I intend to reference the project sites on the project's web site.

The directory structure was left in its original state.

I hope that helps someone else :)


Comments

Popular posts from this blog

import - Python ImportError: No module named wmi -

Editing Python Class in Shell and SQLAlchemy -

lua - HowTo create a fuel bar -