NAME
poncho_package_analyze - command-line utility for analyzing Python script for library and interpreter dependencies
SYNOPSIS
FCponcho_package_analyze [options] <python-script ...> <json-output-file>FT
DESCRIPTION
poncho_package_analyze is a simple command line utility for analyzing Python scripts for the necessary external dependencies. It generates an output file that can be used with python_package_create to build a self-contained Conda environment for the Python application.
The FCpython-script ...FT argument is the path(s) to the Python script(s) to be analyzed. The FCjson-output-fileFT argument is the path to the output JSON file that will be generated by the command. Specifying - for either will use stdin/stdout instead of a file.
OPTIONS
- -h,--help
-
Show this help message
- --toplevel
-
Only include imports at the top level of the script.
- --function=<<fn>>
-
Only include imports in the given function.
- --pkg-mapping=<<import=name>>
-
Specify that the module imported as <import> in the code is provided by the pip/conda package <name>.
- --extra-pkg=<pkg>
-
Also include the pip/conda package <pkg>, even if it does not appear in the sources. May be useful for scripts that execute other (possibly non-Python) components that must also be included.
EXIT
On success, returns zero. On failure, returns non-zero.
EXAMPLE
An example Python script FCexample.pyFT contains the following code:
-
import os import sys import pickle
import antigravity import matplotlib
if __name__ == "__main__":
print("example")
To analyze the FCexample.pyFT script for its dependencies and generate the output JSON dependencies file FCdependencies.jsonFT, run the following command:
FC$ poncho_package_analyze example.py dependencies.jsonFT
Once the command completes, the FCdependencies.jsonFT file within the current working directory will contain a Conda environment specification (suitable to use with FCconda env createFT).
Note that system-level modules are considered part of the Python package installed into the Conda environment. Additionally, imports not managed by Pip or Conda are not allowed. This includes other modules within the CWD or in user-written packages.
COPYRIGHT
The Cooperative Computing Tools are Copyright (C) 2022 The University of Notre Dame. This software is distributed under the GNU General Public License. See the file COPYING for details.