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:
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.
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:
Their extension is .py, or
Their extension (without dot) is in extraExts, or
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:
file:./bin/pipreqs-plus.cs — CLI entry point.
file:./bisos/pipreqsPlus/scanner.py — namespace-import scanner.
file:./bisos/pipreqsPlus/symlinkTree.py — scratch-tree builder with shebang detection.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a150d2f2e8cb6d282f646299311fa041348d5ba2db93957f1b8dc16cfb986035
|
|
| MD5 |
d057c89ec612d6fc4619b8a47b83643a
|
|
| BLAKE2b-256 |
8eaf0acad89f10da84cd7d79eeb37bad58bfc8b5959d77900ff56138fc416214
|