diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 46517ecb..ff073617 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -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. diff --git a/LICENSE b/LICENSE index f32291a4..2b8db5a2 100644 --- a/LICENSE +++ b/LICENSE @@ -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 diff --git a/Makefile b/Makefile index ba147a1e..312048aa 100644 --- a/Makefile +++ b/Makefile @@ -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 @@ -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 @@ -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 \ @@ -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" \ @@ -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) @@ -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); \ @@ -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 \ @@ -141,6 +146,7 @@ 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 @@ -148,29 +154,28 @@ clean: clean-cache 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 diff --git a/README.md b/README.md index 703655e4..80a74afe 100644 --- a/README.md +++ b/README.md @@ -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 @@ -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 ``` @@ -73,11 +43,18 @@ $ docker run --rm --tty --interactive --volume :/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 /.deb ``` @@ -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 ``` diff --git a/debian/changelog.in b/debian/changelog.in index 847ef807..7362886a 100644 --- a/debian/changelog.in +++ b/debian/changelog.in @@ -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 diff --git a/docker/base_ubuntu2204.dockerfile.in b/docker/base_ubuntu2204.dockerfile.in index 5d9a873b..29900702 100644 --- a/docker/base_ubuntu2204.dockerfile.in +++ b/docker/base_ubuntu2204.dockerfile.in @@ -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@ diff --git a/docker/ubuntu2204.dockerfile.in b/docker/ubuntu2204.dockerfile.in index 9ab8cf54..eab87a1b 100644 --- a/docker/ubuntu2204.dockerfile.in +++ b/docker/ubuntu2204.dockerfile.in @@ -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 @@ -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@/@UTIL_NAME@.1 /usr/share/man/man1/ RUN rm --recursive /usr/src/@UTIL_NAME@/debian +RUN register-python-argcomplete @UTIL_NAME@ >> ~/.bashrc + CMD ["/bin/bash"] diff --git a/pyproject.toml b/pyproject.toml index 53f5f81c..92ff2972 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,5 +1,7 @@ [project] -requires-python = ">=3.10" +description = "Code plagiarism searching package." +readme = "README.md" +requires-python = "~=3.10" [tool.ruff] builtins = ["_"] diff --git a/setup.py b/setup.py index eef2bf51..f1615211 100644 --- a/setup.py +++ b/setup.py @@ -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"), diff --git a/test/auto/test_sources.py b/test/auto/test_sources.py index 02df93d3..16378489 100644 --- a/test/auto/test_sources.py +++ b/test/auto/test_sources.py @@ -8,7 +8,6 @@ def test_no_py_files(): - # checks for path in PACKAGE_PATH.glob("**/*"): if path.is_dir(): continue