Skip to content
Merged
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
16 changes: 8 additions & 8 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,17 @@ Note that all of the unit tests names should starts with prefix 'test_'.

## Branches rules

1) The 'main' branch consists sources of the last work and tested version of the util, correct documentation, some helpfull scripts and research notebooks;
2) The 'develop' branch consist source of the current developing version;
1) The 'main' branch consists sources of the last work and tested version of the util, correct documentation, some helpfull scripts and research notebooks.
2) The 'develop' branch consist source of the current developing version.
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.

## Making pull requests

Sequence for submitting PR:

1) Fork this repo (for external contributors) or clone (for internal contributors);
2) Make branch off of 'develop' branch;
3) Add descriptive unit tests;
4) If desire, you may to add auto tests. When adding error fixes it's required;
5) After making commits check that all pre-commit hooks is passed;
6) Push commits into your remote branch and than create pull request.
1) Fork this repo (for external contributors) or clone (for internal contributors).
2) Make branch off of 'main' branch.
3) Add descriptive unit tests if you affect the source code.
4) If desire, you may to add auto tests. When adding error fixes it's required.
5) After making commits check that all pre-commit hooks is passed.
6) Push commits into your remote branch and than create pull request into 'main' branch.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2021 Codeplag Development Team
Copyright (c) 2021-2025 Codeplag Development Team

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
87 changes: 46 additions & 41 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
UTIL_VERSION := 0.5.15
UTIL_VERSION := 0.5.16
UTIL_NAME := codeplag
PWD := $(shell pwd)

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

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

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

SOURCE_SUB_FILES := src/$(UTIL_NAME)/consts.py
IS_DEVELOPED ?= 1
ALL ?= 0
DEBIAN_SUB_FILES := debian/changelog \
debian/control \
debian/preinst \
debian/copyright
DEBIAN_SUB_FILES := ${DEBIAN_PATH}/changelog \
${DEBIAN_PATH}/control \
${DEBIAN_PATH}/preinst \
${DEBIAN_PATH}/copyright
DOCKER_SUB_FILES := docker/base_ubuntu2204.dockerfile \
docker/test_ubuntu2204.dockerfile \
docker/ubuntu2204.dockerfile
Expand All @@ -40,7 +42,7 @@ ifeq ($(IS_DEVELOPED), 1)
DEVEL_SUFFIX := .devel
endif

DEB_PKG_NAME := ${UTIL_NAME}-util_${UTIL_VERSION}-1${DEVEL_SUFFIX}_amd64
DEB_PKG_NAME := ${UTIL_NAME}-util_${UTIL_VERSION}-1${DEVEL_SUFFIX}.${DIST}_amd64


substitute = @sed \
Expand All @@ -51,6 +53,7 @@ substitute = @sed \
-e "s|@PYTHON_REQUIRED_LIBS@|${PYTHON_REQUIRED_LIBS}|g" \
-e "s|@PYTHON_BUILD_LIBS@|${PYTHON_BUILD_LIBS}|g" \
-e "s|@PYTHON_TEST_LIBS@|${PYTHON_TEST_LIBS}|g" \
-e "s|@DIST@|${DIST}|g" \
-e "s|@LOGS_PATH@|${LOGS_PATH}|g" \
-e "s|@LIB_PATH@|${LIB_PATH}|g" \
-e "s|@CONFIG_PATH@|${CONFIG_PATH}|g" \
Expand Down Expand Up @@ -78,24 +81,15 @@ substitute-debian: $(DEBIAN_SUB_FILES)
substitute-docker: $(DOCKER_SUB_FILES)
@echo "Substituted information about the utility in the docker files."

man: substitute-sources
mkdir -p man
argparse-manpage --pyfile src/$(UTIL_NAME)/$(UTIL_NAME)cli.py \
--function CodeplagCLI \
--author "Codeplag Development Team" \
--project-name "$(UTIL_NAME) $(UTIL_VERSION)" \
--url "https://github.com/OSLL/code-plagiarism" \
--output man/$(UTIL_NAME).1

install: substitute-sources man translate-compile
python3 -m pip install --root=/$(DESTDIR) .
python3 -m pip install --root=$(DESTDIR)/ .

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

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

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

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

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

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

man: substitute-sources
mkdir -p man
if [ ! -f man/$(UTIL_NAME).1 ]; then \
argparse-manpage --pyfile src/$(UTIL_NAME)/$(UTIL_NAME)cli.py \
--function CodeplagCLI \
--author "Codeplag Development Team" \
--project-name "$(UTIL_NAME) $(UTIL_VERSION)" \
--url "https://github.com/OSLL/code-plagiarism" \
--output man/$(UTIL_NAME).1; \
fi

