{"id":28495955,"url":"https://github.com/sonarsource/sonar-scanner-python","last_synced_at":"2025-07-02T15:31:29.635Z","repository":{"id":211131017,"uuid":"728221276","full_name":"SonarSource/sonar-scanner-python","owner":"SonarSource","description":"A wrapper around SonarScanner CLI, available on PyPI.","archived":false,"fork":false,"pushed_at":"2025-06-24T16:00:38.000Z","size":528,"stargazers_count":16,"open_issues_count":14,"forks_count":3,"subscribers_count":17,"default_branch":"master","last_synced_at":"2025-06-24T16:22:32.296Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"lgpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/SonarSource.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2023-12-06T13:39:55.000Z","updated_at":"2025-06-23T07:08:41.000Z","dependencies_parsed_at":"2024-03-22T09:30:00.506Z","dependency_job_id":"e9fffaac-0118-4b57-9384-0921db41cde9","html_url":"https://github.com/SonarSource/sonar-scanner-python","commit_stats":null,"previous_names":["sonarsource/sonar-scanner-python"],"tags_count":13,"template":false,"template_full_name":null,"purl":"pkg:github/SonarSource/sonar-scanner-python","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SonarSource%2Fsonar-scanner-python","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SonarSource%2Fsonar-scanner-python/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SonarSource%2Fsonar-scanner-python/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SonarSource%2Fsonar-scanner-python/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SonarSource","download_url":"https://codeload.github.com/SonarSource/sonar-scanner-python/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SonarSource%2Fsonar-scanner-python/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261714847,"owners_count":23198657,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-06-08T11:38:13.853Z","updated_at":"2025-07-02T15:31:29.623Z","avatar_url":"https://github.com/SonarSource.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# pysonar\nA Python scanner for SonarQube, available on PyPI.\n\n# Requirements\n\n - SonarQube v10.6 or above\n - Python 3.9 or above\n\n# Installation\n\nInstall with pip:\n```\npip install pysonar\n```\n\n# Usage\n\nOnce installed, the `pysonar` scanner can be run from the command line to perform an analysis.\nIt assumes a running SonarQube server or a project configured on SonarCloud.\n\n## Setting up analysis properties\n\nIn order for the analysis to run, analysis properties need to be defined. \nThere are multiple ways of providing these properties, described below in descending order of priority:\n\n1. Through CLI arguments to the `pysonar` command\n2. Environment variables for individual properties (e.g. `SONAR_TOKEN`, `SONAR_VERBOSE`, `SONAR_HOST_URL`, ...)\n3. Generic environment variable `SONAR_SCANNER_JSON_PARAMS` \n4. Under the `[tool.sonar]` key of the `pyproject.toml` file\n5. In a dedicated `sonar-project.properties` file\n6. Through common properties extracted from the `pyproject.toml`\n\n### Through CLI arguments\n\nAnalysis properties can be provided as CLI arguments to the `pysonar` command.\nThey can be provided in a similar way as when running the SonarScanner CLI directly \n(see [documentation](https://docs.sonarsource.com/sonarqube-server/2025.1/analyzing-source-code/scanners/sonarscanner/#running-from-zip-file)).\nThis means that analysis properties provided that way should be prepended with `-D`, for instance:\n\n```\n$ pysonar -Dsonar.token=myAuthenticationToken \n```\n\nYou can use all the arguments allowed by __SonarScanner__. \nFor more information on __SonarScanner__ please refer to the [SonarScanner documentation](https://docs.sonarsource.com/sonarqube-server/2025.1/analyzing-source-code/analysis-parameters/).\n\nAdditionally, some common properties can be provided using a shorter alias, such as:\n```\npysonar --token \"MyToken\"\n```\n\nSee [CLI_ARGS](https://github.com/SonarSource/sonar-scanner-python/blob/master/CLI_ARGS.md) for more details.\n\n### With a pyproject.toml file\n\nInside a `pyproject.toml`, Sonar analysis properties can be defined under the `tool.sonar` table.\n\n```\n[tool.sonar]\n# must be unique in a given SonarQube/SonarCloud instance\nprojectKey=my:project\n\n# --- optional properties ---\n# defaults to project key\n#projectName=My project\n# defaults to 'not provided'\n#projectVersion=1.0\n \n# Path is relative to the pyproject.toml file. Defaults to .\n#sources=.\n \n# Encoding of the source code. Default is default system encoding\n#sourceEncoding=UTF-8\n```\n\nThe configuration parameters can be found in the [SonarQube documentation](https://docs.sonarsource.com/sonarqube-server/2025.1/analyzing-source-code/analysis-parameters/).\n\nIn the `pyproject.toml` file the prefix `sonar.` for parameter keys should be omitted. \nFor example, `sonar.scm.provider` in the documentation will become `scm.provider` in the `pyproject.toml` file.\n\nProperties in `pyproject.toml` files are expected to be provided in camel case. However, kebab case is also accepted:\n\n```\n[tool.sonar]\nproject-key=My Project key # valid alias for projectKey\n```\n\nBy default, the scanner will expect the `pyproject.toml` file to be present in the current directory. However, its path can be provided manually through the `toml-path` CLI argument as well as through the `sonar.projectBaseDir` argument. For instance:\n\n```\npysonar --toml-path \"path/to/pyproject.toml\"\n```\n\nOr:\n\n```\npysonar --sonar-project-base-dir \"path/to/projectBaseDir\"\n```\n\nOr:\n\n```\npysonar -Dsonar.projectBaseDir=\"path/to/projectBaseDir\"\n```\n\n### Through project properties extracted from the `pyproject.toml`\n\nWhen a `pyproject.toml` file is available, the scanner can deduce analysis properties from the project configuration. This is currently supported only for projects using `poetry`.\n\n### With a sonar-project.properties file\n\nExactly like [__SonarScanner__](https://docs.sonarsource.com/sonarqube-server/2025.1/analyzing-source-code/scanners/sonarscanner/),\nthe analysis can also be configured with a `sonar-project.properties` file:\n\n```\n# must be unique in a given SonarQube/SonarCloud instance\nsonar.projectKey=my:project\n\n# --- optional properties ---\n\n# defaults to project key\n#sonar.projectName=My project\n# defaults to 'not provided'\n#sonar.projectVersion=1.0\n \n# Path is relative to the sonar-project.properties file. Defaults to .\n#sonar.sources=.\n \n# Encoding of the source code. Default is default system encoding\n#sonar.sourceEncoding=UTF-8\n```\n\n### Through environment variables\n\nIt is also possible to configure the scanner through environment variables:\n\n```\n$ export SONAR_HOST_URL=\"http://localhost:9000\"\n$ pysonar \n```\n\nSee the __SonarScanner__ [documentation](https://docs.sonarsource.com/sonarqube-server/2025.1/setup-and-upgrade/environment-variables/) for more information.\n\n# Feedback\n\nFor feedback and issues regarding `pysonar`, do not hesitate to contact us through our [Community](https://community.sonarsource.com/tag/scanner).\n\n# Installation from testPyPI\n\nTo install the latest pre-released version of Sonar Scanner Python. Execute the following command: \n\n```shell\npip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ pysonar\n```\n\n# License\n\nCopyright 2011-2025 SonarSource.\n\nLicensed under the [GNU Lesser General Public License, Version 3.0](http://www.gnu.org/licenses/lgpl.txt)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsonarsource%2Fsonar-scanner-python","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsonarsource%2Fsonar-scanner-python","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsonarsource%2Fsonar-scanner-python/lists"}