Skip to main content

System Dependency Checker for Python Projects

Project description

sysdep - System Dependency Checker for Python

sysdep is a cross-platform tool to manage and verify non-Python system dependencies required by Python applications. It fills the gap between Python package management and system-level dependencies.

Problem

While Python package managers like pip, Poetry, or Pipenv handle Python modules well, there's no unified way to:

  • Declare system dependencies (like FFmpeg, ImageMagick, or platform libraries)
  • Verify if those dependencies are installed on a user's system
  • Guide users through installation of missing dependencies

Features

  • Declarative Dependencies: Specify system requirements in a clear, structured format
  • Cross-Platform Support: Works on Linux, macOS, and Windows
  • Automatic Detection: Scans for common tools and libraries
  • Installation Guidance: Suggests installation commands for missing dependencies
  • CI Integration: Easy to integrate with CI/CD pipelines
  • Development Tool: Checks dependencies during development or installation
  • Code Annotations: Scan Python code for special comments that declare dependencies
  • Progress Bars: Visual feedback for long-running operations

Installation

# Basic installation
pip install sysdep

# Install with UI enhancements (progress bars)
pip install "sysdep[ui]"

Install with UI enhancements

pip install "sysdep[ui]"


## Quick Start

### Create a dependency manifest

Create a file named `system_requirements.txt` in your project:

Media processing tools

executable: ffmpeg >= 4.2.0 executable: imagemagick

Libraries

library: libssl >= 1.1.0


### Check dependencies

```bash
# Check dependencies from manifest file
sysdep check -f system_requirements.txt

# Scan Python files for dependency annotations
sysdep check -d ./my_package

# Output in JSON format
sysdep check -f system_requirements.txt --json

Install missing dependencies

sysdep install -f system_requirements.txt

Generate manifest

# Generate from code annotations
sysdep generate ./my_package -o system_requirements.txt

# Generate from Python dependencies (requirements.txt, pyproject.toml, setup.py)
sysdep generate ./ --from-python-deps -o system_requirements.txt

# Map Python packages to system dependencies
sysdep map numpy pillow opencv-python

# Map packages from requirements.txt
sysdep map --file requirements.txt

Dependency Declaration

Manifest File

The system_requirements.txt file uses a simple format:

# Comments start with hash
dependency_type: name [>= version]

Available dependency types:

  • executable: Command-line tools found in PATH
  • library: Shared libraries/DLLs

Automatic Generation from Python Dependencies

sysdep can automatically generate system requirements from your Python dependencies:

sysdep generate ./ --from-python-deps

This will:

  1. Scan your project for requirements.txt, pyproject.toml, and setup.py files
  2. Extract Python package dependencies
  3. Map those packages to known system dependencies
  4. Generate a system_requirements.txt file

Supported mappings include (but not limited to):

  • pillow → libjpeg, libpng
  • opencv-python → opencv libraries
  • moviepy, pydub → ffmpeg
  • numpy, scipy → BLAS, LAPACK
  • psycopg2 → libpq
  • lxml → libxml2, libxslt
  • tensorflow, pytorch → CUDA libraries
  • And many more!

Code Annotations

You can declare dependencies directly in your Python code using special comments:

# sysdep: ffmpeg >= 4.2.0
import subprocess

def process_video(input_file, output_file):
    # requires-system: imagemagick
    subprocess.run(['ffmpeg', '-i', input_file, output_file])

Integration with Setuptools

sysdep integrates with setuptools to automatically check dependencies during package installation:

# setup.py
from setuptools import setup, find_packages
from sysdep.setuptools_integration import setup_integration

setup_kwargs = {
    'name': 'my-package',
    'version': '0.1.0',
    # Other setup parameters...
}

# Integrate sysdep with setuptools
setup_integration(setup_kwargs)

# Run setup
setup(**setup_kwargs)

This adds a sysdep command to setuptools and modifies the install and develop commands to check dependencies first.

# Check dependencies
python setup.py sysdep

# Install package and check dependencies
python setup.py install

# Use strict mode to fail if dependencies are missing
python setup.py sysdep --strict

API Usage

from sysdep import check_dependencies
from sysdep.parsers.code_scanner import DependencyScanner

# Check dependencies from manifest file
results = check_dependencies('system_requirements.txt')
if not results['all_installed']:
    print("Missing dependencies:")
    for dep in results['missing']:
        print(f"- {dep['name']}")

# Scan for dependencies in code
scanner = DependencyScanner()
dependencies = scanner.scan_directory('./my_package')

License

MIT License

Copyright (c) 2024-2025 Latiful Mousom

See the LICENSE file for details.

Project details


Download files

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

Source Distribution

sysdep-0.1.4.tar.gz (27.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sysdep-0.1.4-py3-none-any.whl (33.4 kB view details)

Uploaded Python 3

File details

Details for the file sysdep-0.1.4.tar.gz.

File metadata

  • Download URL: sysdep-0.1.4.tar.gz
  • Upload date:
  • Size: 27.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.14

File hashes

Hashes for sysdep-0.1.4.tar.gz
Algorithm Hash digest
SHA256 ab6a697325630e70d8887262d38f37c2acb390159b34b980945f2c25fac61044
MD5 7908df2b45cf5f9e527ad6242244019b
BLAKE2b-256 088cedfc8f73648c25f0daafda0b04a922185ddb3d919197814d9bc68ea7c45a

See more details on using hashes here.

File details

Details for the file sysdep-0.1.4-py3-none-any.whl.

File metadata

  • Download URL: sysdep-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 33.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.14

File hashes

Hashes for sysdep-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 1bfab817688acee122a2359d7683a3b60f517d95f2aa1e1ad615fb010413f90f
MD5 a8e0ab9cde137307a904867b34943aca
BLAKE2b-256 bffba78468752961653fcc05d6cd144333d2a2acd774bfb58c6930c6009cb867

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page