From 07fddd3c1259fb13707a18893638c0378e6037f2 Mon Sep 17 00:00:00 2001 From: Louis Dionne Date: Tue, 14 Oct 2025 08:48:23 -0400 Subject: [PATCH 1/3] Rewrite project build and metadata using pyproject.toml This patch rewrites the project build configuration using pyproject.toml, which is now the de-facto standard in Python. This single configuration file supersedes setup.py, tox.ini, mypy.ini, etc. I checked the contents of the generated package and made sure they matched exactly (that caught a few issues where I originally excluded some data files). This patch is careful not to change the version of dependencies. In pyproject.toml, we specify minimum package versions for the tool to work, and we provide a requirements.txt file that pins down specific versions for use by end-users. Currently, a few tests are failing if we don't pin exact versions when running them, so we're still pinning exact versions when we run tests via tox. The same holds for the type checker. In the future, we could upgrade towards a proper lockfile instead of manually constructed requirements.txt files. Fixes #77 --- Dockerfile | 9 +-- README.md | 34 +++++---- docs/developer_guide.rst | 6 +- mypy.ini | 2 - pyproject.toml | 154 +++++++++++++++++++++++++++++++++++++++ setup.cfg | 4 - setup.py | 134 ---------------------------------- tox.ini | 63 ---------------- 8 files changed, 177 insertions(+), 229 deletions(-) delete mode 100644 mypy.ini create mode 100644 pyproject.toml delete mode 100644 setup.cfg delete mode 100644 setup.py delete mode 100644 tox.ini diff --git a/Dockerfile b/Dockerfile index 26cead04..78b36546 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,19 +4,14 @@ RUN apk update \ && apk add --no-cache --virtual .build-deps git g++ postgresql-dev yaml-dev \ && apk add --no-cache libpq -WORKDIR /var/src/lnt +COPY . /var/src/lnt -COPY requirements*.txt setup.py . -# setup.py uses lnt.__version__ etc. -COPY lnt/__init__.py lnt/__init__.py -# we build the cperf extension during install -COPY lnt/testing/profile lnt/testing/profile +WORKDIR /var/src/lnt RUN pip3 install -r requirements.server.txt \ && apk --purge del .build-deps \ && mkdir /var/log/lnt -COPY . . COPY docker/docker-entrypoint.sh docker/wait_db /usr/local/bin/ VOLUME /var/log diff --git a/README.md b/README.md index dd56a3ea..71369c9b 100644 --- a/README.md +++ b/README.md @@ -1,24 +1,28 @@ -LLVM "Nightly Test" Infrastructure -================================== +LNT: LLVM "Nightly Test" Infrastructure +======================================= -This directory and its subdirectories contain the LLVM nightly test -infrastructure. This is technically version "4.0" of the LLVM nightly test -architecture. +About +===== -The infrastructure has the following layout: +*LNT* is an infrastructure for performance testing. The software itself +consists of two main parts, a web application for accessing and visualizing +performance data, and command line utilities to allow users to generate and +submit test results to the server. - $ROOT/lnt - Top-level Python 'lnt' module +The package was originally written for use in testing LLVM compiler +technologies, but is designed to be usable for the performance testing of any +software. - $ROOT/lnt/server/db - Database schema, utilities, and examples of the LNT plist format. - $ROOT/docs - Sphinx documentation for LNT. +Documentation +============= - $ROOT/tests - Tests for the infrastructure. +The official *LNT* documentation is available online at: + https://llvm.org/docs/lnt -For more information, see the web documentation, or docs/. -Testing -======= +Source +====== -Testing is done by running tox from the top-level directory. It runs the tests -for Python 3 and checks code style. +The *LNT* source is available in the llvm-lnt repository: + https://github.com/llvm/llvm-lnt diff --git a/docs/developer_guide.rst b/docs/developer_guide.rst index dd6aea14..01eb0693 100644 --- a/docs/developer_guide.rst +++ b/docs/developer_guide.rst @@ -34,10 +34,8 @@ To run the tests, we recomment using ``tox`` in a virtual environment:: You can also run individual unit tests with ``lit`` directly:: - pip install lit - lit -sv ./tests - -However, that requires manually setting up the testing environment (``filecheck``, etc). + pip install ".[dev]" + lit -sv tests For simple changes, adding a regression test and making sure all regression tests pass, is often a good enough testing approach. For some changes, the diff --git a/mypy.ini b/mypy.ini deleted file mode 100644 index dda49c57..00000000 --- a/mypy.ini +++ /dev/null @@ -1,2 +0,0 @@ -[mypy] -plugins = sqlmypy diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 00000000..71085352 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,154 @@ +[build-system] +requires = ["setuptools >= 74.1"] +build-backend = "setuptools.build_meta" + +[project] +name = "LNT" +version = "0.4.2.dev0" +description = "LLVM Nightly Test Infrastructure" +readme = "README.md" +license = "LicenseRef-Apache-2.0-with-LLVM-exception" +license-files = ["LICENSE.TXT"] +authors = [ + { name = "Daniel Dunbar", email = "daniel@zuster.org" }, +] +maintainers = [] +keywords = ["web", "testing", "performance", "development", "llvm"] +classifiers = [ + "Development Status :: 4 - Beta", + "Environment :: Web Environment", + "Intended Audience :: Developers", + "Natural Language :: English", + "Operating System :: OS Independent", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Topic :: Software Development :: Quality Assurance", + "Topic :: Software Development :: Testing", +] +requires-python = ">=3.10" +dependencies = [ + "aniso8601>=1.2.0", + "certifi", + "click>=8.1.0", + "Flask-RESTful>=0.3.10", + "Flask-WTF>=1.2.0", + "Flask>=3.1.0", + "Jinja2>=3.1.0", + "MarkupSafe>=3.0.0", + "python-gnupg>=0.3.7", + "pyyaml>=6.0.0", + "requests", + "SQLAlchemy==1.3.24", + "typing", + "Werkzeug>=3.1.0", + "WTForms>=3.2.0", +] + +[project.urls] +Homepage = "https://llvm.org" +Documentation = "https://llvm.org/docs/lnt" +Repository = "https://github.com/llvm/llvm-lnt" +"Bug Reports" = "https://github.com/llvm/llvm-lnt/issues" + +[project.scripts] +lnt = "lnt.lnttool:main" + +[project.optional-dependencies] +server = [ + "gunicorn>=19.9.0", + "psycopg2>=2.9.0", +] +dev = [ + "filecheck", + "Flake8-pyproject", + "flake8", + "lit", + "tox", +] + +[tool.setuptools] +ext-modules = [ + {name = "lnt.testing.profile.cPerf", sources = ["lnt/testing/profile/cPerf.cpp"]} +] + +[tool.setuptools.packages] +find = {namespaces = false} + +[tool.setuptools.package-data] +"lnt.server.ui" = [ + "static/*.ico", + "static/*.js", + "static/*.css", + "static/*.svg", + "static/bootstrap/css/*.css", + "static/bootstrap/js/*.js", + "static/bootstrap/img/*.png", + "static/flot/*.min.js", + "static/plotly/*.min.js", + "static/d3/*.min.js", + "static/jquery/**/*.min.js", + "templates/*.html", + "templates/reporting/*.html", + "templates/reporting/*.txt", +] +"lnt.server.db" = [ + "migrations/*.py" +] + +[tool.flake8] +ignore = ["E712", "E402", "E711", "E266", "W605", "E126", "E226", "W504"] +max-line-length = 120 +count = true + +[tool.mypy] +plugins = ["sqlmypy"] + +[tool.tox] +env_list = ["py3", "mypy", "flake8", "docs"] + +[tool.tox.env.py3] +description = "Run the unit tests" +allowlist_externals = ["rm", "lit"] +# TODO: Make it possible to run the tests without pinning down all dependencies +deps = [ + "-r requirements.txt", + ".[dev]", +] +commands = [ + ["rm", "-rf", "test_run_tmp"], + ["lit", "-sv", "tests"], +] + +[tool.tox.env.flake8] +description = "Run linter on the codebase" +deps = [".[dev]"] +commands = [["flake8", "--statistics", "--exclude=./lnt/external/", "./lnt/", "./tests/", "./deployment/"]] +skip_install = true + +[tool.tox.env.mypy] +description = "Typecheck the codebase" +# TODO: Make it possible to install [.dev] dependencies instead +deps = [ + "mypy >= 0.910", + "sqlalchemy-stubs", + "types-certifi", + "types-PyYAML", +] +# The option --no-incremental is currently needed to suppress warnings +# about UpdatedBase when running tests several times. Future versions of +# mypy should be checked to see if it can be removed and not get +# warnings after running tox several times. +commands = [["mypy", "--no-incremental", "--ignore-missing-imports", "lnt"]] +skip_install = true + +[tool.tox.env.docs] +description = "Build the documentation" +deps = [ + "sphinx==7", + "sphinx_bootstrap_theme", +] +allowlist_externals = ["make"] +commands = [["make", "-C", "{toxinidir}/docs/", "html"]] +skip_install = true diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index 56afb0b8..00000000 --- a/setup.cfg +++ /dev/null @@ -1,4 +0,0 @@ -[flake8] -ignore = E712,E402,E711, E266, W605, E126, E226, W504 -max-line-length = 120 -count = True \ No newline at end of file diff --git a/setup.py b/setup.py deleted file mode 100644 index 10288863..00000000 --- a/setup.py +++ /dev/null @@ -1,134 +0,0 @@ -import lnt -import os -from sys import platform as _platform -import sys -from setuptools import setup, find_packages, Extension - -if sys.version_info < (3, 10): - raise RuntimeError("Python 3.10 or higher required.") - -cflags = [] - -if _platform == "darwin": - os.environ["CC"] = "xcrun --sdk macosx clang" - os.environ["CXX"] = "xcrun --sdk macosx clang" - cflags += ['-stdlib=libc++', '-mmacosx-version-min=10.7'] - -cPerf = Extension('lnt.testing.profile.cPerf', - sources=['lnt/testing/profile/cPerf.cpp'], - extra_compile_args=['-std=c++11'] + cflags) - -if "--server" in sys.argv: - sys.argv.remove("--server") - print("Use pip to install requirements.server.txt for a full server install:") - print("pip install -r ./requirements.server.txt") - sys.exit(1) - - -setup( - name="LNT", - version=lnt.__version__, - - author=lnt.__author__, - author_email=lnt.__email__, - url='https://llvm.org', - license='Apache-2.0 with LLVM exception', - - description="LLVM Nightly Test Infrastructure", - keywords='web testing performance development llvm', - long_description="""\ -*LNT* -+++++ - -About -===== - -*LNT* is an infrastructure for performance testing. The software itself -consists of two main parts, a web application for accessing and visualizing -performance data, and command line utilities to allow users to generate and -submit test results to the server. - -The package was originally written for use in testing LLVM compiler -technologies, but is designed to be usable for the performance testing of any -software. - - -Documentation -============= - -The official *LNT* documentation is available online at: - https://llvm.org/docs/lnt - - -Source -====== - -The *LNT* source is available in the llvm-lnt repository: - https://github.com/llvm/llvm-lnt -""", - - classifiers=[ - 'Development Status :: 4 - Beta', - 'Environment :: Web Environment', - 'Intended Audience :: Developers', - 'License :: OSI Approved :: Apache-2.0 with LLVM exception', - 'Natural Language :: English', - 'Operating System :: OS Independent', - 'Programming Language :: Python :: 3.10', - 'Programming Language :: Python :: 3.11', - 'Programming Language :: Python :: 3.12', - 'Topic :: Software Development :: Quality Assurance', - 'Topic :: Software Development :: Testing', - ], - - zip_safe=False, - - # Additional resource extensions we use. - package_data={'lnt.server.ui': ['static/*.ico', - 'static/*.js', - 'static/*.css', - 'static/*.svg', - 'static/bootstrap/css/*.css', - 'static/bootstrap/js/*.js', - 'static/bootstrap/img/*.png', - 'static/flot/*.min.js', - 'static/plotly/*.min.js', - 'static/d3/*.min.js', - 'static/jquery/**/*.min.js', - 'templates/*.html', - 'templates/reporting/*.html', - 'templates/reporting/*.txt'], - 'lnt.server.db': ['migrations/*.py'], - }, - - packages=find_packages(), - - test_suite='tests.test_all', - - entry_points={ - 'console_scripts': [ - 'lnt = lnt.lnttool:main', - ], - }, - install_requires=[ - "aniso8601", - "certifi", - "click", - "Flask-RESTful", - "Flask-WTF", - "Flask", - "Jinja2", - "MarkupSafe", - "python-gnupg", - "pyyaml", - "requests", - "SQLAlchemy", - "typing", - "Werkzeug", - "WTForms", - ], - - ext_modules=[cPerf], - - python_requires='>=3.10', -) diff --git a/tox.ini b/tox.ini deleted file mode 100644 index daac030b..00000000 --- a/tox.ini +++ /dev/null @@ -1,63 +0,0 @@ -[tox] -envlist = py3 - mypy - flake8 - docs - -[testenv] -allowlist_externals = - rm - make - -commands = - rm -rf ./test_run_tmp - lit -sv ./tests/ - -[testenv:mypy] -basepython = python3 -skip_install = true -deps = - mypy >= 0.910 - sqlalchemy-stubs - types-PyYAML - types-certifi - -commands = - # The option --no-incremental is currently needed to suppress warnings - # about UpdatedBase when running tests several times. Future versions of - # mypy should be checked to see if it can be removed and not get - # warnings after running tox several times. - mypy --no-incremental --junit-xml=junit-{envname}.xml --ignore-missing-imports lnt - -[testenv:flake8] -skip_install = true -deps = - flake8 - -commands = - # Lets keep the clean files clean. - flake8 --statistics --exclude=./lnt/external/ ./lnt/ ./tests/ ./setup.py ./deployment/ - -[testenv:docs] -skip_install = true -deps = - sphinx==7 - sphinx_bootstrap_theme - -commands = - make -C {toxinidir}/docs/ html - -[testenv:py3] -deps = - -r requirements.txt - filecheck - lit - -[testenv:runserver] -# Don't use this for production. Just a handy target -# for local testing. -allowlist_externals = sh -commands = - sh -c "if [[ ! -e ./server_sandbox/ ]]; then lnt create ./server_sandbox/; fi" - - lnt runserver ./server_sandbox/ From 5a4964487834400ecb037c662540fb79b578448e Mon Sep 17 00:00:00 2001 From: Louis Dionne Date: Wed, 15 Oct 2025 08:28:34 -0400 Subject: [PATCH 2/3] Undo README changes --- README.md | 34 +++++++++++++++------------------- 1 file changed, 15 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index 71369c9b..dd56a3ea 100644 --- a/README.md +++ b/README.md @@ -1,28 +1,24 @@ -LNT: LLVM "Nightly Test" Infrastructure -======================================= +LLVM "Nightly Test" Infrastructure +================================== -About -===== +This directory and its subdirectories contain the LLVM nightly test +infrastructure. This is technically version "4.0" of the LLVM nightly test +architecture. -*LNT* is an infrastructure for performance testing. The software itself -consists of two main parts, a web application for accessing and visualizing -performance data, and command line utilities to allow users to generate and -submit test results to the server. +The infrastructure has the following layout: -The package was originally written for use in testing LLVM compiler -technologies, but is designed to be usable for the performance testing of any -software. + $ROOT/lnt - Top-level Python 'lnt' module + $ROOT/lnt/server/db - Database schema, utilities, and examples of the LNT plist format. -Documentation -============= + $ROOT/docs - Sphinx documentation for LNT. -The official *LNT* documentation is available online at: - https://llvm.org/docs/lnt + $ROOT/tests - Tests for the infrastructure. +For more information, see the web documentation, or docs/. -Source -====== +Testing +======= -The *LNT* source is available in the llvm-lnt repository: - https://github.com/llvm/llvm-lnt +Testing is done by running tox from the top-level directory. It runs the tests +for Python 3 and checks code style. From 0a92b62bf8dd557ce4c667d12f928acc77e65ea7 Mon Sep 17 00:00:00 2001 From: Louis Dionne Date: Wed, 15 Oct 2025 09:22:24 -0400 Subject: [PATCH 3/3] Fix casing for PyYAML --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 71085352..4a1f050a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -38,7 +38,7 @@ dependencies = [ "Jinja2>=3.1.0", "MarkupSafe>=3.0.0", "python-gnupg>=0.3.7", - "pyyaml>=6.0.0", + "PyYAML>=6.0.0", "requests", "SQLAlchemy==1.3.24", "typing",