[PATCH] D136976: [lit] Add pyproject.toml and fix build w/ modern setuptools backend

Michał Górny via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 28 13:26:09 PDT 2022


mgorny created this revision.
mgorny added reviewers: ddunbar, yln, jdenny, rnk, zturner.
Herald added a subscriber: delcypher.
Herald added a project: All.
mgorny requested review of this revision.
Herald added a project: LLVM.

Add a `pyproject.toml` file that provides build system information
for PEP 517-compliant builders.  While all the commonly used builders
provide fallback to running `setup.py` for backwards compatibility, this
ensures the best forward compatibility.  It also provides a reliable way
of specifying the minimum required setuptools version.  Effectively, it
will make it possible to remove `setup.py` in favor of purely
declarative configuration in the future, or even switch to a different
build system.

Update `setup.py` to explicitly add the current directory to `sys.path`
for importing `lit`.  This is necessary, as the modern setuptools
backend does not guarantee that the current directory is present there.


https://reviews.llvm.org/D136976

Files:
  llvm/utils/lit/pyproject.toml
  llvm/utils/lit/setup.py


Index: llvm/utils/lit/setup.py
===================================================================
--- llvm/utils/lit/setup.py
+++ llvm/utils/lit/setup.py
@@ -1,5 +1,5 @@
-import lit
 import os
+import sys
 
 from setuptools import setup, find_packages
 
@@ -8,6 +8,9 @@
 #   python path/to/setup.py install
 # to work (for scripts, etc.)
 os.chdir(os.path.dirname(os.path.abspath(__file__)))
+sys.path.insert(0, ".")
+
+import lit
 
 setup(
     name = "lit",
Index: llvm/utils/lit/pyproject.toml
===================================================================
--- /dev/null
+++ llvm/utils/lit/pyproject.toml
@@ -0,0 +1,3 @@
+[build-system]
+requires = ["setuptools"]
+build-backend = "setuptools.build_meta"


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D136976.471637.patch
Type: text/x-patch
Size: 714 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221028/5f911f75/attachment.bin>


More information about the llvm-commits mailing list