Skip to main content

PyCrossCheck

A cross-platform compatibility checker for Python code

PyCrossCheck automatically detects platform-specific code that may cause issues on Windows, Linux, or macOS, and provides intelligent suggestions for cross-platform alternatives.

Features

  • Cross-Platform Detection: Identifies Windows, Linux, and macOS-specific code that may break on other platforms
  • Smart Suggestions: Provides clear, actionable recommendations with cross-platform alternatives
  • Comprehensive Analysis: 56+ rules organized in 10 categories covering file system, process management, user operations, and more
  • Easy Integration: Simple CLI interface and JSON output for CI/CD pipelines
  • Bandit Plugin: Extends Bandit static analysis with platform compatibility checks

Installation

pip install pycrosscheck

From Source

# Clone the repository
git clone https://github.com/yourusername/pycrosscheck.git
cd pycrosscheck

# Install in development mode
pip install -e .

Quick Start

Basic Usage

After installation, you can use the pycrosscheck or pycc command:

# Check a single file
pycrosscheck detect myfile.py

# Check an entire project recursively
pycrosscheck detect -r myproject/

# Check with different output formats
pycrosscheck detect --format json myfile.py
pycrosscheck detect --format csv myfile.py

View All Rules

# Display all available compatibility rules
pycrosscheck rules

📖 Usage Examples

Example 1: Check a Python File

pycrosscheck detect script.py

Sample output:

🔍 Detecting Windows compatibility issues...
💡 This tool will provide suggestions for cross-platform alternatives.

Test results:
>> Issue: [PTB001:os_windows_incompatible_functions] Windows-incompatible function: os.getuid()
   Severity: Medium   Confidence: High
   Location: script.py:15
   More Info: https://bandit.readthedocs.io/en/latest/
   💡 Suggestion: Replace with getpass.getuser() - Works on Windows, Linux, and macOS.

Example 2: Check Entire Project

pycc detect -r ./myproject

Example 3: CI/CD Integration

# Generate JSON report for automated processing
pycrosscheck detect -r . --format json > compatibility_report.json

Example 4: Using with Bandit Directly

Since PyCrossCheck is a Bandit plugin, you can also use it with Bandit:

bandit -r myproject/ -t PTB001

📋 Compatibility Rules Categories

PyCrossCheck includes 56+ rules organized into 10 categories:

Category Description Rules
02 Process Management 14 rules
03 User and Group Management 11 rules
04 File System Operations 11 rules
05 Signal Handling 5 rules
06 Inter-Process Communication 3 rules
07 System Information 4 rules
08 Terminal Control 1 rule
09 Device-Specific Operations 4 rules
10 Priority and Scheduling 3 rules

Examples of Detected Issues

User Management Functions

Problematic code:

import os

# Will fail on Windows
user_id = os.getuid()
effective_user = os.geteuid()

✅ PyCrossCheck suggestion:

💡 Replace with getpass.getuser() - Works on Windows, Linux, and macOS.
   Import: 'import getpass'

Fixed code:

import getpass

# Cross-platform solution
username = getpass.getuser()

❌ System Information

Problematic code:

import os

# Will fail on Windows
system_info = os.uname()

PyCrossCheck suggestion:

💡 Replace with platform.uname() for cross-platform system information.
   Import: 'import platform'

Fixed code:

import platform

# Cross-platform solution
system_info = platform.uname()

❌ Process Management

Problematic code:

import os

# Will fail on Windows
pid = os.fork()

PyCrossCheck suggestion:

💡 Replace with multiprocessing.Process() for cross-platform process creation.
   Import: 'from multiprocessing import Process'

Fixed code:

from multiprocessing import Process

def worker():
    # Your code here
    pass

# Cross-platform solution
process = Process(target=worker)
process.start()

🛡️ CI/CD Integration

GitHub Actions Example

name: Compatibility Check

on: [push, pull_request]

jobs:
  check:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - name: Set up Python
        uses: actions/setup-python@v2
        with:
          python-version: "3.9"
      - name: Install PyCrossCheck
        run: pip install pycrosscheck
      - name: Run compatibility check
        run: pycrosscheck detect -r . --format json

Pre-commit Hook

Add to .pre-commit-config.yaml:

repos:
  - repo: local
    hooks:
      - id: pycrosscheck
        name: PyCrossCheck
        entry: pycrosscheck detect
        language: system
        types: [python]

🤝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

📄 License

This project is licensed under the BSD 2-Clause License - see the LICENSE file for details.

🙏 Acknowledgments

  • Built on top of Bandit security analysis tool
  • Inspired by the need for better cross-platform Python code

📞 Support


Made with ❤️ for the Python community

Metadata

Release files for pycrosscheck 1.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 pycrosscheck 1.0.1
File Size Uploaded Provenance Actions
pycrosscheck-1.0.1.tar.gz 32.9 kB Without provenance Details for pycrosscheck-1.0.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pycrosscheck 1.0.1
File Interpreter ABI Platform Actions
pycrosscheck-1.0.1-py3-none-any.whl Python 3 none any Details for pycrosscheck-1.0.1-py3-none-any.whl

Total release size: 71.3 kB

Release files / pycrosscheck-1.0.1.tar.gz

Download URL pycrosscheck-1.0.1.tar.gz
Size 32.9 kB
Tags Source
SHA-256 checksum
How to use checksums
9c6ccafbed8f5d98243ea659e12d2e7dbd63bf07d51676627ef777613d3137e6
BLAKE2b-256 checksum
How to use checksums
8501afa22bd5a3e3ba4ac8643c9c4894a6f95e19d6853001d96ba11bb7d13fe5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.6

Release files / pycrosscheck-1.0.1-py3-none-any.whl

Download URL pycrosscheck-1.0.1-py3-none-any.whl
Size 38.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9a51bd8b4e09fe0fa416838578930e4cdbc3c0ec65de80a6dcbe2a04f3d455b6
BLAKE2b-256 checksum
How to use checksums
c86d4952c68ce6ade026b528cc609d0403bbc7efa415640a8e5f0777f59f986b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.6

Security for pycrosscheck 1.0.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.0.1 This release

2 release files No provenance

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