poncho_package_analyze(1)

πŸ“¦
version 7.15.9 Β· 2 versions
, in ubuntu resolute, ubuntu stonking

πŸ’– poncho_package_analyze(1) πŸ’–

okay bestie, welcome to the Cooperative Computing Tools manual, section 1, and today's main character is poncho_package_analyze β€” a whole command-line utility for sniffing out the library and interpreter deps hiding inside your Python script. it's giving detective energy fr fr πŸ•΅οΈβ™€οΈβœ¨


✨ NAME ✨

poncho_package_analyze β€” a command-line utility for analyzing a Python script for library and interpreter dependencies πŸπŸ’…


🌸 SYNOPSIS 🌸

poncho_package_analyze [options] <python-script ...>  <json-output-file>

πŸ¦‹ DESCRIPTION πŸ¦‹

so basically, poncho_package_analyze is a cute lil command line utility that analyzes your Python scripts and figures out which external dependencies they actually need. then it spits out an output file you can hand straight to python_package_create to build a self-contained Conda environment for your Python app. no cap, it's iconic. πŸ‘‘

the python-script ... argument is the path (or paths, plural, she's flexible) to the Python script(s) you want analyzed. the json-output-file argument is the path to the output JSON file that this command is gonna generate for you.

and here's the fun part β€” if you specify - for either one of those, it'll use stdin/stdout instead of a file. stream queen behavior. 🌈


πŸ’… OPTIONS πŸ’…

  • -h, --help β€” show this help message. classic. ✨
  • --toplevel β€” only include imports that live at the top level of the script. no digging into functions, we stay surface level. πŸŽ€
  • --function=<<fn>> β€” only include the imports inside the given function. hyper-specific, we love a targeted vibe. 🎯
  • --pkg-mapping=<<import=name>> β€” tell it that the module imported as <import> in your code is actually provided by the pip/conda package <name>. naming drama resolved. 🫢
  • --extra-pkg=<pkg> β€” also include the pip/conda package <pkg>, even if it doesn't show up anywhere in the sources. super useful for scripts that execute other (possibly non-Python) components that also need to be included. come through, bonus package. πŸ“¦

πŸ’€ EXIT πŸ’€

on success, it returns zero. on failure, it returns non-zero. simple as that, bestie.


πŸ“ EXAMPLE πŸ“

say we have an example Python script called example.py containing the following code:

import os
import sys
import pickle

import antigravity
import matplotlib

if __name__ == "__main__":
    print("example")

to analyze the example.py script for its dependencies and generate the output JSON dependencies file dependencies.json, you run the following command:

$ poncho_package_analyze example.py dependencies.json

once the command completes, the dependencies.json file sitting in the current working directory will contain a Conda environment specification (suitable to use with conda env create). slay. πŸ’–

okay important notes, pay attention bestie 😭 β€” system-level modules are considered part of the Python package installed into the Conda environment. also, imports that aren't managed by Pip or Conda are not allowed. that includes other modules within the CWD, and modules in user-written packages. so don't try it. πŸ™ˆ

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. ⭐


and that's a wrap on the poncho_package_analyze(1) page from CCTools 7.15.9 FINAL β€” go analyze something, bestie, you got this πŸ§šπŸ’œ

πŸ“¦ where this page comes from