Skip to content

Commit 18c3926

Browse files
authored
Remove requirements.txt (#2000)
* Remove requirements.txt * Add build migration * Fix docker build sonar-migration (add cli package) * Remove setup files (replaced by poetry) * Remove setup.py
1 parent 740f4a7 commit 18c3926

File tree

9 files changed

+65
-182
lines changed

9 files changed

+65
-182
lines changed

migration/build.sh

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
#!/bin/bash
2+
#
3+
# sonar-tools
4+
# Copyright (C) 2025 Olivier Korach
5+
# mailto:olivier.korach AT gmail DOT com
6+
#
7+
# This program is free software; you can redistribute it and/or
8+
# modify it under the terms of the GNU Lesser General Public
9+
# License as published by the Free Software Foundation; either
10+
# version 3 of the License, or (at your option) any later version.
11+
#
12+
# This program is distributed in the hope that it will be useful,
13+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15+
# Lesser General Public License for more details.
16+
#
17+
# You should have received a copy of the GNU Lesser General Public License
18+
# along with this program; if not, write to the Free Software Foundation,
19+
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20+
#
21+
22+
ROOT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && cd .. && pwd )"
23+
CONF_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
24+
25+
build_image=1
26+
release=0
27+
release_docker=0
28+
29+
while [[ $# -ne 0 ]]; do
30+
case "${1}" in
31+
nodocker)
32+
build_image=0
33+
;;
34+
pypi)
35+
release=1
36+
;;
37+
dockerhub)
38+
release_docker=1
39+
;;
40+
*)
41+
;;
42+
esac
43+
shift
44+
done
45+
46+
rm -rf "${ROOT_DIR}/build/lib/migration" "${ROOT_DIR}/build/lib/cli" "${ROOT_DIR}/build/lib/sonar" "${ROOT_DIR}"/build/scripts*/sonar_migration "${ROOT_DIR}"/dist/sonar_migration*
47+
mv "${ROOT_DIR}/pyproject.toml" "${ROOT_DIR}/pyproject.toml.sonar-tools"
48+
cp "${ROOT_DIR}/migration/pyproject.toml" "${ROOT_DIR}"
49+
poetry build
50+
mv "${ROOT_DIR}/pyproject.toml.sonar-tools" "${ROOT_DIR}/pyproject.toml"
51+
52+
# Deploy locally for tests
53+
pip install --upgrade --force-reinstall "${ROOT_DIR}"/dist/sonar_migration-*-py3-*.whl
54+
55+
if [[ "${build_image}" == "1" ]]; then
56+
docker build -t olivierkorach/sonar-migration:latest -f migration/snapshot.Dockerfile "${ROOT_DIR}" --load
57+
fi

migration/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ requires = [
6565
]
6666

6767
[tool.poetry]
68-
packages = [{include = "sonar"}, {include = "migration"}]
68+
packages = [{include = "sonar"}, {include = "migration"}, {include = "cli"}]
6969

7070
[dependency-groups]
7171
test = [

migration/release.Dockerfile

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,14 @@ ENV PATH="${VIRTUAL_ENV}/bin:${PATH}"
2222
WORKDIR /opt/sonar-migration
2323

2424
COPY ./sonar sonar
25-
COPY ./requirements.txt .
2625
COPY ./cli cli
27-
COPY ./setup_migration.py .
2826
COPY ./migration migration
2927
COPY ./migration/README.md .
3028
COPY ./LICENSE .
3129
COPY ./sonar/audit sonar/audit
3230

3331
RUN pip install --upgrade pip \
34-
&& pip install sonar-migration==0.4 --force-reinstall
32+
&& pip install sonar-migration==0.6 --force-reinstall
3533

3634
USER ${USERNAME}
3735
WORKDIR /home/${USERNAME}

migration/snapshot.Dockerfile

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,15 @@ ENV PATH="${VIRTUAL_ENV}/bin:${PATH}"
2222
WORKDIR /opt/sonar-migration
2323

2424
COPY ./sonar sonar
25-
COPY ./requirements.txt .
25+
COPY ./migration/pyproject.toml .
2626
COPY ./migration migration
27+
COPY ./migration/README.md .
2728
COPY ./LICENSE .
2829
COPY ./cli cli
29-
COPY ./setup_migration.py .
3030

3131
RUN pip install --upgrade pip \
32-
&& pip install --no-cache-dir -r requirements.txt \
33-
&& pip install --no-cache-dir --upgrade pip setuptools wheel \
34-
&& python setup_migration.py bdist_wheel \
32+
&& pip install --no-cache-dir poetry \
33+
&& poetry build \
3534
&& pip install dist/sonar_migration-*-py3-*.whl --force-reinstall
3635

3736
USER ${USERNAME}

requirements-to-build.txt

Lines changed: 0 additions & 12 deletions
This file was deleted.

requirements.txt

Lines changed: 0 additions & 7 deletions
This file was deleted.

setup.py

Lines changed: 0 additions & 84 deletions
This file was deleted.

setup_migration.py

Lines changed: 0 additions & 67 deletions
This file was deleted.

sonar-project.properties

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ sonar.projectName=Sonar Tools
44
sonar.python.version=3.9
55

66
# Comma-separated paths to directories with sources (required)
7-
sonar.sources=sonar, cli, migration, conf, setup.py, setup_migration.py
7+
sonar.sources=sonar, cli, migration, conf
88

99
# Encoding of the source files
1010
sonar.sourceEncoding=UTF-8
@@ -16,6 +16,5 @@ sonar.sarifReportPaths=build/results_sarif.sarif
1616
# sonar.python.bandit.reportPaths=build/bandit-report.json
1717

1818
sonar.tests=test/gen/latest, test/gen/lts, test/gen/9, test/gen/9-ce, test/gen/cb
19-
sonar.coverage.exclusions=setup*.py, test/**/*, conf/*2sonar.py, cli/cust_measures.py, sonar/custom_measures.py, cli/support.py, cli/projects_export.py, cli/projects_import.py, **/*.sh
19+
sonar.coverage.exclusions=test/**/*, conf/*2sonar.py, cli/cust_measures.py, sonar/custom_measures.py, cli/support.py, cli/projects_export.py, cli/projects_import.py, **/*.sh
2020

21-
sonar.cpd.exclusions=setup*.py

0 commit comments

Comments
 (0)