From e6947529af558bce12fa01a905064a5cc88ecdba Mon Sep 17 00:00:00 2001 From: Joachim Metz Date: Thu, 27 Nov 2025 05:39:20 +0100 Subject: [PATCH 1/2] Changes to dependency writers --- .github/workflows/test_docker.yml | 2 +- MANIFEST.in | 6 +- README => README.md | 0 appveyor.yml | 24 +-- config/docker/build_dpkg.sh | 34 ++-- config/docker/build_rpm.sh | 33 +++- config/docker/l2tbuilds_fedora.Dockerfile | 13 +- config/docker/l2tbuilds_ubuntu.Dockerfile | 19 +- data/dpkg_templates/mans-to-es-rules | 17 -- data/pyinstaller/make_release.ps1 | 2 +- data/rpm_templates/artifacts.spec | 4 +- data/rpm_templates/plaso.spec | 4 +- data/templates/check_dependencies-with_url.py | 2 +- data/templates/check_dependencies.py | 2 +- data/templates/github_actions/test_docker.yml | 2 +- data/templates/pyproject.toml | 10 -- data/templates/setup.cfg/metadata | 25 --- data/templates/setup.cfg/options_entry_points | 4 - data/templates/setup.cfg/options_package_data | 4 - .../templates/setup.cfg/options_packages_find | 8 - data/templates/setup.cfg/options_scripts | 2 - data/templates/setup.py | 8 - data/templates/tox.ini/header | 9 - data/templates/tox.ini/testenv_lint | 7 +- data/templates/tox.ini/testenv_lint-with_yaml | 7 +- l2tdevtools/dependencies.py | 5 +- .../dependency_writers/check_dependencies.py | 6 - .../dependency_writers/requirements.py | 43 ----- l2tdevtools/dependency_writers/setup.py | 166 +++++++----------- l2tdevtools/dependency_writers/tox_ini.py | 9 +- l2tdevtools/projects.py | 2 +- l2tdevtools/review_helpers/git.py | 5 +- l2tdevtools/spec_file.py | 4 +- pyproject.toml | 30 +++- requirements.txt | 0 run_tests.py | 2 +- setup.cfg | 43 ----- setup.py | 8 - tests/build_helpers/dpkg.py | 2 +- tests/build_helpers/factory.py | 2 +- tests/build_helpers/interface.py | 2 +- tests/build_helpers/rpm.py | 2 +- tests/build_helpers/source.py | 2 +- tests/build_helpers/wheel.py | 2 +- tests/dependencies.py | 2 +- tests/dependency_writers/appveyor_yml.py | 2 +- tests/dependency_writers/dependencies_py.py | 2 +- tests/dependency_writers/dpkg.py | 2 +- tests/dependency_writers/gift_copr.py | 2 +- tests/dependency_writers/gift_ppa.py | 2 +- tests/dependency_writers/interface.py | 2 +- tests/dependency_writers/jenkins_scripts.py | 2 +- tests/dependency_writers/linux_scripts.py | 2 +- tests/dependency_writers/pylint_rc.py | 2 +- tests/dependency_writers/requirements.py | 67 ------- tests/dependency_writers/setup.py | 30 +--- tests/dependency_writers/sphinx_docs.py | 2 +- tests/dependency_writers/tox_ini.py | 2 +- tests/download_helper.py | 2 +- tests/download_helpers/github.py | 2 +- tests/download_helpers/interface.py | 2 +- tests/download_helpers/pypi.py | 2 +- tests/download_helpers/sourceforge.py | 2 +- tests/dpkg_files.py | 2 +- tests/helpers/project.py | 2 +- tests/presets.py | 2 +- tests/projects.py | 2 +- tests/review_helpers/cli.py | 2 +- tests/review_helpers/git.py | 2 +- tests/review_helpers/github.py | 2 +- tests/review_helpers/pylint.py | 2 +- tests/review_helpers/review.py | 2 +- tests/schema_extractor.py | 2 +- tests/source_helper.py | 2 +- tests/spec_file.py | 2 +- tests/update.py | 2 +- tools/build.py | 2 +- tools/develop.py | 2 +- tools/dpkg-generate.py | 2 +- tools/manage.py | 2 +- tools/review.py | 2 +- tools/schema_extractor.py | 2 +- tools/stats.py | 2 +- tools/update-dependencies.py | 7 +- tools/update.py | 2 +- tox.ini | 20 +-- 86 files changed, 245 insertions(+), 538 deletions(-) rename README => README.md (100%) delete mode 100755 data/dpkg_templates/mans-to-es-rules delete mode 100644 data/templates/pyproject.toml delete mode 100644 data/templates/setup.cfg/metadata delete mode 100644 data/templates/setup.cfg/options_entry_points delete mode 100644 data/templates/setup.cfg/options_package_data delete mode 100644 data/templates/setup.cfg/options_packages_find delete mode 100644 data/templates/setup.cfg/options_scripts delete mode 100755 data/templates/setup.py delete mode 100644 l2tdevtools/dependency_writers/requirements.py delete mode 100644 requirements.txt delete mode 100644 setup.cfg delete mode 100755 setup.py delete mode 100644 tests/dependency_writers/requirements.py diff --git a/.github/workflows/test_docker.yml b/.github/workflows/test_docker.yml index 92e16b9d..d8aac799 100644 --- a/.github/workflows/test_docker.yml +++ b/.github/workflows/test_docker.yml @@ -37,7 +37,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - version: ['24.04'] + version: ['26.04'] container: image: ubuntu:${{ matrix.version }} steps: diff --git a/MANIFEST.in b/MANIFEST.in index c16fc6db..3f89fe27 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,6 +1,5 @@ -include ACKNOWLEDGEMENTS AUTHORS LICENSE README +include ACKNOWLEDGEMENTS AUTHORS LICENSE README.md include dependencies.ini run_tests.py -include requirements.txt test_requirements.txt exclude .gitignore exclude *.pyc recursive-include config * @@ -10,6 +9,5 @@ recursive-include tools *.py recursive-exclude tools *.pyc recursive-include test_data * # The test scripts are not required in a binary distribution package they -# are considered source distribution files and excluded in find_package() -# in setup.py. +# are considered source distribution files and excluded by find_package(). recursive-include tests *.py diff --git a/README b/README.md similarity index 100% rename from README rename to README.md diff --git a/appveyor.yml b/appveyor.yml index b8883ac0..fbd737db 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,31 +1,31 @@ environment: matrix: - - DESCRIPTION: "Run tests on Windows with 32-bit Python 3.12" + - DESCRIPTION: "Run tests on Windows with 32-bit Python 3.14" MACHINE_TYPE: "x86" APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2022 - PYTHON: "C:\\Python312" - PYTHON_VERSION: "3.12" + PYTHON: "C:\\Python314" + PYTHON_VERSION: "3.14" L2TBINARIES_TRACK: "dev" TARGET: tests - - DESCRIPTION: "Run tests on Windows with 64-bit Python 3.12" + - DESCRIPTION: "Run tests on Windows with 64-bit Python 3.14" MACHINE_TYPE: "amd64" APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2022 - PYTHON: "C:\\Python312-x64" - PYTHON_VERSION: "3.12" + PYTHON: "C:\\Python314-x64" + PYTHON_VERSION: "3.14" L2TBINARIES_TRACK: "dev" TARGET: tests - - DESCRIPTION: "Build wheel on Windows with 32-bit Python 3.12" + - DESCRIPTION: "Build wheel on Windows with 32-bit Python 3.14" MACHINE_TYPE: "amd64" APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2022 - PYTHON: "C:\\Python312-x64" - PYTHON_VERSION: "3.12" + PYTHON: "C:\\Python314-x64" + PYTHON_VERSION: "3.14" L2TBINARIES_TRACK: "dev" TARGET: wheel - - DESCRIPTION: "Build wheel on Windows with 64-bit Python 3.12" + - DESCRIPTION: "Build wheel on Windows with 64-bit Python 3.14" MACHINE_TYPE: "amd64" APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2022 - PYTHON: "C:\\Python312-x64" - PYTHON_VERSION: "3.12" + PYTHON: "C:\\Python314-x64" + PYTHON_VERSION: "3.14" L2TBINARIES_TRACK: "dev" TARGET: wheel - DESCRIPTION: "Run tests on Mac OS with Python 3.14" diff --git a/config/docker/build_dpkg.sh b/config/docker/build_dpkg.sh index b6ab4431..5ff171d2 100755 --- a/config/docker/build_dpkg.sh +++ b/config/docker/build_dpkg.sh @@ -5,24 +5,36 @@ # Fail on error. set -e -GID=$(id -g); +GID=$(id -g) -L2TBUILDS_DIRECTORY="${HOME}/Projects/l2tbuilds"; -GNUPG_DIRECTORY="${HOME}/Projects/l2tbuilds-gnupg"; +L2TBUILDS_DIRECTORY="${HOME}/Projects/l2tbuilds" +GNUPG_DIRECTORY="${HOME}/Projects/l2tbuilds-gnupg" -cd config/docker; +cd config/docker -mkdir -p "${L2TBUILDS_DIRECTORY}/dpkg"; -mkdir -p "${L2TBUILDS_DIRECTORY}/dpkg-source"; +mkdir -p "${L2TBUILDS_DIRECTORY}/dpkg" +mkdir -p "${L2TBUILDS_DIRECTORY}/dpkg-source" # Build the l2tbuilds Ubuntu Docker image. -docker build -f l2tbuilds_ubuntu.Dockerfile --force-rm --no-cache -t log2timeline/l2tbuilds_ubuntu . ; +docker build \ + -f l2tbuilds_ubuntu.Dockerfile \ + --force-rm \ + --no-cache \ + -t log2timeline/l2tbuilds_ubuntu . -if test -d "${GNUPG_DIRECTORY}"; +if test -d "${GNUPG_DIRECTORY}" then # Run the container in interactive mode ("run -it") to use gpg-agent to sign the builds - docker run -it -u ${UID}:${GID} -v "${GNUPG_DIRECTORY}:/home/ubuntu/.gnupg:z" -v "${L2TBUILDS_DIRECTORY}:/home/ubuntu/l2tbuilds:z" log2timeline/l2tbuilds_ubuntu + docker run \ + -it \ + -u ${UID}:${GID} \ + -v "${GNUPG_DIRECTORY}:/home/ubuntu/.gnupg:z" \ + -v "${L2TBUILDS_DIRECTORY}:/home/ubuntu/l2tbuilds:z" \ + log2timeline/l2tbuilds_ubuntu else - docker run -u ${UID}:${GID} -v "${L2TBUILDS_DIRECTORY}:/home/ubuntu/l2tbuilds:z" log2timeline/l2tbuilds_ubuntu /bin/bash -c "(cd l2tdevtools && ./utils/build_dpkg.sh --preset plaso)" + docker run \ + -u ${UID}:${GID} \ + -v "${L2TBUILDS_DIRECTORY}:/home/ubuntu/l2tbuilds:z" \ + log2timeline/l2tbuilds_ubuntu \ + /bin/bash -c "(cd l2tdevtools && ./utils/build_dpkg.sh --preset plaso)" fi - diff --git a/config/docker/build_rpm.sh b/config/docker/build_rpm.sh index e94fc8c6..a92cac73 100755 --- a/config/docker/build_rpm.sh +++ b/config/docker/build_rpm.sh @@ -5,17 +5,34 @@ # Fail on error. set -e -GID=$(id -g); +GID=$(id -g) -L2TBUILDS_DIRECTORY="${HOME}/Projects/l2tbuilds"; +L2TBUILDS_DIRECTORY="${HOME}/Projects/l2tbuilds" -cd config/docker; +cd config/docker -mkdir -p "${L2TBUILDS_DIRECTORY}/rpm"; -mkdir -p "${L2TBUILDS_DIRECTORY}/srpm"; +mkdir -p "${L2TBUILDS_DIRECTORY}/rpm" +mkdir -p "${L2TBUILDS_DIRECTORY}/srpm" # Build the l2tbuilds Fedora Docker image. -docker build -f l2tbuilds_fedora.Dockerfile --force-rm --no-cache -t log2timeline/l2tbuilds_fedora . ; -docker run -it -u ${UID}:${GID} -v "${L2TBUILDS_DIRECTORY}:/home/build/l2tbuilds:z" log2timeline/l2tbuilds_fedora /bin/bash +docker build \ + --build-arg GID=${GID} \ + --build-arg UID=${UID} \ + -f l2tbuilds_fedora.Dockerfile \ + --force-rm \ + --no-cache \ + -t log2timeline/l2tbuilds_fedora \ + . -# docker run -u ${UID}:${GID} -v "${L2TBUILDS_DIRECTORY}:/home/build/l2tbuilds:z" log2timeline/l2tbuilds_fedora /bin/bash -c "(cd l2tdevtools && ./utils/build_dpkg.sh --preset plaso)" +docker run \ + -it \ + -u ${UID}:${GID} \ + -v "${L2TBUILDS_DIRECTORY}:/home/build/l2tbuilds:z" \ + log2timeline/l2tbuilds_fedora \ + /bin/bash + +# docker run \ +# -u ${UID}:${GID} +# -v "${L2TBUILDS_DIRECTORY}:/home/build/l2tbuilds:z" +# log2timeline/l2tbuilds_fedora +# /bin/bash -c "(cd l2tdevtools && ./utils/build_rpm.sh --preset plaso)" diff --git a/config/docker/l2tbuilds_fedora.Dockerfile b/config/docker/l2tbuilds_fedora.Dockerfile index f575c706..f515b2e6 100644 --- a/config/docker/l2tbuilds_fedora.Dockerfile +++ b/config/docker/l2tbuilds_fedora.Dockerfile @@ -1,8 +1,11 @@ -FROM fedora:42 +FROM fedora:43 # Create container with: # docker build -f l2tbuilds_fedora.Dockerfile --force-rm --no-cache -t log2timeline/l2tbuilds_fedora . +ARG UID=1000 +ARG GID=1000 + RUN dnf install -y \ @development-tools \ autoconf \ @@ -22,6 +25,12 @@ RUN dnf install -y \ python3-setuptools \ python3-wheel +RUN groupadd --gid ${GID} build && \ + useradd --create-home --gid ${GID} --shell /bin/bash --uid ${UID} build + # Set up the l2tdevtools source and build directories -WORKDIR /home/build/ +WORKDIR /home/build + +USER build + RUN git clone https://github.com/log2timeline/l2tdevtools.git diff --git a/config/docker/l2tbuilds_ubuntu.Dockerfile b/config/docker/l2tbuilds_ubuntu.Dockerfile index 0df72d62..92970b08 100644 --- a/config/docker/l2tbuilds_ubuntu.Dockerfile +++ b/config/docker/l2tbuilds_ubuntu.Dockerfile @@ -11,6 +11,9 @@ RUN apt-get -y update && \ apt-get -y install apt-transport-https apt-utils && \ apt-get -y install libterm-readline-gnu-perl software-properties-common && \ apt-get -y upgrade && \ + apt-get -y install \ + locales \ + pinentry-tty && \ apt-get -y install --no-install-recommends \ autoconf \ automake \ @@ -38,9 +41,7 @@ RUN apt-get -y update && \ libssl-dev \ libtool \ libyaml-dev \ - locales \ pkg-config \ - pinentry-tty \ pybuild-plugin-pyproject \ python3-all \ python3-all-dev \ @@ -63,16 +64,16 @@ RUN apt-get -y update && \ tox-current-env && \ apt-get clean && rm -rf /var/cache/apt/* /var/lib/apt/lists/* -# Set terminal to UTF-8 by default -RUN locale-gen en_US.UTF-8 -RUN update-locale LANG=en_US.UTF-8 LC_ALL=en_US.UTF-8 +# Set terminal to UTF-8 by default and changes pinentry to use TTY +RUN locale-gen en_US.UTF-8 && \ + update-locale LANG=en_US.UTF-8 LC_ALL=en_US.UTF-8 && \ + update-alternatives --set pinentry /usr/bin/pinentry-tty ENV LANG=en_US.UTF-8 ENV LC_ALL=en_US.UTF-8 -# Changes pinentry to use TTY -RUN update-alternatives --set pinentry /usr/bin/pinentry-tty - # Set up the l2tdevtools source and build directories -USER ubuntu WORKDIR /home/ubuntu + +USER ubuntu + RUN git clone https://github.com/log2timeline/l2tdevtools.git diff --git a/data/dpkg_templates/mans-to-es-rules b/data/dpkg_templates/mans-to-es-rules deleted file mode 100755 index 3b9dcd28..00000000 --- a/data/dpkg_templates/mans-to-es-rules +++ /dev/null @@ -1,17 +0,0 @@ -#!/usr/bin/make -f - -%: - dh $@ --buildsystem=pybuild --with=python3 - -.PHONY: override_dh_auto_test -override_dh_auto_test: - -.PHONY: override_dh_auto_clean -override_dh_auto_clean: - touch requirements.txt - dh_auto_clean - -.PHONY: override_dh_auto_install -override_dh_auto_install: - touch requirements.txt - dh_auto_install diff --git a/data/pyinstaller/make_release.ps1 b/data/pyinstaller/make_release.ps1 index 06f2d516..a170f7f1 100644 --- a/data/pyinstaller/make_release.ps1 +++ b/data/pyinstaller/make_release.ps1 @@ -191,7 +191,7 @@ New-Item -ItemType "directory" -Path "${DistPath}\licenses" Copy-Item -Force ACKNOWLEDGEMENTS "${DistPath}" Copy-Item -Force AUTHORS "${DistPath}" Copy-Item -Force LICENSE "${DistPath}" -Copy-Item -Force README "${DistPath}" +Copy-Item -Force README.md "${DistPath}" Copy-Item -Force -Recurse "dist\image_export\*" "${DistPath}" Copy-Item -Force -Recurse "dist\log2timeline\*" "${DistPath}" diff --git a/data/rpm_templates/artifacts.spec b/data/rpm_templates/artifacts.spec index 66199627..3e43307c 100644 --- a/data/rpm_templates/artifacts.spec +++ b/data/rpm_templates/artifacts.spec @@ -62,12 +62,12 @@ rm -rf %{{buildroot}} %files -n %{{name}}-data %license LICENSE -%doc ACKNOWLEDGEMENTS AUTHORS README +%doc ACKNOWLEDGEMENTS AUTHORS README.md %{{_datadir}}/%{{name}}/* %files -n python3-%{{name}} %license LICENSE -%doc README +%doc README.md %{{python3_sitelib}}/artifacts %{{python3_sitelib}}/artifacts*.egg-info diff --git a/data/rpm_templates/plaso.spec b/data/rpm_templates/plaso.spec index ad27ee08..7a865b40 100644 --- a/data/rpm_templates/plaso.spec +++ b/data/rpm_templates/plaso.spec @@ -62,12 +62,12 @@ rm -rf %{{buildroot}} %files -n %{{name}}-data %license LICENSE -%doc ACKNOWLEDGEMENTS AUTHORS README +%doc ACKNOWLEDGEMENTS AUTHORS README.md %{{_datadir}}/%{{name}}/* %files -n python3-%{{name}} %license LICENSE -%doc README +%doc README.md %{{python3_sitelib}}/plaso %{{python3_sitelib}}/plaso*.egg-info diff --git a/data/templates/check_dependencies-with_url.py b/data/templates/check_dependencies-with_url.py index 08a4d33a..c890a09f 100755 --- a/data/templates/check_dependencies-with_url.py +++ b/data/templates/check_dependencies-with_url.py @@ -1,4 +1,4 @@ -${shebang} +#!/usr/bin/env python3 # -*- coding: utf-8 -*- """Script to check for the availability and version of dependencies.""" diff --git a/data/templates/check_dependencies.py b/data/templates/check_dependencies.py index f46a8e11..73c1ba41 100755 --- a/data/templates/check_dependencies.py +++ b/data/templates/check_dependencies.py @@ -1,4 +1,4 @@ -${shebang} +#!/usr/bin/env python3 # -*- coding: utf-8 -*- """Script to check for the availability and version of dependencies.""" diff --git a/data/templates/github_actions/test_docker.yml b/data/templates/github_actions/test_docker.yml index 6f1c4c15..e1b62a36 100644 --- a/data/templates/github_actions/test_docker.yml +++ b/data/templates/github_actions/test_docker.yml @@ -37,7 +37,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - version: ['24.04'] + version: ['26.04'] container: image: ubuntu:$${{ matrix.version }} steps: diff --git a/data/templates/pyproject.toml b/data/templates/pyproject.toml deleted file mode 100644 index ee74093b..00000000 --- a/data/templates/pyproject.toml +++ /dev/null @@ -1,10 +0,0 @@ -[build-system] -requires = ["setuptools", "wheel"] -build-backend = "setuptools.build_meta" - -[tool.docformatter] -black = false -non-cap = ["dfDateTime", "dfImageTools", "dfVFS", "dfWinReg", "dtFabric", "iMessage", "iOS", "iPod", "mDNS"] -non-strict = false -wrap-summaries = 80 -wrap-descriptions = 80 diff --git a/data/templates/setup.cfg/metadata b/data/templates/setup.cfg/metadata deleted file mode 100644 index 6c7c5452..00000000 --- a/data/templates/setup.cfg/metadata +++ /dev/null @@ -1,25 +0,0 @@ -[metadata] -name = ${python_module_name} -version = ${version} -description = ${description_short} -long_description = ${description_long} -long_description_content_type = text/plain -url = ${homepage_url} -maintainer = ${maintainer_name} -maintainer_email = ${maintainer_email} -license = Apache License, Version 2.0 -license_files = - ACKNOWLEDGEMENTS - AUTHORS - LICENSE - README -classifiers = - ${development_status} - Programming Language :: Python - -[options] -install_requires = file:requirements.txt -package_dir = - ${python_module_name} = ${python_module_name} -packages = find: -python_requires = >=3.10 diff --git a/data/templates/setup.cfg/options_entry_points b/data/templates/setup.cfg/options_entry_points deleted file mode 100644 index d3416d0b..00000000 --- a/data/templates/setup.cfg/options_entry_points +++ /dev/null @@ -1,4 +0,0 @@ - -[options.entry_points] -console_scripts = -${console_scripts} diff --git a/data/templates/setup.cfg/options_package_data b/data/templates/setup.cfg/options_package_data deleted file mode 100644 index a339bb68..00000000 --- a/data/templates/setup.cfg/options_package_data +++ /dev/null @@ -1,4 +0,0 @@ - -[options.package_data] -${python_module_name} = -${package_data} diff --git a/data/templates/setup.cfg/options_packages_find b/data/templates/setup.cfg/options_packages_find deleted file mode 100644 index 1634ba26..00000000 --- a/data/templates/setup.cfg/options_packages_find +++ /dev/null @@ -1,8 +0,0 @@ - -[options.packages.find] -exclude = - docs - tests - tests.* - utils -where = . diff --git a/data/templates/setup.cfg/options_scripts b/data/templates/setup.cfg/options_scripts deleted file mode 100644 index de9c8b45..00000000 --- a/data/templates/setup.cfg/options_scripts +++ /dev/null @@ -1,2 +0,0 @@ -scripts = -${scripts} diff --git a/data/templates/setup.py b/data/templates/setup.py deleted file mode 100755 index 888841c5..00000000 --- a/data/templates/setup.py +++ /dev/null @@ -1,8 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- -"""Installation and deployment script.""" - -from setuptools import setup - - -setup() diff --git a/data/templates/tox.ini/header b/data/templates/tox.ini/header index 955bb769..271cb1de 100644 --- a/data/templates/tox.ini/header +++ b/data/templates/tox.ini/header @@ -11,8 +11,6 @@ passenv = setenv = PYTHONPATH = {toxinidir} deps = - -rrequirements.txt - -rtest_requirements.txt coverage: coverage wheel: build @@ -24,10 +22,3 @@ commands = coverage: coverage run --source=${python_module_name} --omit="*_test*,*__init__*,*test_lib*" run_tests.py coverage: coverage xml wheel: python -m build --no-isolation --wheel - -[testenv:docformatter] -usedevelop = True -deps = - docformatter -commands = - docformatter --in-place --recursive ${python_module_name} tests diff --git a/data/templates/tox.ini/testenv_lint b/data/templates/tox.ini/testenv_lint index 7e4ca601..11fac4af 100644 --- a/data/templates/tox.ini/testenv_lint +++ b/data/templates/tox.ini/testenv_lint @@ -9,13 +9,8 @@ passenv = setenv = PYTHONPATH = {toxinidir} deps = - -rrequirements.txt - -rtest_requirements.txt - docformatter pylint >= 3.3.0, < 3.4.0 - setuptools + setuptools >= 65 commands = - docformatter --version pylint --version - docformatter --check --diff --recursive ${paths_to_lint_python} pylint --rcfile=.pylintrc ${paths_to_lint_python} diff --git a/data/templates/tox.ini/testenv_lint-with_yaml b/data/templates/tox.ini/testenv_lint-with_yaml index f336111c..efcd264c 100644 --- a/data/templates/tox.ini/testenv_lint-with_yaml +++ b/data/templates/tox.ini/testenv_lint-with_yaml @@ -9,16 +9,11 @@ passenv = setenv = PYTHONPATH = {toxinidir} deps = - -rrequirements.txt - -rtest_requirements.txt - docformatter pylint >= 3.3.0, < 3.4.0 - setuptools + setuptools >= 65 yamllint >= 1.26.0 commands = - docformatter --version pylint --version yamllint -v - docformatter --check --diff --recursive ${paths_to_lint_python} pylint --rcfile=.pylintrc ${paths_to_lint_python} yamllint -c .yamllint.yaml ${paths_to_lint_yaml} diff --git a/l2tdevtools/dependencies.py b/l2tdevtools/dependencies.py index 4f46027d..c6274ca6 100644 --- a/l2tdevtools/dependencies.py +++ b/l2tdevtools/dependencies.py @@ -26,7 +26,7 @@ class DependencyDefinition(object): skip_check (bool): True if the dependency should be skipped by the CheckDependencies or CheckTestDependencies methods of DependencyHelper. skip_requires (bool): True if the dependency should be excluded from - requirements.txt or setup.py install_requires. + pyproject.toml dependencies. version_property (str): name of the version attribute or function. """ @@ -421,7 +421,8 @@ def _GetInstallRequires(self, dependencies, exclude_version=False): requires_string = ' '.join([requires_string, ','.join(requires_part)]) if module_name in ('pyxattr', 'xattr'): - requires_string = f'{requires_string:s} ; platform_system != "Windows"' + requires_string = ( + f'{requires_string:s} ; platform_system != \\"Windows\\"') install_requires.append(requires_string) diff --git a/l2tdevtools/dependency_writers/check_dependencies.py b/l2tdevtools/dependency_writers/check_dependencies.py index f3caf672..b876cf73 100644 --- a/l2tdevtools/dependency_writers/check_dependencies.py +++ b/l2tdevtools/dependency_writers/check_dependencies.py @@ -17,14 +17,8 @@ class CheckDependenciesWriter(interface.DependencyFileWriter): def Write(self): """Writes a check_dependencies.py file.""" - if self._project_definition.name in self._PROJECTS_WITH_PYTHON3_AS_DEFAULT: - shebang = '#!/usr/bin/env python3' - else: - shebang = '#!/usr/bin/env python' - template_mappings = { 'project_name': self._project_definition.name, - 'shebang': shebang, } if self._project_definition.name == 'plaso': diff --git a/l2tdevtools/dependency_writers/requirements.py b/l2tdevtools/dependency_writers/requirements.py deleted file mode 100644 index 33a459fc..00000000 --- a/l2tdevtools/dependency_writers/requirements.py +++ /dev/null @@ -1,43 +0,0 @@ -# -*- coding: utf-8 -*- -"""Writer for requirements.txt files.""" - -from l2tdevtools.dependency_writers import interface - - -class RequirementsWriter(interface.DependencyFileWriter): - """Requirements file writer.""" - - PATH = 'requirements.txt' - - def Write(self): - """Writes a requirements file.""" - python_dependencies = self._GetPyPIPythonDependencies() - - file_content = [str(dependency) for dependency in python_dependencies] - - file_content.append('') - - file_content = '\n'.join(file_content) - - with open(self.PATH, 'w', encoding='utf-8') as file_object: - file_object.write(file_content) - - -class TestRequirementsWriter(interface.DependencyFileWriter): - """Test requirements file writer.""" - - PATH = 'test_requirements.txt' - - def Write(self): - """Writes a test requirements file.""" - python_dependencies = self._GetPyPIPythonDependencies() - test_dependencies = self._GetPyPITestDependencies(python_dependencies) - - file_content = [str(dependency) for dependency in test_dependencies] - - file_content.append('') - - file_content = '\n'.join(file_content) - - with open(self.PATH, 'w', encoding='utf-8') as file_object: - file_object.write(file_content) diff --git a/l2tdevtools/dependency_writers/setup.py b/l2tdevtools/dependency_writers/setup.py index 975518ab..2f067bfa 100644 --- a/l2tdevtools/dependency_writers/setup.py +++ b/l2tdevtools/dependency_writers/setup.py @@ -3,6 +3,7 @@ import datetime import glob +import logging import os from l2tdevtools.dependency_writers import interface @@ -13,55 +14,11 @@ class PyprojectTomlWriter(interface.DependencyFileWriter): PATH = os.path.join('pyproject.toml') - _TEMPLATE_FILE = os.path.join('data', 'templates', 'pyproject.toml') - - def Write(self): - """Writes a pyproject.toml file.""" - path = os.path.join(self._l2tdevtools_path, self._TEMPLATE_FILE) - with open(path, 'r', encoding='utf-8') as file_object: - file_content = file_object.read() - - with open(self.PATH, 'w', encoding='utf-8') as file_object: - file_object.write(file_content) - - -class SetupCfgWriter(interface.DependencyFileWriter): - """Setup configuration file writer.""" - - PATH = 'setup.cfg' - - _DOC_FILES = ('ACKNOWLEDGEMENTS', 'AUTHORS', 'LICENSE', 'README') - _PROJECTS_WITH_PACKAGE_DATA = ( 'artifacts-kb', 'dfvfs', 'dfwinreg', 'dtformats', 'esedb-kb', 'mapi-kb', 'olecf-kb', 'plaso', 'winreg-kb', 'winsps-kb') - _TEMPLATE_DIRECTORY = os.path.join('data', 'templates', 'setup.cfg') - - def _DetermineSubmoduleLevels(self, python_module_name): - """Determines the number of submodule levels. - - Args: - python_module_name (str): name of the Python module. - - Return: - int: number of submodule levels. - """ - submodule_glob = python_module_name - submodule_levels = 0 - - while submodule_levels < 10: - submodule_glob = f'{submodule_glob:s}/*' - submodule_paths = [ - path for path in glob.glob(submodule_glob) - if os.path.isdir(path) and os.path.basename(path) != '__pycache__'] - - if not submodule_paths: - break - - submodule_levels += 1 - - return submodule_levels + _TEMPLATE_DIRECTORY = os.path.join('data', 'templates', 'pyproject.toml') def _GenerateFromTemplate(self, template_filename, template_mappings): """Generates file context based on a template file. @@ -79,14 +36,11 @@ def _GenerateFromTemplate(self, template_filename, template_mappings): """ template_filename = os.path.join( self._l2tdevtools_path, self._TEMPLATE_DIRECTORY, template_filename) - return super(SetupCfgWriter, self)._GenerateFromTemplate( + return super(PyprojectTomlWriter, self)._GenerateFromTemplate( template_filename, template_mappings) def Write(self): - """Writes a setup.cfg file.""" - description_long = ' '.join( - self._project_definition.description_long.split('\n')) - + """Writes a pyproject.toml file.""" if self._project_definition.status == 'experimental': development_status = 'Development Status :: 2 - Pre-Alpha' elif self._project_definition.status == 'alpha': @@ -98,11 +52,7 @@ def Write(self): else: development_status = '' - doc_files = [ - doc_file for doc_file in self._DOC_FILES if os.path.isfile(doc_file)] - - formatted_doc_files = [ - f' {doc_file:s}' for doc_file in sorted(doc_files)] + # TODO: handle license-files maintainer_name, _, maintainer_email = ( self._project_definition.maintainer.partition('<')) @@ -114,8 +64,6 @@ def Write(self): if self._project_definition.name.endswith('-kb'): python_module_name = ''.join([python_module_name[:-3], 'rc']) - # TODO: handle data directory without yaml files. - package_data = [] for data_file in glob.glob( f'{python_module_name:s}/**/*.yaml', recursive=True): @@ -129,8 +77,9 @@ def Write(self): if data_file not in package_data: package_data.append(data_file) - formatted_package_data = [ - f' {data_file:s}' for data_file in sorted(package_data)] + readme_file = 'README.md' + if not os.path.isfile(readme_file): + readme_file = 'README' scripts_directory = 'scripts' if not os.path.isdir(scripts_directory): @@ -138,12 +87,11 @@ def Write(self): if not os.path.isdir(scripts_directory): scripts_directory = None - scripts = [] if scripts_directory: - scripts = glob.glob(f'{scripts_directory:s}/[a-z]*.py') - - formatted_scripts = [ - f' {script:s}' for script in sorted(scripts)] + if glob.glob(f'{scripts_directory:s}/[a-z]*.py'): + logging.warning(( + 'Scripts are not supported by pyproject.toml, change them to ' + 'console_scripts entry points.')) console_scripts_directory = os.path.join(python_module_name, 'scripts') if not os.path.isdir(console_scripts_directory): @@ -153,73 +101,77 @@ def Write(self): if console_scripts_directory: console_scripts = glob.glob(f'{console_scripts_directory:s}/[a-z]*.py') - entry_points_console_scripts = [] - for console_script in sorted(console_scripts): - console_script = console_script.replace('.py', '') - module_name = console_script.replace(os.path.sep, '.') - name = os.path.basename(console_script) - entry_points_console_scripts.append(f' {name:s} = {module_name:s}:Main') - date_time = datetime.datetime.now() version = date_time.strftime('%Y%m%d') template_mappings = { - 'console_scripts': '\n'.join(entry_points_console_scripts), - 'description_long': description_long, - 'description_short': self._project_definition.description_short, + 'description_short': ( + self._project_definition.description_short.rstrip(".")), 'development_status': development_status, - 'doc_files': '\n'.join(formatted_doc_files), - 'homepage_url': self._project_definition.homepage_url, - 'maintainer': self._project_definition.maintainer, 'maintainer_email': maintainer_email, 'maintainer_name': maintainer_name, - 'package_data': '\n'.join(formatted_package_data), 'python_module_name': python_module_name, - 'scripts': '\n'.join(formatted_scripts), + 'readme_file': readme_file, 'version': version} file_content = [] - template_data = self._GenerateFromTemplate('metadata', template_mappings) + template_data = self._GenerateFromTemplate('header.toml', template_mappings) file_content.append(template_data) - if scripts: - template_data = self._GenerateFromTemplate( - 'options_scripts', template_mappings) - file_content.append(template_data) - - if package_data: - template_data = self._GenerateFromTemplate( - 'options_package_data', template_mappings) - file_content.append(template_data) - template_data = self._GenerateFromTemplate( - 'options_packages_find', template_mappings) + 'project.toml', template_mappings) file_content.append(template_data) - if entry_points_console_scripts: - template_data = self._GenerateFromTemplate( - 'options_entry_points', template_mappings) - file_content.append(template_data) + python_dependencies = self._GetPyPIPythonDependencies() + if python_dependencies: + file_content.append('dependencies = [\n') + for dependency in python_dependencies: + dependency_string = str(dependency) + file_content.append(f' "{dependency_string:s}",\n') - file_content = ''.join(file_content) + file_content.append(']\n') - with open(self.PATH, 'w', encoding='utf-8') as file_object: - file_object.write(file_content) + if console_scripts: + file_content.append('\n') + file_content.append('[project.scripts]\n') + for console_script in sorted(console_scripts): + console_script = console_script.replace('.py', '') + module_name = console_script.replace(os.path.sep, '.') + name = os.path.basename(console_script) + file_content.append(f'{name:s} = "{module_name:s}:Main"\n') -class SetupPyWriter(interface.DependencyFileWriter): - """Setup script file writer.""" + if self._project_definition.homepage_url: + file_content.append('\n') + file_content.append('[project.urls]\n') - PATH = os.path.join('setup.py') + if os.path.isdir('docs'): + url = f'https://{python_module_name:s}.readthedocs.io/en/latest' + file_content.append(f'Documentation = "{url:s}"\n') - _TEMPLATE_FILE = os.path.join('data', 'templates', 'setup.py') + url = self._project_definition.homepage_url + file_content.append(f'Homepage = "{url:s}"\n') + file_content.append(f'Repository = "{url:s}"\n') - def Write(self): - """Writes a setup.py file.""" - path = os.path.join(self._l2tdevtools_path, self._TEMPLATE_FILE) - with open(path, 'r', encoding='utf-8') as file_object: - file_content = file_object.read() + if package_data: + file_content.append('\n') + file_content.append('[tool.setuptools.package-data]\n') + + file_content.append(f'{python_module_name:s} = [\n') + for data_file in sorted(package_data): + if (self._project_definition.name == 'plaso' and + data_file == 'data/*.yaml'): + data_file = 'data/*.*' + file_content.append(f' "{data_file:s}",\n') + + file_content.append(']\n') + + template_data = self._GenerateFromTemplate( + 'setuptools.packages.toml', template_mappings) + file_content.append(template_data) + + file_content = ''.join(file_content) with open(self.PATH, 'w', encoding='utf-8') as file_object: file_object.write(file_content) diff --git a/l2tdevtools/dependency_writers/tox_ini.py b/l2tdevtools/dependency_writers/tox_ini.py index d57ed0fa..57f39a05 100644 --- a/l2tdevtools/dependency_writers/tox_ini.py +++ b/l2tdevtools/dependency_writers/tox_ini.py @@ -35,6 +35,10 @@ def _GenerateFromTemplate(self, template_filename, template_mappings): def Write(self): """Writes a tox.ini file.""" + # TODO: Write test dependencies. + # python_dependencies = self._GetPyPIPythonDependencies() + # test_dependencies = self._GetPyPITestDependencies(python_dependencies) + python_module_name = self._project_definition.name if self._project_definition.name.endswith('-kb'): @@ -54,9 +58,6 @@ def Write(self): if glob.glob(os.path.join('data', '**', '*.yaml'), recursive=True): paths_to_lint_yaml.append('data') - if os.path.isfile('setup.py'): - paths_to_lint_python.append('setup.py') - if os.path.isdir('scripts'): paths_to_lint_python.append('scripts') @@ -73,7 +74,7 @@ def Write(self): if os.path.isdir('tools'): paths_to_lint_python.append('tools') - envlist = ['py3{10,11,12,13,14}', 'coverage', 'docformatter'] + envlist = ['py3{10,11,12,13,14}', 'coverage'] if os.path.isdir('docs'): envlist.append('docs') diff --git a/l2tdevtools/projects.py b/l2tdevtools/projects.py index 3d709255..cf8e4a8c 100644 --- a/l2tdevtools/projects.py +++ b/l2tdevtools/projects.py @@ -52,7 +52,7 @@ class ProjectDefinition(object): rpm_dependencies (list[str]): rpm dependencies. rpm_name (str): RPM package name. rpm_template_spec (str): name of the rpm spec file. - setup_name (str): project name used in setup.py. + setup_name (str): project name used by setup.py or pyproject.toml. srpm_name (str): source RPM package name. version (ProjectVersionDefinition): version requirements. wheel_name (str): Python wheel package name. diff --git a/l2tdevtools/review_helpers/git.py b/l2tdevtools/review_helpers/git.py index 3584788e..eb7a65ad 100644 --- a/l2tdevtools/review_helpers/git.py +++ b/l2tdevtools/review_helpers/git.py @@ -174,7 +174,7 @@ def GetChangedPythonFiles(self, diffbase=None): Note that several Python files are excluded: * Python files generated by the protobuf compiler (*_pb2.py) * Python files used as test data (test_data/*.py) - * setup.py and review/lib/upload.py + * l2tdevtools/lib/upload.py Args: diffbase (Optional[str]): git diffbase, for example "upstream/main". @@ -182,7 +182,6 @@ def GetChangedPythonFiles(self, diffbase=None): Returns: list[str]: names of the changed Python files. """ - upload_path = os.path.join('l2tdevtools', 'lib', 'upload.py') python_files = [] for changed_file in self.GetChangedFiles(diffbase=diffbase): if (not changed_file.endswith('.py') or @@ -191,7 +190,7 @@ def GetChangedPythonFiles(self, diffbase=None): changed_file.startswith('data') or changed_file.startswith('docs') or changed_file.startswith('test_data') or - changed_file in ('setup.py', upload_path)): + changed_file == os.path.join('l2tdevtools', 'lib', 'upload.py')): continue python_files.append(changed_file) diff --git a/l2tdevtools/spec_file.py b/l2tdevtools/spec_file.py index 21e9342e..803e0240 100644 --- a/l2tdevtools/spec_file.py +++ b/l2tdevtools/spec_file.py @@ -19,7 +19,7 @@ class RPMSpecFileGenerator(object): _DOC_FILENAMES = [ 'CHANGES', 'CHANGES.txt', 'CHANGES.TXT', - 'README', 'README.txt', 'README.TXT'] + 'README', 'README.md', 'README.txt', 'README.TXT'] _LICENSE_FILENAMES = [ 'LICENSE', 'LICENSE.txt', 'LICENSE.TXT'] @@ -405,7 +405,7 @@ def _WriteDataPackageFiles(self, output_file_object): '%files -n %{name}-data', '%defattr(644,root,root,755)', '%license LICENSE', - '%doc ACKNOWLEDGEMENTS AUTHORS README', + '%doc ACKNOWLEDGEMENTS AUTHORS README.md', '%{_datadir}/%{name}/*', '', ''] diff --git a/pyproject.toml b/pyproject.toml index ee74093b..79a77026 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -2,9 +2,27 @@ requires = ["setuptools", "wheel"] build-backend = "setuptools.build_meta" -[tool.docformatter] -black = false -non-cap = ["dfDateTime", "dfImageTools", "dfVFS", "dfWinReg", "dtFabric", "iMessage", "iOS", "iPod", "mDNS"] -non-strict = false -wrap-summaries = 80 -wrap-descriptions = 80 +[project] +name = "l2tdevtools" +version = "20251127" +description = "Development tools for the log2timeline projects" +maintainers = [ + { name = "Log2Timeline maintainers", email = "log2timeline-maintainers@googlegroups.com" }, +] +license = "Apache-2.0" +license-files = ["ACKNOWLEDGEMENTS", "AUTHORS", "LICENSE"] +readme = "README.md" +classifiers = [ + "Development Status :: 3 - Alpha", + "Programming Language :: Python", +] +requires-python = ">=3.11" + +[project.urls] +Homepage = "https://github.com/log2timeline/l2tdevtools" +Repository = "https://github.com/log2timeline/l2tdevtools" + +[tool.setuptools.packages.find] +where = ["."] +include = ["l2tdevtools"] +exclude = ["docs", "tests", "tests.*", "utils"] diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index e69de29b..00000000 diff --git a/run_tests.py b/run_tests.py index 3d845763..736408d1 100755 --- a/run_tests.py +++ b/run_tests.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # -*- coding: utf-8 -*- """Script to run the tests.""" diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index 3ad934eb..00000000 --- a/setup.cfg +++ /dev/null @@ -1,43 +0,0 @@ -[metadata] -name = l2tdevtools -version = 20251118 -description = Development tools for the log2timeline projects -long_description = Development tools for the log2timeline projects. -long_description_content_type = text/plain -url = https://github.com/log2timeline/l2tdevtools -maintainer = Log2Timeline maintainers -maintainer_email = log2timeline-maintainers@googlegroups.com -license = Apache License, Version 2.0 -license_files = - ACKNOWLEDGEMENTS - AUTHORS - LICENSE - README -classifiers = - Development Status :: 3 - Alpha - Programming Language :: Python - -[options] -install_requires = file:requirements.txt -package_dir = - l2tdevtools = l2tdevtools -packages = find: -python_requires = >=3.11 -scripts = - tools/build.py - tools/develop.py - tools/dpkg-generate.py - tools/manage.py - tools/review.py - tools/schema_extractor.py - tools/stats.py - tools/update-dependencies.py - tools/update.py - -[options.packages.find] -exclude = - docs - tests - tests.* - utils -where = . diff --git a/setup.py b/setup.py deleted file mode 100755 index 888841c5..00000000 --- a/setup.py +++ /dev/null @@ -1,8 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- -"""Installation and deployment script.""" - -from setuptools import setup - - -setup() diff --git a/tests/build_helpers/dpkg.py b/tests/build_helpers/dpkg.py index bf6acb5f..a427e898 100644 --- a/tests/build_helpers/dpkg.py +++ b/tests/build_helpers/dpkg.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # -*- coding: utf-8 -*- """Tests for the helper for building projects from source.""" diff --git a/tests/build_helpers/factory.py b/tests/build_helpers/factory.py index 3275c4f8..8dde4723 100644 --- a/tests/build_helpers/factory.py +++ b/tests/build_helpers/factory.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # -*- coding: utf-8 -*- """Tests for the helper for building projects from source.""" diff --git a/tests/build_helpers/interface.py b/tests/build_helpers/interface.py index d66bd39f..7595fa52 100644 --- a/tests/build_helpers/interface.py +++ b/tests/build_helpers/interface.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # -*- coding: utf-8 -*- """Tests for the helper for building projects from source.""" diff --git a/tests/build_helpers/rpm.py b/tests/build_helpers/rpm.py index 12e7e710..4a1e1203 100644 --- a/tests/build_helpers/rpm.py +++ b/tests/build_helpers/rpm.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # -*- coding: utf-8 -*- """Tests for the helper for building projects from source.""" diff --git a/tests/build_helpers/source.py b/tests/build_helpers/source.py index 490b5899..4850f934 100644 --- a/tests/build_helpers/source.py +++ b/tests/build_helpers/source.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # -*- coding: utf-8 -*- """Tests for the helper for building projects from source.""" diff --git a/tests/build_helpers/wheel.py b/tests/build_helpers/wheel.py index 0b3f42da..f0edaf10 100644 --- a/tests/build_helpers/wheel.py +++ b/tests/build_helpers/wheel.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # -*- coding: utf-8 -*- """Tests for the helper for building projects from source.""" diff --git a/tests/dependencies.py b/tests/dependencies.py index 5aa53f2e..34d9e786 100644 --- a/tests/dependencies.py +++ b/tests/dependencies.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # -*- coding: utf-8 -*- """Tests for the helper to check for dependencies.""" diff --git a/tests/dependency_writers/appveyor_yml.py b/tests/dependency_writers/appveyor_yml.py index 3278f3d3..0b90f35a 100644 --- a/tests/dependency_writers/appveyor_yml.py +++ b/tests/dependency_writers/appveyor_yml.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # -*- coding: utf-8 -*- """Tests for the appveyor.yml writer.""" diff --git a/tests/dependency_writers/dependencies_py.py b/tests/dependency_writers/dependencies_py.py index b7c5f7ae..9d448982 100644 --- a/tests/dependency_writers/dependencies_py.py +++ b/tests/dependency_writers/dependencies_py.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # -*- coding: utf-8 -*- """Tests for the dependencies.py writer.""" diff --git a/tests/dependency_writers/dpkg.py b/tests/dependency_writers/dpkg.py index 7559a407..26d74689 100644 --- a/tests/dependency_writers/dpkg.py +++ b/tests/dependency_writers/dpkg.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # -*- coding: utf-8 -*- """Tests for the Debian packaging (dpkg) writer.""" diff --git a/tests/dependency_writers/gift_copr.py b/tests/dependency_writers/gift_copr.py index d6cb1481..e58ea177 100644 --- a/tests/dependency_writers/gift_copr.py +++ b/tests/dependency_writers/gift_copr.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # -*- coding: utf-8 -*- """Tests for the GIFT COPR script writer.""" diff --git a/tests/dependency_writers/gift_ppa.py b/tests/dependency_writers/gift_ppa.py index e53d134f..d92ff9a5 100644 --- a/tests/dependency_writers/gift_ppa.py +++ b/tests/dependency_writers/gift_ppa.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # -*- coding: utf-8 -*- """Tests for the GIFT PPA script writer.""" diff --git a/tests/dependency_writers/interface.py b/tests/dependency_writers/interface.py index 4f7161e1..fcf0afc3 100644 --- a/tests/dependency_writers/interface.py +++ b/tests/dependency_writers/interface.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # -*- coding: utf-8 -*- """Tests for the base class for dependency file writers.""" diff --git a/tests/dependency_writers/jenkins_scripts.py b/tests/dependency_writers/jenkins_scripts.py index ea67f81e..21d1d507 100644 --- a/tests/dependency_writers/jenkins_scripts.py +++ b/tests/dependency_writers/jenkins_scripts.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # -*- coding: utf-8 -*- """Tests for the end-to-end tests script files writer.""" diff --git a/tests/dependency_writers/linux_scripts.py b/tests/dependency_writers/linux_scripts.py index dfa2e44d..d5293d80 100644 --- a/tests/dependency_writers/linux_scripts.py +++ b/tests/dependency_writers/linux_scripts.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # -*- coding: utf-8 -*- """Tests for the GIFT PPA script writer.""" diff --git a/tests/dependency_writers/pylint_rc.py b/tests/dependency_writers/pylint_rc.py index 948716b0..5970d439 100644 --- a/tests/dependency_writers/pylint_rc.py +++ b/tests/dependency_writers/pylint_rc.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # -*- coding: utf-8 -*- """Tests for the pylint.rc writer.""" diff --git a/tests/dependency_writers/requirements.py b/tests/dependency_writers/requirements.py deleted file mode 100644 index 6d279b4d..00000000 --- a/tests/dependency_writers/requirements.py +++ /dev/null @@ -1,67 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- -"""Tests for the requirements.txt writer.""" - -import unittest - -from l2tdevtools import dependencies -from l2tdevtools import projects -from l2tdevtools.dependency_writers import requirements - -from tests import test_lib - - -class RequirementsWriterTest(test_lib.BaseTestCase): - """Tests the requirements writer.""" - - def _CreateTestWriter(self): - """Creates a dependency file writer for testing. - - Returns: - RequirementsWriter: dependency file writer for testing. - """ - project_definition = projects.ProjectDefinition('test') - dependencies_file = self._GetTestFilePath(['dependencies.ini']) - test_dependencies_file = self._GetTestFilePath(['test_dependencies.ini']) - dependency_helper = dependencies.DependencyHelper( - dependencies_file=dependencies_file, - test_dependencies_file=test_dependencies_file) - - return requirements.RequirementsWriter( - '/fake/l2tdevtools/', project_definition, dependency_helper) - - def testInitialize(self): - """Tests the __init__ function.""" - test_writer = self._CreateTestWriter() - self.assertIsNotNone(test_writer) - - # TODO: Add test for the Write method. - - -class TestRequirementsWriterTest(test_lib.BaseTestCase): - """Tests the test requirements writer.""" - - def _CreateTestWriter(self): - """Creates a dependency file writer for testing. - - Returns: - TestRequirementsWriter: dependency file writer for testing. - """ - project_definition = projects.ProjectDefinition('test') - dependencies_file = self._GetTestFilePath(['dependencies.ini']) - test_dependencies_file = self._GetTestFilePath(['test_dependencies.ini']) - dependency_helper = dependencies.DependencyHelper( - dependencies_file=dependencies_file, - test_dependencies_file=test_dependencies_file) - - return requirements.TestRequirementsWriter( - '/fake/l2tdevtools/', project_definition, dependency_helper) - - def testInitialize(self): - """Tests the __init__ function.""" - test_writer = self._CreateTestWriter() - self.assertIsNotNone(test_writer) - - -if __name__ == '__main__': - unittest.main() diff --git a/tests/dependency_writers/setup.py b/tests/dependency_writers/setup.py index bb163602..56c8c7fb 100644 --- a/tests/dependency_writers/setup.py +++ b/tests/dependency_writers/setup.py @@ -1,6 +1,6 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # -*- coding: utf-8 -*- -"""Tests for the setup.cfg writer.""" +"""Tests for the setup configuration and script file writers.""" import unittest @@ -10,8 +10,8 @@ from tests import test_lib -class SetupCfgTest(test_lib.BaseTestCase): - """Tests the setup configuration file writer.""" +class PyprojectTomlWriterTest(test_lib.BaseTestCase): + """Tests the pyproject.toml configuration file writer.""" def testInitialize(self): """Tests that the writer can be initialized.""" @@ -23,27 +23,7 @@ def testInitialize(self): dependencies_file=dependencies_file, test_dependencies_file=test_dependencies_file) - writer = setup.SetupCfgWriter( - l2tdevtools_path, project_definition, dependency_helper) - self.assertIsNotNone(writer) - - # TODO: Add test for the Write method. - - -class SetupPyTest(test_lib.BaseTestCase): - """Tests the setup.py writer.""" - - def testInitialize(self): - """Tests that the writer can be initialized.""" - l2tdevtools_path = '/fake/l2tdevtools/' - project_definition = project.ProjectHelper(l2tdevtools_path) - dependencies_file = self._GetTestFilePath(['dependencies.ini']) - test_dependencies_file = self._GetTestFilePath(['test_dependencies.ini']) - dependency_helper = dependencies.DependencyHelper( - dependencies_file=dependencies_file, - test_dependencies_file=test_dependencies_file) - - writer = setup.SetupPyWriter( + writer = setup.PyprojectTomlWriter( l2tdevtools_path, project_definition, dependency_helper) self.assertIsNotNone(writer) diff --git a/tests/dependency_writers/sphinx_docs.py b/tests/dependency_writers/sphinx_docs.py index b2003f8b..f054fbb0 100644 --- a/tests/dependency_writers/sphinx_docs.py +++ b/tests/dependency_writers/sphinx_docs.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # -*- coding: utf-8 -*- """Tests for the Sphinx build configuration and documentation file writer.""" diff --git a/tests/dependency_writers/tox_ini.py b/tests/dependency_writers/tox_ini.py index b4c5828a..e49ed9f3 100644 --- a/tests/dependency_writers/tox_ini.py +++ b/tests/dependency_writers/tox_ini.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # -*- coding: utf-8 -*- """Tests for the tox.ini writer.""" diff --git a/tests/download_helper.py b/tests/download_helper.py index d0ed24f4..ddf88005 100644 --- a/tests/download_helper.py +++ b/tests/download_helper.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # -*- coding: utf-8 -*- """Tests for the download helper object implementations.""" diff --git a/tests/download_helpers/github.py b/tests/download_helpers/github.py index c337efca..9866dce0 100644 --- a/tests/download_helpers/github.py +++ b/tests/download_helpers/github.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # -*- coding: utf-8 -*- """Tests for the download helper object implementations.""" diff --git a/tests/download_helpers/interface.py b/tests/download_helpers/interface.py index 387e0e48..97133e86 100644 --- a/tests/download_helpers/interface.py +++ b/tests/download_helpers/interface.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # -*- coding: utf-8 -*- """Tests for the download helper object implementations.""" diff --git a/tests/download_helpers/pypi.py b/tests/download_helpers/pypi.py index 346008e4..71791813 100644 --- a/tests/download_helpers/pypi.py +++ b/tests/download_helpers/pypi.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # -*- coding: utf-8 -*- """Tests for the download helper object implementations.""" diff --git a/tests/download_helpers/sourceforge.py b/tests/download_helpers/sourceforge.py index ffc95254..584960f1 100644 --- a/tests/download_helpers/sourceforge.py +++ b/tests/download_helpers/sourceforge.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # -*- coding: utf-8 -*- """Tests for the download helper object implementations.""" diff --git a/tests/dpkg_files.py b/tests/dpkg_files.py index 0afd40ab..e528f0c9 100644 --- a/tests/dpkg_files.py +++ b/tests/dpkg_files.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # -*- coding: utf-8 -*- """Tests for the dpkg build files generator.""" diff --git a/tests/helpers/project.py b/tests/helpers/project.py index 96095184..c5286c21 100644 --- a/tests/helpers/project.py +++ b/tests/helpers/project.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # -*- coding: utf-8 -*- """Tests for the project helper.""" diff --git a/tests/presets.py b/tests/presets.py index 44f60493..bdc7500a 100644 --- a/tests/presets.py +++ b/tests/presets.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # -*- coding: utf-8 -*- """Tests for the project preset definitions.""" diff --git a/tests/projects.py b/tests/projects.py index a12b9fe1..44af0b78 100644 --- a/tests/projects.py +++ b/tests/projects.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # -*- coding: utf-8 -*- """Tests for the project definitions.""" diff --git a/tests/review_helpers/cli.py b/tests/review_helpers/cli.py index bc6bb787..d14dd35f 100644 --- a/tests/review_helpers/cli.py +++ b/tests/review_helpers/cli.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # -*- coding: utf-8 -*- """Tests for command line helper.""" diff --git a/tests/review_helpers/git.py b/tests/review_helpers/git.py index e63793db..f79eda9b 100644 --- a/tests/review_helpers/git.py +++ b/tests/review_helpers/git.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # -*- coding: utf-8 -*- """Tests for the git helper.""" diff --git a/tests/review_helpers/github.py b/tests/review_helpers/github.py index a687c6cb..89523b7b 100644 --- a/tests/review_helpers/github.py +++ b/tests/review_helpers/github.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # -*- coding: utf-8 -*- """Tests for the GitHub helper.""" diff --git a/tests/review_helpers/pylint.py b/tests/review_helpers/pylint.py index ac4065df..6129a0cb 100644 --- a/tests/review_helpers/pylint.py +++ b/tests/review_helpers/pylint.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # -*- coding: utf-8 -*- """Tests for the pylint helper.""" diff --git a/tests/review_helpers/review.py b/tests/review_helpers/review.py index 2b72c82b..4c949698 100644 --- a/tests/review_helpers/review.py +++ b/tests/review_helpers/review.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # -*- coding: utf-8 -*- """Tests for the review helper.""" diff --git a/tests/schema_extractor.py b/tests/schema_extractor.py index 59241db4..38d7db35 100644 --- a/tests/schema_extractor.py +++ b/tests/schema_extractor.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # -*- coding: utf-8 -*- """Tests for the SQLite database schema extractor tool.""" diff --git a/tests/source_helper.py b/tests/source_helper.py index 6bea33e6..cca2a90a 100644 --- a/tests/source_helper.py +++ b/tests/source_helper.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # -*- coding: utf-8 -*- """Tests for the helper for managing project source code.""" diff --git a/tests/spec_file.py b/tests/spec_file.py index de59ebeb..b32be087 100644 --- a/tests/spec_file.py +++ b/tests/spec_file.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # -*- coding: utf-8 -*- """Tests for the RPM spec file generator.""" diff --git a/tests/update.py b/tests/update.py index 2232d162..a0ca466a 100644 --- a/tests/update.py +++ b/tests/update.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # -*- coding: utf-8 -*- """Tests for the update tool.""" diff --git a/tools/build.py b/tools/build.py index 101a0ebc..8174511c 100755 --- a/tools/build.py +++ b/tools/build.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # -*- coding: utf-8 -*- """Script to automate creating builds of projects.""" diff --git a/tools/develop.py b/tools/develop.py index 5523261c..dcc8d275 100755 --- a/tools/develop.py +++ b/tools/develop.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # -*- coding: utf-8 -*- """Tool to build, run and manage dockerized development environments.""" diff --git a/tools/dpkg-generate.py b/tools/dpkg-generate.py index da7a381b..cc24f164 100755 --- a/tools/dpkg-generate.py +++ b/tools/dpkg-generate.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # -*- coding: utf-8 -*- # pylint: disable=invalid-name """Script to generate dpkg packaging files.""" diff --git a/tools/manage.py b/tools/manage.py index 033a89ca..1d4df3f3 100755 --- a/tools/manage.py +++ b/tools/manage.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # -*- coding: utf-8 -*- """Script to manage the GIFT launchpad PPA and l2tbinaries.""" diff --git a/tools/review.py b/tools/review.py index 1ab5b6f6..58417e77 100755 --- a/tools/review.py +++ b/tools/review.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # -*- coding: utf-8 -*- """Script to manage code reviews.""" diff --git a/tools/schema_extractor.py b/tools/schema_extractor.py index 13d12d3a..8d49188a 100755 --- a/tools/schema_extractor.py +++ b/tools/schema_extractor.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python3 # -*- coding: utf-8 -*- """Script to extract the database schema from SQLite database files.""" diff --git a/tools/stats.py b/tools/stats.py index a449865b..fa8f36a9 100755 --- a/tools/stats.py +++ b/tools/stats.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # -*- coding: utf-8 -*- """Script to retrieve GitHub project statistics.""" diff --git a/tools/update-dependencies.py b/tools/update-dependencies.py index d5063774..6abeed1e 100755 --- a/tools/update-dependencies.py +++ b/tools/update-dependencies.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # -*- coding: utf-8 -*- # pylint: disable=invalid-name """Script to update the dependencies in various configuration files.""" @@ -22,7 +22,6 @@ from l2tdevtools.dependency_writers import jenkins_scripts from l2tdevtools.dependency_writers import linux_scripts from l2tdevtools.dependency_writers import pylint_rc -from l2tdevtools.dependency_writers import requirements from l2tdevtools.dependency_writers import setup from l2tdevtools.dependency_writers import sphinx_docs from l2tdevtools.dependency_writers import tox_ini @@ -45,9 +44,7 @@ def Main(): dependencies_helper = dependencies.DependencyHelper() for writer_class in ( - pylint_rc.PylintRcWriter, requirements.RequirementsWriter, - requirements.TestRequirementsWriter, setup.PyprojectTomlWriter, - setup.SetupCfgWriter, setup.SetupPyWriter): + pylint_rc.PylintRcWriter, setup.PyprojectTomlWriter): writer = writer_class( l2tdevtools_path, project_definition, dependencies_helper) writer.Write() diff --git a/tools/update.py b/tools/update.py index 40ca740b..a12055d2 100755 --- a/tools/update.py +++ b/tools/update.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # -*- coding: utf-8 -*- """Script to update prebuilt versions of the projects.""" diff --git a/tox.ini b/tox.ini index 86941c17..e691235f 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = py3{11,12,13,14},coverage,docformatter,lint,wheel +envlist = py3{11,12,13,14},coverage,lint,wheel [testenv] allowlist_externals = ./run_tests.py @@ -11,8 +11,6 @@ passenv = setenv = PYTHONPATH = {toxinidir} deps = - -rrequirements.txt - -rtest_requirements.txt coverage: coverage wheel: build @@ -25,13 +23,6 @@ commands = coverage: coverage xml wheel: python -m build --no-isolation --wheel -[testenv:docformatter] -usedevelop = True -deps = - docformatter -commands = - docformatter --in-place --recursive l2tdevtools tests - [testenv:lint] skipsdist = True pip_pre = True @@ -42,16 +33,11 @@ passenv = setenv = PYTHONPATH = {toxinidir} deps = - -rrequirements.txt - -rtest_requirements.txt - docformatter pylint >= 3.3.0, < 3.4.0 - setuptools + setuptools >= 65 yamllint >= 1.26.0 commands = - docformatter --version pylint --version yamllint -v - docformatter --check --diff --recursive l2tdevtools setup.py tests tools - pylint --rcfile=.pylintrc l2tdevtools setup.py tests tools + pylint --rcfile=.pylintrc l2tdevtools tests tools yamllint -c .yamllint.yaml data From c1d8aae17ef8a164ae77e2414b545678d95f1130 Mon Sep 17 00:00:00 2001 From: Joachim Metz Date: Thu, 27 Nov 2025 05:47:58 +0100 Subject: [PATCH 2/2] Changes to dependency writers --- data/templates/pyproject.toml/header.toml | 3 +++ data/templates/pyproject.toml/project.toml | 16 ++++++++++++++++ .../pyproject.toml/setuptools.packages.toml | 5 +++++ l2tdevtools/dependency_writers/setup.py | 2 +- 4 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 data/templates/pyproject.toml/header.toml create mode 100644 data/templates/pyproject.toml/project.toml create mode 100644 data/templates/pyproject.toml/setuptools.packages.toml diff --git a/data/templates/pyproject.toml/header.toml b/data/templates/pyproject.toml/header.toml new file mode 100644 index 00000000..9787c3bd --- /dev/null +++ b/data/templates/pyproject.toml/header.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["setuptools", "wheel"] +build-backend = "setuptools.build_meta" diff --git a/data/templates/pyproject.toml/project.toml b/data/templates/pyproject.toml/project.toml new file mode 100644 index 00000000..ebceca4b --- /dev/null +++ b/data/templates/pyproject.toml/project.toml @@ -0,0 +1,16 @@ + +[project] +name = "${python_module_name}" +version = "${version}" +description = "${description_short}" +maintainers = [ + { name = "${maintainer_name}", email = "${maintainer_email}" }, +] +license = "Apache-2.0" +license-files = ["ACKNOWLEDGEMENTS", "AUTHORS", "LICENSE"] +readme = "${readme_file}" +classifiers = [ + "${development_status}", + "Programming Language :: Python", +] +requires-python = ">=3.10" diff --git a/data/templates/pyproject.toml/setuptools.packages.toml b/data/templates/pyproject.toml/setuptools.packages.toml new file mode 100644 index 00000000..c15d5e74 --- /dev/null +++ b/data/templates/pyproject.toml/setuptools.packages.toml @@ -0,0 +1,5 @@ + +[tool.setuptools.packages.find] +where = ["."] +include = ["${python_module_name}"] +exclude = ["docs", "tests", "tests.*", "utils"] diff --git a/l2tdevtools/dependency_writers/setup.py b/l2tdevtools/dependency_writers/setup.py index 2f067bfa..e002c82b 100644 --- a/l2tdevtools/dependency_writers/setup.py +++ b/l2tdevtools/dependency_writers/setup.py @@ -90,7 +90,7 @@ def Write(self): if scripts_directory: if glob.glob(f'{scripts_directory:s}/[a-z]*.py'): logging.warning(( - 'Scripts are not supported by pyproject.toml, change them to ' + 'Scripts are not supported by pyproject.toml, change them to ' 'console_scripts entry points.')) console_scripts_directory = os.path.join(python_module_name, 'scripts')