Skip to content

Commit 79b100c

Browse files
authored
build: reworks build process, adds distributive name into package name. (#221)
1 parent 48f7143 commit 79b100c

File tree

10 files changed

+78
-92
lines changed

10 files changed

+78
-92
lines changed

CONTRIBUTING.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,17 @@ Note that all of the unit tests names should starts with prefix 'test_'.
2323

2424
## Branches rules
2525

26-
1) The 'main' branch consists sources of the last work and tested version of the util, correct documentation, some helpfull scripts and research notebooks;
27-
2) The 'develop' branch consist source of the current developing version;
26+
1) The 'main' branch consists sources of the last work and tested version of the util, correct documentation, some helpfull scripts and research notebooks.
27+
2) The 'develop' branch consist source of the current developing version.
2828
3) All pull requests should fix one issue or some related issues. After the review, all commits will squash (combined into one) and merge with descriptive message.
2929

3030
## Making pull requests
3131

3232
Sequence for submitting PR:
3333

34-
1) Fork this repo (for external contributors) or clone (for internal contributors);
35-
2) Make branch off of 'develop' branch;
36-
3) Add descriptive unit tests;
37-
4) If desire, you may to add auto tests. When adding error fixes it's required;
38-
5) After making commits check that all pre-commit hooks is passed;
39-
6) Push commits into your remote branch and than create pull request.
34+
1) Fork this repo (for external contributors) or clone (for internal contributors).
35+
2) Make branch off of 'main' branch.
36+
3) Add descriptive unit tests if you affect the source code.
37+
4) If desire, you may to add auto tests. When adding error fixes it's required.
38+
5) After making commits check that all pre-commit hooks is passed.
39+
6) Push commits into your remote branch and than create pull request into 'main' branch.

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2021 Codeplag Development Team
3+
Copyright (c) 2021-2025 Codeplag Development Team
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

Makefile

Lines changed: 46 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
1-
UTIL_VERSION := 0.5.15
1+
UTIL_VERSION := 0.5.16
22
UTIL_NAME := codeplag
33
PWD := $(shell pwd)
44

55
USER_UID ?= $(shell id --user)
66
USER_GID ?= $(shell id --group)
77

8-
BASE_DOCKER_VERSION := 1.1
9-
BASE_DOCKER_TAG := $(shell echo $(UTIL_NAME)-base-ubuntu22.04:$(BASE_DOCKER_VERSION) | tr A-Z a-z)
10-
TEST_DOCKER_TAG := $(shell echo $(UTIL_NAME)-test-ubuntu22.04:$(UTIL_VERSION) | tr A-Z a-z)
11-
DOCKER_TAG ?= $(shell echo $(UTIL_NAME)-ubuntu22.04:$(UTIL_VERSION) | tr A-Z a-z)
8+
BASE_DOCKER_VERSION := 1.2
9+
DIST := ubuntu22.04
10+
BASE_DOCKER_TAG := $(shell echo $(UTIL_NAME)-base-${DIST}:$(BASE_DOCKER_VERSION))
11+
TEST_DOCKER_TAG := $(shell echo $(UTIL_NAME)-test-${DIST}:$(UTIL_VERSION))
12+
DOCKER_TAG ?= $(shell echo $(UTIL_NAME)-${DIST}:$(UTIL_VERSION))
1213

1314
PYTHONDONTWRITEBYTECODE := "1"
1415
PYTHONPATH := $(PWD)/src/:$(PWD)/test/auto
@@ -17,16 +18,17 @@ LOGS_PATH := /var/log/$(UTIL_NAME)
1718
CODEPLAG_LOG_PATH := $(LOGS_PATH)/$(UTIL_NAME).log
1819
CONFIG_PATH := /etc/$(UTIL_NAME)/settings.conf
1920
LIB_PATH := /var/lib/$(UTIL_NAME)
20-
DEBIAN_PACKAGES_PATH := debian/deb
21+
DEBIAN_PATH := debian/
22+
DEBIAN_PACKAGES_PATH := ${DEBIAN_PATH}/deb
2123
PY_INSTALL_PATH := $(shell python3 -c "import site; print(site.getsitepackages()[0]);")
2224

