libbtrfsutil: update python setup.py for distribution

Fixes so 'python3 -m build' works and package can be uploaded to pypi
(https://pypi.org/project/btrfsutil/).

- setup.py is still used for local build (make)
- for pypi it must be done by 'python3 -m build' that is build in a
  temporary directory
- btrfsutilpy.h must be also distributed
- version is set manually (the git VERSION file is not accessible)
- the project page metadata is empty, the README.md should be added

Issue: #310
Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
David Sterba 2024-07-31 01:37:35 +02:00
parent 0cac9acfc6
commit 87c3fb557e
1 changed files with 12 additions and 2 deletions

View File

@ -70,7 +70,12 @@ void add_module_constants(PyObject *m)
class my_build_ext(build_ext):
def run(self):
if out_of_date(['../btrfsutil.h'], 'constants.c'):
# Running dist outside of git
if not os.path.exists('../btrfsutil.h'):
# But no generated constants.c found
if not os.path.exists('constants.c'):
raise Exception("No generated constants.c found, please fix")
elif out_of_date(['../btrfsutil.h'], 'constants.c'):
try:
gen_constants()
except Exception as e:
@ -92,6 +97,9 @@ module = Extension(
'qgroup.c',
'subvolume.c',
],
headers=[
'btrfsutilpy.h'
],
include_dirs=['..'],
library_dirs=['../..'],
libraries=['btrfsutil'],
@ -99,7 +107,9 @@ module = Extension(
setup(
name='btrfsutil',
version=get_version(),
# FIXME: version file is not present when building outside of git
#version=get_version(),
version='6.10',
description='Library for managing Btrfs filesystems',
url='https://github.com/kdave/btrfs-progs',
license='LGPLv2+',