Skip to content

Commit 656dbfa

Browse files
committed
Document and add a job to build and publish a PyPI package
The job will build the Python package on every PR and every push, but will only publish it to the official PyPI repository when we push a new tag. Fixes #84
1 parent 375cfcc commit 656dbfa

File tree

4 files changed

+95
-16
lines changed

4 files changed

+95
-16
lines changed
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
name: Build and publish Python distribution package to PyPI and TestPyPI
2+
3+
on:
4+
- push
5+
- pull_request
6+
7+
jobs:
8+
build:
9+
runs-on: ubuntu-latest
10+
name: Build LNT distribution package
11+
steps:
12+
- uses: actions/checkout@v5
13+
with:
14+
persist-credentials: false
15+
- name: Set up Python
16+
uses: actions/setup-python@v5
17+
with:
18+
python-version: "3.10"
19+
- name: Build the source tarball
20+
run: |
21+
python -m pip install build
22+
python -m build
23+
- name: Store the distribution packages
24+
uses: actions/upload-artifact@v4
25+
with:
26+
name: python-package-distributions
27+
path: dist/
28+
29+
30+
publish-to-testpypi:
31+
runs-on: ubuntu-latest
32+
name: Publish LNT package to TestPyPI
33+
needs: [build]
34+
environment:
35+
name: testpypi
36+
url: https://test.pypi.org/p/llvm-lnt
37+
permissions:
38+
id-token: write
39+
40+
steps:
41+
- name: Download distributions
42+
uses: actions/download-artifact@v4
43+
with:
44+
name: python-package-distributions
45+
path: dist/
46+
- name: Publish LNT to TestPyPI
47+
uses: pypa/gh-action-pypi-publish@release/v1
48+
with:
49+
repository-url: https://test.pypi.org/legacy/
50+
51+
52+
publish-to-pypi:
53+
runs-on: ubuntu-latest
54+
name: Publish LNT package to PyPI
55+
if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes
56+
needs: [build]
57+
environment:
58+
name: pypi
59+
url: https://pypi.org/p/llvm-lnt
60+
permissions:
61+
id-token: write
62+
63+
steps:
64+
- name: Download distributions
65+
uses: actions/download-artifact@v4
66+
with:
67+
name: python-package-distributions
68+
path: dist/
69+
- name: Publish LNT to PyPI
70+
uses: pypa/gh-action-pypi-publish@release/v1

docs/developer_guide.rst

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,3 +72,18 @@ default. You can enable them by passing additional flags to lit:
7272
Example::
7373

7474
lit -sv -Dpostgres=1 -Dmysql=1 -Dtidylib=1 ./tests
75+
76+
Publishing a new version of LNT
77+
-------------------------------
78+
79+
We publish a new version of the LNT package on a regular basis. This is done automatically via a Github
80+
Action whenever a commit is tagged. However, publishing can also be done manually. To do so, make sure you
81+
install the development dependencies, and then run the following commands from the virtual environment::
82+
83+
rm -rf dist
84+
python -m build
85+
python -m twine upload --repository testpypi dist/*
86+
87+
This requires setting up the right API token, see `the official documentation <https://packaging.python.org/en/latest/tutorials/packaging-projects/#uploading-the-distribution-archives>`_
88+
for details. You can replace ``--repository testpypi`` with ``--repository pypi`` once you are actually ready
89+
to publish the package.

docs/quickstart.rst

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,25 +9,17 @@ interested in using LNT to test compilers using the LLVM test-suite.
99
Installation
1010
------------
1111

12-
The first thing to do is to checkout install the LNT software itself. The
13-
following steps should suffice on any modern Unix variant:
12+
You can install the latest stable release of LNT from PyPI. We recommend doing
13+
that from a virtual environment::
1414

15-
#. Checkout the LNT sources::
15+
python3 -m venv .venv
16+
source .venv/bin/activate
17+
pip install llvm-lnt
1618

17-
git clone https://github.com/llvm/llvm-lnt.git ~/lnt
19+
This will install the client-side tools. If you also want to run a production
20+
server, you should instead include the server-side optional requirements::
1821

19-
#. Create a new virtual environment for the LNT application and activate it::
20-
21-
python3 -m venv .venv
22-
source .venv/bin/activate
23-
24-
#. Install LNT into the virtual environment::
25-
26-
pip install -r requirements.txt
27-
28-
Note that if you only want to use the client-side features of ``lnt``, you can
29-
install the requirements specified in ``requirements.client.txt`` instead, which
30-
are a bit more lightweight.
22+
pip install "llvm-lnt[server]"
3123

3224
That's it! ``lnt`` should now be accessible from the virtual environment.
3325

pyproject.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,13 @@ server = [
6060
"psycopg2>=2.9.0",
6161
]
6262
dev = [
63+
"build",
6364
"filecheck",
6465
"Flake8-pyproject",
6566
"flake8",
6667
"lit",
6768
"tox",
69+
"twine",
6870
]
6971

7072
[tool.setuptools]

0 commit comments

Comments
 (0)