Skip to main content

Overview

bisos.pipreqs-plus is a thin layer on top of pipreqs that addresses two of pipreqs’ shortcomings when generating requirements.txt for real-world Python projects:

  1. Non-``.py`` Python source files. pipreqs walks *.py files only. Many projects contain executable Python source under bin/ with different suffixes (.cs, .pcs, .mcs) or no extension at all. pipreqs-plus transparently makes these files visible to pipreqs by building a scratch directory of .py symlinks. Detection is automatic: any file whose first line matches a Python shebang (#!.*python*) is included. An optional --extraExts list catches files that lack a shebang.

  2. Namespace-package submodule imports. When pipreqs encounters from NS.X import ... or import NS.X, it collapses the record down to a single NS. For genuine namespace packages where each NS.X is separately published to PyPI (e.g. bisos.b, bisos.common, bisos.pycs), this loses information the requirements.txt needs. pipreqs-plus scans the sources independently for NS.X-style imports and appends the two-level names to requirements.txt. The bare NS line from pipreqs is preserved.

bisos.pipreqs-plus is intended to be broadly useful — it does not depend on the BISOS platform for its core function. It is distributed as a bisos-pip package because that is the packaging convention its author uses.

Package Documentation At Github

The information below is a subset of the full of documentation for this bisos-pip package. More complete documentation is available at: https://github.com/bisos-pip/capability-cs

Table of Contents TOC

Installation

The sources for the bisos.pipreqs-plus pip package are maintained at: https://github.com/bisos-pip/pipreqs-plus.

The bisos.pipreqs-plus pip package is available at PYPI as https://pypi.org/project/bisos.pipreqs-plus.

You can install bisos.pipreqs-plus with pip or pipx.

Installation With pip

pip install bisos.pipreqs-plus

Installation With pipx

For command-line-only use, pipx is a good fit:

pipx install bisos.pipreqs-plus

The following command is made available on PATH:

  • pipreqs-plus.cs

Prerequisite: pipreqs itself must be available on PATH too. Recommended:

pipx install pipreqs

Usage

Minimal invocation

Scan a package source tree and its ./bin directory, write ./requirements.txt:

pipreqs-plus.cs -i genRequirements --srcDir=./myPackage

Full invocation

Every knob explicit:

pipreqs-plus.cs -i genRequirements                       \
    --srcDir=./myPackage                                 \
    --binDir=./bin                                       \
    --outFile=./requirements.txt                         \
    --namespaces="['bisos', 'other']"                    \
    --extraExts="['cs', 'pcs', 'mcs']"                   \
    --pipreqsMode=no-pin

Parameters

Parameter

Kind

Default

Purpose

srcDir

Mandatory

Package source tree; scanned recursively.

binDir

Optional

./bin

Exec utables/scripts dir; scanned top-level only.

outFile

Optional

./req uirements.txt

Where to write.

extraExts

Optional

[]

Python-literal list of extensions to treat as Python.

namespaces

Optional

['bisos']

Python-literal list of namespace packages to expand.

pipreqsMode

Optional

"no-pin"

Passed through to pi preqs --mode.

List-valued parameters (namespaces, extraExts) accept Python-literal syntax. Because PyCS (Python Command Service) is Python-centric, all list values on the command line are Python literals. Use double-quoted shell strings with single-quoted Python strings inside:

--namespaces="['bisos', 'other']"
--extraExts="['cs', 'pcs', 'mcs']"

How it works

Given srcDir and binDir, pipreqs-plus.cs builds a scratch directory of .py symlinks:

  • Files under srcDir are exposed as-is (they are already .py).

  • Files under binDir/* (top level only) are included if:

    1. Their extension is .py, or

    2. Their extension (without dot) is in extraExts, or

    3. Their first line matches ^#!.*\bpython\d*\b (a Python shebang).

    Included files are symlinked with a .py suffix so pipreqs will scan them.

pipreqs is then invoked against the scratch directory and writes outFile.

For each NS in namespaces, the scratch directory is scanned independently for from NS.X ... and import NS.X ... statements. The captured two-level NS.X names are appended to outFile and the file is sort-uniq’d in place.

The scratch directory is removed on exit.

Source code

Source code is written in COMEEGA (https://github.com/bx-blee/comeega); the primary implementation files are:

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

bisos_pipreqsplus-0.1.tar.gz (16.1 kB view details)

Uploaded Source

File details

Details for the file bisos_pipreqsplus-0.1.tar.gz.

File metadata

  • Download URL: bisos_pipreqsplus-0.1.tar.gz
  • Upload date:
  • Size: 16.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.2

File hashes

Hashes for bisos_pipreqsplus-0.1.tar.gz
Algorithm Hash digest
SHA256 a150d2f2e8cb6d282f646299311fa041348d5ba2db93957f1b8dc16cfb986035
MD5 d057c89ec612d6fc4619b8a47b83643a
BLAKE2b-256 8eaf0acad89f10da84cd7d79eeb37bad58bfc8b5959d77900ff56138fc416214

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.1 This release

1 file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page