2325
SOURCE_SUB_FILES := src/$(UTIL_NAME)/consts.py
2426
IS_DEVELOPED ?= 1
2527
ALL ?= 0
26-
DEBIAN_SUB_FILES := debian/changelog \
27-
debian/control \
28-
debian/preinst \
29-
debian/copyright
28+
DEBIAN_SUB_FILES := ${DEBIAN_PATH}/changelog \
29+
${DEBIAN_PATH}/control \
30+
${DEBIAN_PATH}/preinst \
31+
${DEBIAN_PATH}/copyright
3032
DOCKER_SUB_FILES := docker/base_ubuntu2204.dockerfile \
3133
docker/test_ubuntu2204.dockerfile \
3234
docker/ubuntu2204.dockerfile
@@ -40,7 +42,7 @@ ifeq ($(IS_DEVELOPED), 1)
4042
DEVEL_SUFFIX := .devel
4143
endif
4244

43-
DEB_PKG_NAME := ${UTIL_NAME}-util_${UTIL_VERSION}-1${DEVEL_SUFFIX}_amd64
45+
DEB_PKG_NAME := ${UTIL_NAME}-util_${UTIL_VERSION}-1${DEVEL_SUFFIX}.${DIST}_amd64
4446

4547

4648
substitute = @sed \
@@ -51,6 +53,7 @@ substitute = @sed \
5153
-e "s|@PYTHON_REQUIRED_LIBS@|${PYTHON_REQUIRED_LIBS}|g" \
5254
-e "s|@PYTHON_BUILD_LIBS@|${PYTHON_BUILD_LIBS}|g" \
5355
-e "s|@PYTHON_TEST_LIBS@|${PYTHON_TEST_LIBS}|g" \
56+
-e "s|@DIST@|${DIST}|g" \
5457
-e "s|@LOGS_PATH@|${LOGS_PATH}|g" \
5558
-e "s|@LIB_PATH@|${LIB_PATH}|g" \
5659
-e "s|@CONFIG_PATH@|${CONFIG_PATH}|g" \
@@ -78,24 +81,15 @@ substitute-debian: $(DEBIAN_SUB_FILES)
7881
substitute-docker: $(DOCKER_SUB_FILES)
7982
@echo "Substituted information about the utility in the docker files."
8083

81-
man: substitute-sources
82-
mkdir -p man
83-
argparse-manpage --pyfile src/$(UTIL_NAME)/$(UTIL_NAME)cli.py \
84-
--function CodeplagCLI \
85-
--author "Codeplag Development Team" \
86-
--project-name "$(UTIL_NAME) $(UTIL_VERSION)" \
87-
--url "https://github.com/OSLL/code-plagiarism" \
88-
--output man/$(UTIL_NAME).1
89-
9084
install: substitute-sources man translate-compile
91-
python3 -m pip install --root=/$(DESTDIR) .
85+
python3 -m pip install --root=$(DESTDIR)/ .
9286

93-
@echo "Cleaning unnecessary files after Cython compilation"
94-
find "$(DESTDIR)/$(PY_INSTALL_PATH)/$(UTIL_NAME)/" -type f -name '*.py' -exec rm --force {} +
95-
find "$(DESTDIR)/$(PY_INSTALL_PATH)/$(UTIL_NAME)" -type d -iname "__pycache__" -exec rm --recursive --force {} +
87+
@echo "Cleaning unnecessary files after Cython compilation in $(PY_INSTALL_PATH)"
88+
find "$(DESTDIR)/$(PY_INSTALL_PATH)/$(UTIL_NAME)/" -type f -name '*.py' -exec rm --force '{}' +
89+
find "$(DESTDIR)/$(PY_INSTALL_PATH)/$(UTIL_NAME)" -type d -iname "__pycache__" -exec rm --recursive --force '{}' +
9690

