build: add tools/make-wheel

This is the entrypoint for building a wheel from the current checked out
source tree.  It makes sure systemd_ctypes is available.

This is intended to be used as an API from various subprojects that want
to test against the Python bridge.
This commit is contained in:
Allison Karlitskaya 2023-01-30 16:54:11 +01:00
parent 176b81fda8
commit 90a489fc5b
2 changed files with 11 additions and 9 deletions

View File

@ -19,7 +19,6 @@
# along with Cockpit; If not, see <http://www.gnu.org/licenses/>.
import argparse
import glob
import os
import shlex
import shutil
@ -199,14 +198,8 @@ def validate_packages():
def install_python_bridge():
subprocess.run([f'{BASE_DIR}/tools/systemd_ctypes'], check=True)
shutil.rmtree('tmp/wheel', ignore_errors=True)
subprocess.run([sys.executable, '-m', 'build', '--no-isolation', '--wheel', '--outdir', 'tmp/wheel'], check=True)
wheels = glob.glob('tmp/wheel/*.whl')
assert len(wheels) == 1
return ['--install', *wheels]
wheel = subprocess.check_output([f'{BASE_DIR}/tools/make-wheel'], universal_newlines=True)
return ['--install', wheel.strip()]
def main():

9
tools/make-wheel Executable file
View File

@ -0,0 +1,9 @@
#!/bin/sh
set -eu
cd "$(realpath -m "$0"/../..)"
tools/systemd_ctypes
rm -rf tmp/wheel build
python3 -m build --no-isolation --wheel --outdir tmp/wheel . >&2
realpath tmp/wheel/*.whl