Update README.md
This commit is contained in:
parent
a69d736903
commit
cb5bdae8e5
1 changed files with 40 additions and 35 deletions
75
README.md
75
README.md
|
@ -141,53 +141,58 @@ The Weird and the Eerie ep 7.aax
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## 📦 `kip` - Intelligent Python Package Installer
|
## 📦 `deps` - Unified Python Dependency Manager
|
||||||
|
|
||||||
A smart package installer that automates Python dependency management, supporting both mamba and pip.
|
A single script that analyzes `import` statements in .py files and installs dependencies using mamba/conda or pip.
|
||||||
|
|
||||||
### Setup
|
|
||||||
```bash
|
|
||||||
chmod +x kip
|
|
||||||
```
|
|
||||||
|
|
||||||
### Usage
|
### Usage
|
||||||
```bash
|
```bash
|
||||||
kip <package1> [<package2> ...] # Install specific packages
|
deps <subcommand> ...
|
||||||
kip <script.py> # Install from Python file
|
|
||||||
kip -r <requirements.txt> # Install from requirements file
|
|
||||||
```
|
```
|
||||||
|
|
||||||
### Key Features
|
#### Subcommands
|
||||||
- Smart import detection in Python files
|
|
||||||
- Handles package name corrections automatically
|
|
||||||
- Uses mamba first, falls back to pip
|
|
||||||
- Supports multiple installation methods
|
|
||||||
- Filters out built-in modules
|
|
||||||
|
|
||||||
### Examples
|
1. **`ls`**
|
||||||
```bash
|
Analyzes `.py` files for external imports:
|
||||||
# Install single package
|
- Writes PyPI-available packages to `requirements.txt`.
|
||||||
kip requests
|
- Writes unavailable packages to `missing-packages.txt`.
|
||||||
|
|
||||||
# Analyze script and install dependencies
|
**Examples**:
|
||||||
kip analysis.py
|
```bash
|
||||||
|
deps ls # Analyze current directory (no recursion)
|
||||||
|
deps ls -r # Recursively analyze current directory
|
||||||
|
deps ls src # Analyze a 'src' folder
|
||||||
|
deps ls -r src # Recursively analyze 'src'
|
||||||
|
```
|
||||||
|
|
||||||
# Install from requirements
|
2. **`install`**
|
||||||
kip -r requirements.txt
|
Installs Python packages either by analyzing local imports or from explicit arguments.
|
||||||
```
|
- **Conda Environment Detection**: If in a conda environment, tries `mamba` (if installed), else `conda`.
|
||||||
|
- **Fallback** to `pip` if conda tool fails or is unavailable.
|
||||||
|
- **`--no-conda`**: Skip conda/mamba entirely and go straight to pip.
|
||||||
|
|
||||||
### Package Corrections
|
**Examples**:
|
||||||
Automatically corrects common package names:
|
```bash
|
||||||
- `yaml` → `pyyaml`
|
deps install # Analyze current folder, install discovered packages (no recursion)
|
||||||
- `dateutil` → `python-dateutil`
|
deps install -r # Same as above but recursive
|
||||||
- `dotenv` → `python-dotenv`
|
deps install requests # Directly install 'requests'
|
||||||
- `newspaper` → `newspaper3k`
|
deps install script.py # Analyze and install packages from 'script.py'
|
||||||
|
deps install -R requirements.txt # Install from a requirements file
|
||||||
|
deps install requests --no-conda # Skip conda/mamba, use pip only
|
||||||
|
```
|
||||||
|
|
||||||
|
### How It Works
|
||||||
|
- **Scanning Imports**: Locates `import ...` and `from ... import ...` lines in `.py` files, skipping built-in modules.
|
||||||
|
- **PyPI Check**: Uses `urllib` to confirm package availability at `pypi.org`.
|
||||||
|
- **Requirements & Missing Packages**: If you run `deps ls`, discovered imports go into `requirements.txt` (available) or `missing-packages.txt` (unavailable).
|
||||||
|
- **Installation**: For `deps install`:
|
||||||
|
- If no extra arguments, it auto-discovers imports in the current directory (optionally with `-r`) and installs only PyPI-available ones.
|
||||||
|
- If passed packages, `.py` files, or `-R <reqfile>`, it installs those specifically.
|
||||||
|
- By default, tries conda environment tools first (mamba or conda) if in a conda environment, otherwise pip.
|
||||||
|
|
||||||
### Notes
|
### Notes
|
||||||
- Requires Python 3.x
|
- If `mamba` or `conda` is available in your environment, `deps install` will prefer that. Otherwise, it uses pip.
|
||||||
- Works with mamba or pip
|
- You can run `deps ls` repeatedly to keep updating `requirements.txt` and `missing-packages.txt`.
|
||||||
- Provides clear installation feedback
|
|
||||||
- Ignores built-in modules and generic names
|
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue