{"library":"pysonar","title":"Sonar Scanner for Python (pysonar)","description":"pysonar is a command-line tool developed by SonarSource for static code analysis of Python projects with SonarQube or SonarCloud. It acts as a wrapper around the SonarScanner CLI, simplifying configuration and execution for Python ecosystems. It is actively maintained with frequent releases, currently at version 1.4.0.4676, and supports configuration via `pyproject.toml` or `sonar-project.properties` files.","language":"python","status":"active","last_verified":"Mon May 18","install":{"commands":["pip install pysonar"],"cli":{"name":"pysonar","version":"ERROR: Unexpected argument: --version"}},"imports":["pysonar --help"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"# 1. Install pysonar\npip install pysonar\n\n# 2. Configure your project (e.g., in pyproject.toml in your project root)\n#    Replace <your-project-key> with your SonarQube project key.\n#    For SonarCloud, also uncomment and set 'organization'.\n#    For SonarQube Server, ensure host.url is set if not default.\n#\n#  [tool.sonar]\n#  project-key = \"<your-project-key>\"\n#  # host.url = \"https://sonarqube.example.com\"\n#  # organization = \"<your-organization-key>\" \n\n# 3. Run the analysis\n#    Ensure SONAR_TOKEN is set in your environment with a valid SonarQube/SonarCloud token.\n#    Example: export SONAR_TOKEN=\"your_sonar_token_here\"\nimport os\nsonar_token = os.environ.get('SONAR_TOKEN', '')\nif not sonar_token:\n    print(\"Error: SONAR_TOKEN environment variable not set. Please set it before running pysonar.\")\nelse:\n    print(\"Running SonarQube analysis...\")\n    # The actual command would be run in your shell or CI/CD pipeline\n    # For demonstration, we'll print it. In a real scenario, you'd use subprocess.run()\n    print(f\"Executing: pysonar --token {sonar_token}\")\n    # Example of actual command to run (requires `pysonar` to be in PATH):\n    # import subprocess\n    # result = subprocess.run([\"pysonar\", \"--token\", sonar_token], capture_output=True, text=True)\n    # print(result.stdout)\n    # if result.stderr: print(result.stderr)\n    # if result.returncode != 0: print(\"Analysis failed!\")","lang":"python","description":"To quickly get started, install `pysonar`, configure your project (ideally via a `[tool.sonar]` section in `pyproject.toml`), and then run the `pysonar` command with your SonarQube or SonarCloud authentication token. The token can be passed via command-line argument `--token` or an environment variable `SONAR_TOKEN`.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":{"tag":null,"tag_description":null,"last_tested":"2026-05-18","installed_version":"1.5.0.4793","pypi_latest":"1.5.0.4793","is_stale":false,"summary":{"python_range":"3.10–3.9","success_rate":100,"avg_install_s":2.3,"avg_import_s":null,"wheel_type":"wheel"},"results":[{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":"pysonar","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":"21.8M"},{"runtime":"python:3.10-slim","python_version":"3.10","os_libc":"slim (glibc)","variant":"pysonar","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":2.2,"import_time_s":null,"mem_mb":null,"disk_size":"22M"},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":"pysonar","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":"24.5M"},{"runtime":"python:3.11-slim","python_version":"3.11","os_libc":"slim (glibc)","variant":"pysonar","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":2.4,"import_time_s":null,"mem_mb":null,"disk_size":"25M"},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":"pysonar","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":"16.3M"},{"runtime":"python:3.12-slim","python_version":"3.12","os_libc":"slim (glibc)","variant":"pysonar","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":2.1,"import_time_s":null,"mem_mb":null,"disk_size":"17M"},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":"pysonar","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":"16.1M"},{"runtime":"python:3.13-slim","python_version":"3.13","os_libc":"slim (glibc)","variant":"pysonar","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":2.1,"import_time_s":null,"mem_mb":null,"disk_size":"17M"},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":"pysonar","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":"21.0M"},{"runtime":"python:3.9-slim","python_version":"3.9","os_libc":"slim (glibc)","variant":"pysonar","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":2.6,"import_time_s":null,"mem_mb":null,"disk_size":"21M"}]}}