97-
@echo "Cleaning unnecessary temporary Python files after installation"
98-
find "$(DESTDIR)/$(PY_INSTALL_PATH)/$(UTIL_NAME)/" -type f -name '*.tmp.py' -exec rm --force {} +
91+
@echo "Cleaning unnecessary temporary Python files after installation in $(PY_INSTALL_PATH)"
92+
find "$(DESTDIR)/$(PY_INSTALL_PATH)/$(UTIL_NAME)/" -type f -name '*.tmp.py' -exec rm --force '{}' +
9993
rm --recursive --force "$(DESTDIR)/$(PY_INSTALL_PATH)/$(UTIL_NAME)/consts"
10094

10195
install -D -d -m 0755 $(DESTDIR)/$(LOGS_PATH)
@@ -106,7 +100,7 @@ install: substitute-sources man translate-compile
106100
install -D -m 0666 src/templates/sources.templ $(DESTDIR)/$(LIB_PATH)/sources.templ
107101

108102
cp --recursive locales/translations/ $(DESTDIR)/$(LIB_PATH)/
109-
find "$(DESTDIR)/$(LIB_PATH)/translations/" -type f -name '*.po' -exec rm --force {} +
103+
find "$(DESTDIR)/$(LIB_PATH)/translations/" -type f -name '*.po' -exec rm --force '{}' +
110104

111105
if [ ! -f $(DESTDIR)/$(CONFIG_PATH) ]; then \
112106
install -D -d -m 0755 $(DESTDIR)/etc/$(UTIL_NAME); \
@@ -116,6 +110,17 @@ install: substitute-sources man translate-compile
116110

117111
install -D -m 0644 man/$(UTIL_NAME).1 $(DESTDIR)/usr/share/man/man1/$(UTIL_NAME).1
118112

