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:

Metadata

Release files for bisos.pipreqsPlus 0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for bisos.pipreqsPlus 0.1
File Size Uploaded
bisos_pipreqsplus-0.1.tar.gz 16.1 kB Details

Release files / bisos_pipreqsplus-0.1.tar.gz

Download URL bisos_pipreqsplus-0.1.tar.gz
Size 16.1 kB
Tags Source
SHA-256 checksum
How to use checksums
a150d2f2e8cb6d282f646299311fa041348d5ba2db93957f1b8dc16cfb986035
BLAKE2b-256 checksum
How to use checksums
8eaf0acad89f10da84cd7d79eeb37bad58bfc8b5959d77900ff56138fc416214
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.11.2

Release history Release notifications | RSS feed

This release

0.1 This release

1 release 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