Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
128 changes: 128 additions & 0 deletions .github/workflows/pip-install.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
name: pip install

on:
push:
paths:
- 'setup.py'
- 'pyproject.toml'
- 'MANIFEST.in'
- 'config/**'
- 'codechecker_common/**'
- 'analyzer/**'
- 'web/**'
- 'tools/**'
- '.github/workflows/pip-install.yml'
pull_request:
paths:
- 'setup.py'
- 'pyproject.toml'
- 'MANIFEST.in'
- 'config/**'
- 'codechecker_common/**'
- 'analyzer/**'
- 'web/**'
- 'tools/**'
- '.github/workflows/pip-install.yml'

permissions: read-all

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
pip-install-smoke:
name: "pip install (${{ matrix.os }}, Python ${{ matrix.python }})"
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-24.04, macos-latest, windows-latest]
python: ['3.9', '3.12', '3.13']

steps:
- uses: actions/checkout@v6

- uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python }}

- name: pip install .
run: pip install .

- name: Smoke test
run: |
CodeChecker --help
CodeChecker version
report-converter --help
merge-clang-extdef-mappings --help
post-process-stats --help
tu_collector --help

- name: Verify data files installed
run: |
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd move this part to a separate file to make it more readable and invoke it here. Also given the simplicity of this task, couldn't it be done with bash instead of python?

python -c "
import sysconfig, os
data = sysconfig.get_path('data')
cfg = os.path.join(data, 'share', 'codechecker', 'config')
assert os.path.isdir(cfg), f'Config dir missing: {cfg}'
assert os.path.isfile(os.path.join(cfg, 'package_layout.json')), 'package_layout.json missing'
"

pip-install-editable:
name: "pip install -e . (ubuntu, Python 3.12)"
runs-on: ubuntu-24.04

steps:
- uses: actions/checkout@v6

- uses: actions/setup-python@v6
with:
python-version: '3.12'

- name: pip install -e .
run: pip install -e .

- name: Smoke test
run: |
CodeChecker --help
CodeChecker version

pip-install-analyze:
name: "pip install + analyze (ubuntu, Python 3.12)"
runs-on: ubuntu-24.04

steps:
- uses: actions/checkout@v6

- uses: actions/setup-python@v6
with:
python-version: '3.12'

- name: Install dependencies
run: |
sudo apt-get update -q
sudo apt-get install -y clang clang-tidy cppcheck

- name: pip install .
run: pip install .

- name: Test analyze and parse
run: |
WORK="$RUNNER_TEMP/analyze-test"
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally I'd imagine this in a separate file too because of the length of the script. Also if JQ is available, counting reports could be done with it: CodeChecker parse "$WORK/reports" -e json | jq ".reports | length".

mkdir -p "$WORK"

cat > "$WORK/main.c" <<'EOF'
int main() { int i = 1 / 0; return i; }
EOF

cat > "$WORK/compile_commands.json" <<EOF
[{"directory": "$WORK", "command": "gcc -c $WORK/main.c", "file": "$WORK/main.c"}]
EOF

CodeChecker analyze "$WORK/compile_commands.json" -o "$WORK/reports"
CodeChecker parse "$WORK/reports" -e json | python -c "
import sys, json
reports = json.load(sys.stdin)
assert len(reports) > 0, 'Expected at least one report'
"
12 changes: 12 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,18 @@ venv_dev
.coverage
Makefile.local

# Generated config files (copied/extended from sub-project dirs by setup.py)
config/analyzer_version.json
config/web_version.json
config/git_commit_urls.json
config/session_client.json
config/system_comment_kinds.json
config/server_config.json

# Setuptools artifacts
*.egg-info
dist

/web/server/vue-cli/dist

# tools
Expand Down
9 changes: 8 additions & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,2 +1,9 @@
recursive-include build_dist/CodeChecker/lib/python3/codechecker_report_converter/report/output/html/static *
recursive-include tools/report-converter/codechecker_report_converter/report/output/html/static *
recursive-include config *
recursive-include analyzer/config *
recursive-include web/config *
recursive-include web/server/config *
include LICENSE.TXT
include docs/README.md
include analyzer/requirements.txt
include web/requirements.txt
12 changes: 12 additions & 0 deletions codechecker_common/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,18 @@ def get_data_files_dir_path():
if os.path.exists(data_dir_path):
return data_dir_path

# Editable / development install fallback: config/ lives at the
# repository root, which is the parent of this package's directory.
repo_root = os.path.abspath(
os.path.join(os.path.dirname(__file__), os.pardir)
)
if os.path.isfile(
os.path.join(repo_root, "pyproject.toml")
) and os.path.isfile(
os.path.join(repo_root, "config", "package_layout.json")
):
return repo_root

print("Failed to get CodeChecker data files directory path in: ",
data_dir_paths)
sys.exit(1)
Expand Down
23 changes: 23 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,29 @@ set the `BUILD_UI_DIST` environment variable to `NO` before the package build:
- Use `make standalone_package` instead of `make package` to avoid
having to manually activate the environment before running CodeChecker.

### Alternative: `pip install`

```sh
# Standard install:
pip install .

# Editable install (source changes take effect immediately):
pip install -e .

# Verify:
CodeChecker version
```

#### `make package` vs `pip install`

| Feature | `make package` | `pip install` |
|---------|---------------|---------------|
| Static analysis (`analyze`, `parse`, `check`) | supported | supported |
| Build logging (`CodeChecker log`) | supported (with ldlogger 32+64 bit on Linux and `intercept-build` on OSX) | **not** supported (unless you use `intercept-build` on OSX) |
| Web server and storage | supported | supported, but must build API packages with `make package_api`, then `pip install api/py/codechecker_api/dist/codechecker_api.tar.gz api/py/codechecker_api_shared/dist/codechecker_api_shared.tar.gz` |
| Web frontend (Vue.js UI) | supported | **not** supported |
| Editable / development install | **not** supported | supported (`pip install -e .`) |

### Minimum Recommended package versions

* In production it is recommended to execute CodeChecker with the minimum Python versions: 3.7.14, 3.8.14, 3.9.14, 3.10.6, 3.11.0, otherwise it may be vulnerable to open-redirect attacks. For more info see https://python-security.readthedocs.io/vuln/http-server-redirection.html (CVE-2021-28861).
Expand Down
4 changes: 4 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
[build-system]
requires = ["setuptools>=64", "wheel"]
build-backend = "setuptools.build_meta"

[tool.mypy]
verbosity = 1
show_error_codes = true
Expand Down
Loading
Loading