pylibfdt: Use setuptools_scm for the version

The DTC version in version_gen.h causes a warning with setuptools:

setuptools/dist.py:501: UserWarning: The version specified ('1.6.1-g5454474d') \
is an invalid version, this may not work as expected with newer versions of \
setuptools, pip, and PyPI. Please see PEP 440 for more details.

It also creates an unnecessary dependency on the rest of the build
system(s). Switch to use setuptools_scm instead to get the version for
pylibfdt.

Signed-off-by: Rob Herring <robh@kernel.org>
Message-Id: <20211111011135.2386773-3-robh@kernel.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
This commit is contained in:
Rob Herring 2021-11-10 19:11:33 -06:00 committed by David Gibson
parent c691776ddb
commit 0b106a77db
3 changed files with 5 additions and 16 deletions

View file

@ -16,7 +16,7 @@ ifndef V
SETUPFLAGS += --quiet SETUPFLAGS += --quiet
endif endif
$(PYMODULE): $(PYLIBFDT_srcs) $(LIBFDT_archive) $(SETUP) $(VERSION_FILE) $(PYMODULE): $(PYLIBFDT_srcs) $(LIBFDT_archive) $(SETUP)
@$(VECHO) PYMOD $@ @$(VECHO) PYMOD $@
$(PYTHON) $(SETUP) $(SETUPFLAGS) build_ext --build-lib=$(PYLIBFDT_dir) $(PYTHON) $(SETUP) $(SETUPFLAGS) build_ext --build-lib=$(PYLIBFDT_dir)

View file

@ -5,7 +5,6 @@ custom_target(
'pylibfdt', 'pylibfdt',
input: 'libfdt.i', input: 'libfdt.i',
output: '_libfdt.so', output: '_libfdt.so',
depends: version_gen_h,
command: [setup_py, 'build_ext', '--build-lib=' + meson.current_build_dir()], command: [setup_py, 'build_ext', '--build-lib=' + meson.current_build_dir()],
build_by_default: true, build_by_default: true,
) )

View file

@ -15,10 +15,6 @@ import os
import re import re
import sys import sys
VERSION_PATTERN = '^#define DTC_VERSION "DTC ([^"]*)"$'
def get_top_builddir(): def get_top_builddir():
if '--top-builddir' in sys.argv: if '--top-builddir' in sys.argv:
index = sys.argv.index('--top-builddir') index = sys.argv.index('--top-builddir')
@ -27,18 +23,9 @@ def get_top_builddir():
else: else:
return os.getcwd() return os.getcwd()
srcdir = os.path.dirname(os.path.abspath(sys.argv[0])) srcdir = os.path.dirname(os.path.abspath(sys.argv[0]))
top_builddir = get_top_builddir() top_builddir = get_top_builddir()
def get_version():
version_file = os.path.join(top_builddir, 'version_gen.h')
f = open(version_file, 'rt')
m = re.match(VERSION_PATTERN, f.readline())
return m.group(1)
libfdt_module = Extension( libfdt_module = Extension(
'_libfdt', '_libfdt',
sources=[os.path.join(srcdir, 'libfdt.i')], sources=[os.path.join(srcdir, 'libfdt.i')],
@ -50,7 +37,10 @@ libfdt_module = Extension(
setup( setup(
name='libfdt', name='libfdt',
version=get_version(), use_scm_version={
"root": os.path.join(srcdir, '..'),
},
setup_requires = ['setuptools_scm'],
author='Simon Glass <sjg@chromium.org>', author='Simon Glass <sjg@chromium.org>',
description='Python binding for libfdt', description='Python binding for libfdt',
ext_modules=[libfdt_module], ext_modules=[libfdt_module],