[llvm] 7b4b150 - [lit] Add pyproject.toml and fix build w/ modern setuptools backend

Michał Górny via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 31 23:30:22 PDT 2022


Author: Michał Górny
Date: 2022-11-01T07:30:14+01:00
New Revision: 7b4b15042d2b9f513dc23a951e4a6e92492894e3

URL: https://github.com/llvm/llvm-project/commit/7b4b15042d2b9f513dc23a951e4a6e92492894e3
DIFF: https://github.com/llvm/llvm-project/commit/7b4b15042d2b9f513dc23a951e4a6e92492894e3.diff

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

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.

Differential Revision: https://reviews.llvm.org/D136976

Added: 
    llvm/utils/lit/pyproject.toml

Modified: 
    llvm/utils/lit/setup.py

Removed: 
    


################################################################################
diff  --git a/llvm/utils/lit/pyproject.toml b/llvm/utils/lit/pyproject.toml
new file mode 100644
index 0000000000000..fed528d4a7a14
--- /dev/null
+++ b/llvm/utils/lit/pyproject.toml
@@ -0,0 +1,3 @@
+[build-system]
+requires = ["setuptools"]
+build-backend = "setuptools.build_meta"

diff  --git a/llvm/utils/lit/setup.py b/llvm/utils/lit/setup.py
index 948c671a33a88..69a38edef83d6 100644
--- a/llvm/utils/lit/setup.py
+++ b/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
 
 with open("README.rst", "r", encoding="utf-8") as f:
     long_description = f.read()


        


More information about the llvm-commits mailing list