mirror of
https://github.com/kdave/btrfs-progs
synced 2025-02-21 12:26:51 +00:00
libbtrfsutil: python: use version from primary VERSION file
The version file of the python subpackage had to have the version set manually in setup.py due to the out-of-tree build where it was not possible to access the file VERSION. Manual update was error prone. Improve that by adding a separate file template that is finalized with the version during the configure phase. Then it's inclded in setup.py as it's in the same directory. There are two exceptions when the file is not required to run setup.py: - clean - allow running 'make clean' in partially configured directory - (no arguments) - show the help and commands In all other cases the file version.py must exist. Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
parent
6cf93a2504
commit
83bd999c3e
1
Makefile
1
Makefile
@ -953,6 +953,7 @@ clean-gen:
|
||||
configure.lineno config.status.lineno Makefile.inc \
|
||||
Documentation/Makefile tags TAGS \
|
||||
libbtrfsutil/libbtrfsutil.pc \
|
||||
libbtrfsutil/python/version.py \
|
||||
cscope.files cscope.out cscope.in.out cscope.po.out \
|
||||
config.log include/config.h include/config.h.in~ aclocal.m4 \
|
||||
configure configure~ autom4te.cache/
|
||||
|
@ -558,6 +558,7 @@ Makefile.inc
|
||||
Documentation/Makefile
|
||||
libbtrfs/version.h
|
||||
libbtrfsutil/libbtrfsutil.pc
|
||||
libbtrfsutil/python/version.py
|
||||
])
|
||||
|
||||
AC_OUTPUT
|
||||
|
1
libbtrfsutil/python/.gitignore
vendored
1
libbtrfsutil/python/.gitignore
vendored
@ -5,3 +5,4 @@ __pycache__
|
||||
/build
|
||||
/constants.c
|
||||
/dist
|
||||
/version.py
|
||||
|
@ -20,16 +20,24 @@
|
||||
import re
|
||||
import os
|
||||
import os.path
|
||||
import sys
|
||||
from setuptools import setup, Extension
|
||||
from setuptools.command.build_ext import build_ext
|
||||
import subprocess
|
||||
|
||||
|
||||
def get_version():
|
||||
f = open('../../VERSION', 'r')
|
||||
version = f.readline().strip()
|
||||
f.close()
|
||||
return ".".join(version[1:].split('.'))
|
||||
version = 0
|
||||
try:
|
||||
import version
|
||||
version = version.btrfs_util_py_version
|
||||
except:
|
||||
# Don't fail if this is only the 'clean' target or no command
|
||||
if 'clean' in sys.argv or len(sys.argv) == 1:
|
||||
version = '0.0'
|
||||
else:
|
||||
raise Exception("No generated version.py found, please configure")
|
||||
return version
|
||||
|
||||
|
||||
def out_of_date(dependencies, target):
|
||||
@ -104,9 +112,7 @@ module = Extension(
|
||||
|
||||
setup(
|
||||
name='btrfsutil',
|
||||
# FIXME: version file is not present when building outside of git
|
||||
#version=get_version(),
|
||||
version='6.12',
|
||||
version=get_version(),
|
||||
description='Library for managing Btrfs filesystems',
|
||||
long_description=open('README.md').read(),
|
||||
long_description_content_type='text/markdown',
|
||||
|
18
libbtrfsutil/python/version.py.in
Normal file
18
libbtrfsutil/python/version.py.in
Normal file
@ -0,0 +1,18 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# This file is part of libbtrfsutil.
|
||||
#
|
||||
# libbtrfsutil is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Lesser General Public License as published by
|
||||
# the Free Software Foundation, either version 2.1 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# libbtrfsutil is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Lesser General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public License
|
||||
# along with libbtrfsutil. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
btrfs_util_py_version = '@BTRFS_VERSION_PLAIN@'
|
Loading…
Reference in New Issue
Block a user