{"library":"p4python","title":"P4Python: Perforce Helix Core API","description":"P4Python is the official Python API for Perforce Helix Core, allowing Python applications to interact with Perforce servers. It enables scripting of Perforce operations like file management, changelists, jobs, and user administration. The library is actively maintained with frequent releases, currently at version 2025.2.2863679.","language":"python","status":"active","last_verified":"Sun May 17","install":{"commands":["pip install p4python"],"cli":null},"imports":["from P4 import P4","from P4 import P4Exception"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import os\nfrom P4 import P4, P4Exception\n\n# Configure connection details (prefer environment variables or explicit settings)\n# Example: P4PORT='ssl:perforce:1666', P4USER='your_user', P4CLIENT='your_workspace'\np4_port = os.environ.get('P4PORT', 'perforce:1666') # Replace with your server:port\np4_user = os.environ.get('P4USER', 'guest')       # Replace with your Perforce username\np4_client = os.environ.get('P4CLIENT', 'cli_workspace') # Replace with your client workspace name\np4_password = os.environ.get('P4PASSWD', '')    # Only needed if using password authentication\n\ntry:\n    # Initialize P4 object\n    p4 = P4()\n\n    # Set connection parameters\n    p4.port = p4_port\n    p4.user = p4_user\n    p4.client = p4_client\n    if p4_password:\n        p4.password = p4_password\n\n    # Connect to the Perforce server\n    p4.connect()\n\n    # Log in if required (if 'p4 login' is enforced)\n    # p4.login()\n\n    # Run a simple Perforce command\n    info_output = p4.run('info')\n    print(f\"Successfully connected to Perforce server: {info_output[0]['serverAddress']}\")\n    print(f\"Current Perforce user: {info_output[0]['userName']}\")\n\n    # Get a list of clients\n    clients = p4.run('clients')\n    print(f\"Found {len(clients)} clients.\")\n\nexcept P4Exception as e:\n    # P4Exception catches errors reported by the Perforce server or API\n    for error_msg in e.errors:\n        print(f\"P4API Error: {error_msg}\")\nexcept Exception as e:\n    # Catch other unexpected Python errors\n    print(f\"An unexpected error occurred: {e}\")\nfinally:\n    # Always ensure disconnection\n    if 'p4' in locals() and p4.connected():\n        p4.disconnect()\n        print(\"Disconnected from Perforce server.\")","lang":"python","description":"This quickstart demonstrates how to establish a connection to a Perforce Helix Core server, run a basic 'info' command, and properly disconnect. It prioritizes using environment variables for credentials where possible, falling back to placeholders.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":{"tag":null,"tag_description":null,"last_tested":"2026-05-17","installed_version":"2025.2.2863679","pypi_latest":"2025.2.2863679","is_stale":false,"summary":{"python_range":"3.10–3.9","success_rate":50,"avg_install_s":2.4,"avg_import_s":0.04,"wheel_type":"wheel"},"results":[{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":"p4python","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.10-slim","python_version":"3.10","os_libc":"slim (glibc)","variant":"p4python","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":2.4,"import_time_s":0.03,"mem_mb":1.6,"disk_size":"120M"},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":"p4python","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.11-slim","python_version":"3.11","os_libc":"slim (glibc)","variant":"p4python","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":2.4,"import_time_s":0.05,"mem_mb":2,"disk_size":"122M"},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":"p4python","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.12-slim","python_version":"3.12","os_libc":"slim (glibc)","variant":"p4python","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":2.4,"import_time_s":0.04,"mem_mb":1.8,"disk_size":"114M"},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":"p4python","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.13-slim","python_version":"3.13","os_libc":"slim (glibc)","variant":"p4python","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":2.3,"import_time_s":0.04,"mem_mb":1.6,"disk_size":"114M"},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":"p4python","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.9-slim","python_version":"3.9","os_libc":"slim (glibc)","variant":"p4python","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":2.7,"import_time_s":0.03,"mem_mb":1.6,"disk_size":"120M"}]}}