package: substitute-debian
find $(DEBIAN_PACKAGES_PATH)/$(UTIL_NAME)* > /dev/null 2>&1 || ( \
dpkg-buildpackage -jauto -b \
Expand All @@ -141,36 +146,36 @@ pre-commit:

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

clean: clean-cache
rm --force --recursive man/
rm --force --recursive build/
rm --force --recursive dist/
rm --force --recursive $(DEBIAN_PACKAGES_PATH)/*
rm --force --recursive debian/.debhelper/
rm --force --recursive debian/$(UTIL_NAME)-util/
rm --force debian/debhelper-build-stamp
rm --force debian/files
rm --force debian/$(UTIL_NAME)-util.debhelper.log
rm --force debian/$(UTIL_NAME)-util.substvars
rm --force --recursive ${DEBIAN_PATH}/.debhelper/
rm --force --recursive ${DEBIAN_PATH}/$(UTIL_NAME)-util/
rm --force ${DEBIAN_PATH}/debhelper-build-stamp
rm --force ${DEBIAN_PATH}/files
rm --force ${DEBIAN_PATH}/$(UTIL_NAME)-util.debhelper.log
rm --force ${DEBIAN_PATH}/$(UTIL_NAME)-util.substvars
rm --force --recursive src/$(UTIL_NAME).egg-info

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

rm --force docker/base_ubuntu2204.dockerfile
rm --force docker/test_ubuntu2204.dockerfile
rm --force docker/ubuntu2204.dockerfile
rm --force docker/*.dockerfile

rm --force --recursive $(DEBIAN_PACKAGES_PATH)
rm --force debian/changelog
rm --force debian/control
rm --force debian/preinst
rm --force debian/copyright
rm --force ${DEBIAN_PATH}/changelog
rm --force ${DEBIAN_PATH}/control
rm --force ${DEBIAN_PATH}/preinst
rm --force ${DEBIAN_PATH}/copyright

uninstall:
rm --force /usr/share/man/man1/$(UTIL_NAME).1
rm --force $(DESTDIR)/usr/share/man/man1/$(UTIL_NAME).1
rm --force --recursive $(DESTDIR)/$(LIB_PATH)
pip3 uninstall $(UTIL_NAME) -y

reinstall: uninstall install
Expand Down
50 changes: 14 additions & 36 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,40 +1,10 @@
# Code Plagiarism Analysis

## 1. Install

### 1.1 Manual installation on the local system from sources

First of all, clone the repository and moved into this.

```
sudo apt install git # if not installed
git clone https://github.com/OSLL/code-plagiarism.git
cd code-plagiarism/
```

- OS Ubuntu Linux == 22.04
Program for finding plagiarism in the source code written in Python 3, C, and C++ based on comparing AST metadata.

- Python version == 3.10

- Run these commands:

```
sudo apt update
sudo apt install python3 python3-pip
sudo apt install clang libncurses5

# Optional
sudo apt install python3-venv
pip3 install virtualenv
python3 -m venv venv
source venv/bin/activate
## 1. Install

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

- Create a code-plagiarism docker image

Expand All @@ -60,7 +30,7 @@
$ make help
```

### 1.3 Pull the Docker Image from Docker Hub
### 1.2 Pull the Docker Image from Docker Hub

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

### 1.4 Install with package manager apt-get
### 1.3 Install with package manager apt-get

- Requirements:
- OS Ubuntu Linux == 22.04
- Python version == 3.10

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

Expand All @@ -91,6 +68,7 @@
$ python3 -m pip install --requirement docs/notebooks/requirements.txt
$ python3 -m pip install $(python3 -m setup.py --build-requirements)
$ python3 -m pip install $(python3 -m setup.py --install-requirements)
$ python3 -m pip install pre-commit==4.1.0
$ make pre-commit
```

Expand Down
2 changes: 1 addition & 1 deletion debian/changelog.in
Original file line number Diff line number Diff line change
@@ -1 +1 @@
@UTIL_NAME@-util (@UTIL_VERSION@-1@DEVEL_SUFFIX@) stable; urgency=medium
@UTIL_NAME@-util (@UTIL_VERSION@-1@DEVEL_SUFFIX@.@DIST@) stable; urgency=medium
3 changes: 1 addition & 2 deletions docker/base_ubuntu2204.dockerfile.in
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,12 @@ RUN if [ "$(dpkg-divert --truename /usr/bin/man)" = "/usr/bin/man.REAL" ]; then
fi
RUN apt-get update
RUN apt-get install -y python3-pip
RUN pip3 install --upgrade setuptools
RUN apt-get install -y clang libncurses5
RUN apt-get install -y man
RUN apt-get install -y vim nano less
RUN pip3 install --upgrade setuptools

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

VOLUME /usr/src/works
WORKDIR /usr/src/@UTIL_NAME@
3 changes: 3 additions & 0 deletions docker/ubuntu2204.dockerfile.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ FROM @BASE_DOCKER_TAG@

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

RUN register-python-argcomplete @UTIL_NAME@ >> ~/.bashrc

CMD ["/bin/bash"]
4 changes: 3 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
[project]
requires-python = ">=3.10"
description = "Code plagiarism searching package."
readme = "README.md"
requires-python = "~=3.10"

[tool.ruff]
builtins = ["_"]
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
setup(
name=f"{UTIL_NAME}",
version=f"{UTIL_VERSION}",
description="Code plagiarism searching package",
description="Code plagiarism searching package.",
author="Artyom Semidolin, Dmitry Nikolaev, Alexander Evsikov",
url="https://github.com/OSLL/code-plagiarism",
long_description=Path("README.md").read_text(encoding="utf-8"),
Expand Down
1 change: 0 additions & 1 deletion test/auto/test_sources.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@


def test_no_py_files():
# checks
for path in PACKAGE_PATH.glob("**/*"):
if path.is_dir():
continue
Expand Down
Loading