113+
man: substitute-sources
114+
mkdir -p man
115+
if [ ! -f man/$(UTIL_NAME).1 ]; then \
116+
argparse-manpage --pyfile src/$(UTIL_NAME)/$(UTIL_NAME)cli.py \
117+
--function CodeplagCLI \
118+
--author "Codeplag Development Team" \
119+
--project-name "$(UTIL_NAME) $(UTIL_VERSION)" \
120+
--url "https://github.com/OSLL/code-plagiarism" \
121+
--output man/$(UTIL_NAME).1; \
122+
fi
123+
119124
package: substitute-debian
120125
find $(DEBIAN_PACKAGES_PATH)/$(UTIL_NAME)* > /dev/null 2>&1 || ( \
121126
dpkg-buildpackage -jauto -b \
@@ -141,36 +146,36 @@ pre-commit:
141146

142147
clean-cache:
143148
find . -maxdepth 1 -type d | grep -E "pytest_cache" | (xargs rm -r 2> /dev/null || exit 0)
149+
find "src/$(UTIL_NAME)/" -type f -name '*.c' -exec rm --force '{}' +
144150
rm --recursive --force $(shell find -type d -iname "__pycache__")
145151

146152
clean: clean-cache
147153
rm --force --recursive man/
148154
rm --force --recursive build/
149155
rm --force --recursive dist/
150156
rm --force --recursive $(DEBIAN_PACKAGES_PATH)/*
151-
rm --force --recursive debian/.debhelper/
152-
rm --force --recursive debian/$(UTIL_NAME)-util/
153-
rm --force debian/debhelper-build-stamp
154-
rm --force debian/files
155-
rm --force debian/$(UTIL_NAME)-util.debhelper.log
156-
rm --force debian/$(UTIL_NAME)-util.substvars
157+
rm --force --recursive ${DEBIAN_PATH}/.debhelper/
158+
rm --force --recursive ${DEBIAN_PATH}/$(UTIL_NAME)-util/
159+
rm --force ${DEBIAN_PATH}/debhelper-build-stamp
160+
rm --force ${DEBIAN_PATH}/files
161+
rm --force ${DEBIAN_PATH}/$(UTIL_NAME)-util.debhelper.log
162+
rm --force ${DEBIAN_PATH}/$(UTIL_NAME)-util.substvars
157163
rm --force --recursive src/$(UTIL_NAME).egg-info
158164

159165
clean-all: clean
160166
rm --force src/$(UTIL_NAME)/consts.py
161167

162-
rm --force docker/base_ubuntu2204.dockerfile
163-
rm --force docker/test_ubuntu2204.dockerfile
164-
rm --force docker/ubuntu2204.dockerfile
168+
rm --force docker/*.dockerfile
165169

166170
rm --force --recursive $(DEBIAN_PACKAGES_PATH)
167-
rm --force debian/changelog
168-
rm --force debian/control
169-
rm --force debian/preinst
170-
rm --force debian/copyright
171+
rm --force ${DEBIAN_PATH}/changelog
172+
rm --force ${DEBIAN_PATH}/control
173+
rm --force ${DEBIAN_PATH}/preinst
174+
rm --force ${DEBIAN_PATH}/copyright
171175

172176
uninstall:
173-
rm --force /usr/share/man/man1/$(UTIL_NAME).1
177+
rm --force $(DESTDIR)/usr/share/man/man1/$(UTIL_NAME).1
178+
rm --force --recursive $(DESTDIR)/$(LIB_PATH)
174179
pip3 uninstall $(UTIL_NAME) -y
175180

176181
reinstall: uninstall install

README.md

Lines changed: 14 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,10 @@
11
# Code Plagiarism Analysis
22

3-
## 1. Install
4-
5-
### 1.1 Manual installation on the local system from sources
6-
7-
First of all, clone the repository and moved into this.
8-
9-
```
10-
sudo apt install git # if not installed
11-
git clone https://github.com/OSLL/code-plagiarism.git
12-
cd code-plagiarism/
13-
```
14-
15-
- OS Ubuntu Linux == 22.04
3+
Program for finding plagiarism in the source code written in Python 3, C, and C++ based on comparing AST metadata.
164

17-
- Python version == 3.10
18-
19-
- Run these commands:
20-
21-
```
22-
sudo apt update
23-
sudo apt install python3 python3-pip
24-
sudo apt install clang libncurses5
25-
26-
# Optional
27-
sudo apt install python3-venv
28-
pip3 install virtualenv
29-
python3 -m venv venv
30-
source venv/bin/activate
5+
## 1. Install
316

32-
pip3 install -U pip # pip3 version >= 19.0
33-
pip3 install argparse-manpage==3 requests==2.31.0
34-
pip3 install --upgrade setuptools # Ensure that an up-to-date version of setuptools is installed
35-
make
36-
```
37-
### 1.2 Build and run local Docker container
7+
### 1.1 Build and run local Docker container
388

399
- Create a code-plagiarism docker image
4010

@@ -60,7 +30,7 @@
6030
$ make help
6131
```
6232

63-
### 1.3 Pull the Docker Image from Docker Hub
33+
### 1.2 Pull the Docker Image from Docker Hub
6434

6535
- Pull an image from Docker Hub
6636
```
@@ -73,11 +43,18 @@
7343
$ docker run --rm --tty --interactive --volume <absolute_local_path_with_data>:/usr/src/works "artanias/codeplag-ubuntu22.04:latest" /bin/bash
7444
```
7545

76-
### 1.4 Install with package manager apt-get
46+
### 1.3 Install with package manager apt-get
47+
48+
- Requirements:
49+
- OS Ubuntu Linux == 22.04
50+
- Python version == 3.10
7751

7852
- For this purpose, you need to get installing package from releases [tab](https://github.com/OSLL/code-plagiarism/releases) with extension .deb;
79-
- The next step is run command on the target system:
53+
- The next step is run commands on the target system:
8054
```
55+
$ sudo apt update
56+
$ sudo apt install python3 python3-pip
57+
$ sudo apt install clang libncurses5
8158
$ sudo apt-get install <path_to_the_package>/<package_name>.deb
8259
```
8360

@@ -91,6 +68,7 @@
9168
$ python3 -m pip install --requirement docs/notebooks/requirements.txt
9269
$ python3 -m pip install $(python3 -m setup.py --build-requirements)
9370
$ python3 -m pip install $(python3 -m setup.py --install-requirements)
71+
$ python3 -m pip install pre-commit==4.1.0
9472
$ make pre-commit
9573
```
9674

debian/changelog.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
@UTIL_NAME@-util (@UTIL_VERSION@-1@DEVEL_SUFFIX@) stable; urgency=medium
1+
@UTIL_NAME@-util (@UTIL_VERSION@-1@DEVEL_SUFFIX@.@DIST@) stable; urgency=medium

docker/base_ubuntu2204.dockerfile.in

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,12 @@ RUN if [ "$(dpkg-divert --truename /usr/bin/man)" = "/usr/bin/man.REAL" ]; then
77
fi
88
RUN apt-get update
99
RUN apt-get install -y python3-pip
10+
RUN pip3 install --upgrade setuptools
1011
RUN apt-get install -y clang libncurses5
1112
RUN apt-get install -y man
1213
RUN apt-get install -y vim nano less
13-
RUN pip3 install --upgrade setuptools
1414

1515
RUN pip3 install @PYTHON_REQUIRED_LIBS@
16-
RUN register-python-argcomplete @UTIL_NAME@ >> ~/.bashrc
1716

1817
VOLUME /usr/src/works
1918
WORKDIR /usr/src/@UTIL_NAME@

docker/ubuntu2204.dockerfile.in

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ FROM @BASE_DOCKER_TAG@
22

33
# TODO: Move to middle docker file or make another solution
44
ADD setup.py /usr/src/@UTIL_NAME@/setup.py
5+
ADD pyproject.toml /usr/src/@UTIL_NAME@/pyproject.toml
56
ADD src/ /usr/src/@UTIL_NAME@/src
67
ADD README.md /usr/src/@UTIL_NAME@/README.md
78
ADD LICENSE /usr/src/@UTIL_NAME@/LICENSE
@@ -15,4 +16,6 @@ RUN apt-get install -y /usr/src/@UTIL_NAME@/@DEBIAN_PACKAGES_PATH@/@DEB_PKG_NAME
1516
RUN install -D -m 0644 @DEBIAN_PACKAGES_PATH@/@[email protected] /usr/share/man/man1/
1617
RUN rm --recursive /usr/src/@UTIL_NAME@/debian
1718

19+
RUN register-python-argcomplete @UTIL_NAME@ >> ~/.bashrc
20+
1821
CMD ["/bin/bash"]

pyproject.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
[project]
2-
requires-python = ">=3.10"
2+
description = "Code plagiarism searching package."
3+
readme = "README.md"
4+
requires-python = "~=3.10"
35

46
[tool.ruff]
57
builtins = ["_"]

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
setup(
6161
name=f"{UTIL_NAME}",
6262
version=f"{UTIL_VERSION}",
63-
description="Code plagiarism searching package",
63+
description="Code plagiarism searching package.",
6464
author="Artyom Semidolin, Dmitry Nikolaev, Alexander Evsikov",
6565
url="https://github.com/OSLL/code-plagiarism",
6666
long_description=Path("README.md").read_text(encoding="utf-8"),

test/auto/test_sources.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88

99

1010
def test_no_py_files():
11-
# checks
1211
for path in PACKAGE_PATH.glob("**/*"):
1312
if path.is_dir():
1413
continue

0 commit comments

Comments
 (0)