summaryrefslogtreecommitdiff
path: root/packaging/builddist.py
blob: 5cf3b02a79beb133d29a64be983881404e9f0e95 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/usr/bin/env python3

# SPDX-License-Identifier: Apache-2.0
# Copyright 2025 The Meson development team

# This script must be run from the source root.

import pathlib, shutil, subprocess

gendir = pathlib.Path('distgendir')
distdir = pathlib.Path('dist')
gitdir = pathlib.Path('.git')

if distdir.is_dir():
    shutil.rmtree(distdir)
distdir.mkdir()

if gendir.is_dir():
    shutil.rmtree(gendir)
gendir.mkdir()

shutil.copytree(gitdir, gendir / '.git')

subprocess.check_call(['git', 'reset', '--hard'],
                      cwd=gendir)
subprocess.check_call(['python3', 'setup.py', 'sdist', 'bdist_wheel'],
                       cwd=gendir)
for f in (gendir / 'dist').glob('*'):
    shutil.copy(f, distdir)

shutil.rmtree(gendir)