Skip to content

Commit f0800db

Browse files
authored
Rewrite project build and metadata using pyproject.toml (#88)
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
1 parent 309e185 commit f0800db

File tree

7 files changed

+158
-214
lines changed

7 files changed

+158
-214
lines changed

Dockerfile

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,14 @@ RUN apk update \
44
&& apk add --no-cache --virtual .build-deps git g++ postgresql-dev yaml-dev \
55
&& apk add --no-cache libpq
66

7-
WORKDIR /var/src/lnt
7+
COPY . /var/src/lnt
88

9-
COPY requirements*.txt setup.py .
10-
# setup.py uses lnt.__version__ etc.
11-
COPY lnt/__init__.py lnt/__init__.py
12-
# we build the cperf extension during install
13-
COPY lnt/testing/profile lnt/testing/profile
9+
WORKDIR /var/src/lnt
1410

1511
RUN pip3 install -r requirements.server.txt \
1612
&& apk --purge del .build-deps \
1713
&& mkdir /var/log/lnt
1814

19-
COPY . .
2015
COPY docker/docker-entrypoint.sh docker/wait_db /usr/local/bin/
2116

2217
VOLUME /var/log

docs/developer_guide.rst

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,8 @@ To run the tests, we recomment using ``tox`` in a virtual environment::
3434

3535
You can also run individual unit tests with ``lit`` directly::
3636

37-
pip install lit
38-
lit -sv ./tests
39-
40-
However, that requires manually setting up the testing environment (``filecheck``, etc).
37+
pip install ".[dev]"
38+
lit -sv tests
4139

4240
For simple changes, adding a regression test and making sure all regression
4341
tests pass, is often a good enough testing approach. For some changes, the

mypy.ini

Lines changed: 0 additions & 2 deletions
This file was deleted.

pyproject.toml

Lines changed: 154 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,154 @@
1+
[build-system]
2+
requires = ["setuptools >= 74.1"]
3+
build-backend = "setuptools.build_meta"
4+
5+
[project]
6+
name = "LNT"
7+
version = "0.4.2.dev0"
8+
description = "LLVM Nightly Test Infrastructure"
9+
readme = "README.md"
10+
license = "LicenseRef-Apache-2.0-with-LLVM-exception"
11+
license-files = ["LICENSE.TXT"]
12+
authors = [
13+
{ name = "Daniel Dunbar", email = "[email protected]" },
14+
]
15+
maintainers = []
16+
keywords = ["web", "testing", "performance", "development", "llvm"]
17+
classifiers = [
18+
"Development Status :: 4 - Beta",
19+
"Environment :: Web Environment",
20+
"Intended Audience :: Developers",
21+
"Natural Language :: English",
22+
"Operating System :: OS Independent",
23+
"Programming Language :: Python :: 3",
24+
"Programming Language :: Python :: 3.10",
25+
"Programming Language :: Python :: 3.11",
26+
"Programming Language :: Python :: 3.12",
27+
"Topic :: Software Development :: Quality Assurance",
28+
"Topic :: Software Development :: Testing",
29+
]
30+
requires-python = ">=3.10"
31+
dependencies = [
32+
"aniso8601>=1.2.0",
33+
"certifi",
34+
"click>=8.1.0",
35+
"Flask-RESTful>=0.3.10",
36+
"Flask-WTF>=1.2.0",
37+
"Flask>=3.1.0",
38+
"Jinja2>=3.1.0",
39+
"MarkupSafe>=3.0.0",
40+
"python-gnupg>=0.3.7",
41+
"PyYAML>=6.0.0",
42+
"requests",
43+
"SQLAlchemy==1.3.24",
44+
"typing",
45+
"Werkzeug>=3.1.0",
46+
"WTForms>=3.2.0",
47+
]
48+
49+
[project.urls]
50+
Homepage = "https://llvm.org"
51+
Documentation = "https://llvm.org/docs/lnt"
52+
Repository = "https://github.com/llvm/llvm-lnt"
53+
"Bug Reports" = "https://github.com/llvm/llvm-lnt/issues"
54+
55+
[project.scripts]
56+
lnt = "lnt.lnttool:main"
57+
58+
[project.optional-dependencies]
59+
server = [
60+
"gunicorn>=19.9.0",
61+
"psycopg2>=2.9.0",
62+
]
63+
dev = [
64+
"filecheck",
65+
"Flake8-pyproject",
66+
"flake8",
67+
"lit",
68+
"tox",
69+
]
70+
71+
[tool.setuptools]
72+
ext-modules = [
73+
{name = "lnt.testing.profile.cPerf", sources = ["lnt/testing/profile/cPerf.cpp"]}
74+
]
75+
76+
[tool.setuptools.packages]
77+
find = {namespaces = false}
78+
79+
[tool.setuptools.package-data]
80+
"lnt.server.ui" = [
81+
"static/*.ico",
82+
"static/*.js",
83+
"static/*.css",
84+
"static/*.svg",
85+
"static/bootstrap/css/*.css",
86+
"static/bootstrap/js/*.js",
87+
"static/bootstrap/img/*.png",
88+
"static/flot/*.min.js",
89+
"static/plotly/*.min.js",
90+
"static/d3/*.min.js",
91+
"static/jquery/**/*.min.js",
92+
"templates/*.html",
93+
"templates/reporting/*.html",
94+
"templates/reporting/*.txt",
95+
]
96+
"lnt.server.db" = [
97+
"migrations/*.py"
98+
]
99+
100+
[tool.flake8]
101+
ignore = ["E712", "E402", "E711", "E266", "W605", "E126", "E226", "W504"]
102+
max-line-length = 120
103+
count = true
104+
105+
[tool.mypy]
106+
plugins = ["sqlmypy"]
107+
108+
[tool.tox]
109+
env_list = ["py3", "mypy", "flake8", "docs"]
110+
111+
[tool.tox.env.py3]
112+
description = "Run the unit tests"
113+
allowlist_externals = ["rm", "lit"]
114+
# TODO: Make it possible to run the tests without pinning down all dependencies
115+
deps = [
116+
"-r requirements.txt",
117+
".[dev]",
118+
]
119+
commands = [
120+
["rm", "-rf", "test_run_tmp"],
121+
["lit", "-sv", "tests"],
122+
]
123+
124+
[tool.tox.env.flake8]
125+
description = "Run linter on the codebase"
126+
deps = [".[dev]"]
127+
commands = [["flake8", "--statistics", "--exclude=./lnt/external/", "./lnt/", "./tests/", "./deployment/"]]
128+
skip_install = true
129+
130+
[tool.tox.env.mypy]
131+
description = "Typecheck the codebase"
132+
# TODO: Make it possible to install [.dev] dependencies instead
133+
deps = [
134+
"mypy >= 0.910",
135+
"sqlalchemy-stubs",
136+
"types-certifi",
137+
"types-PyYAML",
138+
]
139+
# The option --no-incremental is currently needed to suppress warnings
140+
# about UpdatedBase when running tests several times. Future versions of
141+
# mypy should be checked to see if it can be removed and not get
142+
# warnings after running tox several times.
143+
commands = [["mypy", "--no-incremental", "--ignore-missing-imports", "lnt"]]
144+
skip_install = true
145+
146+
[tool.tox.env.docs]
147+
description = "Build the documentation"
148+
deps = [
149+
"sphinx==7",
150+
"sphinx_bootstrap_theme",
151+
]
152+
allowlist_externals = ["make"]
153+
commands = [["make", "-C", "{toxinidir}/docs/", "html"]]
154+
skip_install = true

setup.cfg

Lines changed: 0 additions & 4 deletions
This file was deleted.

setup.py

Lines changed: 0 additions & 134 deletions
This file was deleted.

tox.ini

Lines changed: 0 additions & 63 deletions
This file was deleted.

0 commit comments

Comments
 (0)