Commit 508531e1 authored by Konrad Sztyber's avatar Konrad Sztyber Committed by Jim Harris
Browse files

python: add setup script



It allows people to install our python scripts as a regular python
package via pip.  For now the script is very basic, but we can extend it
in the future (e.g. list dependencies).

Also, python uses a different version format than we do (see PEP 440),
so the version reported by the python scripts will be a little
different: the leading zero in the minor part is removed and "-pre" is
replaced with "rc0".  For instance, "23.05-pre" will be reported as
"23.5rc0".

Additionally, a simple test was added that will make sure that the
version in the scripts is consistent with the version in the .c code.

Fixes #2997.

Signed-off-by: default avatarKonrad Sztyber <konrad.sztyber@intel.com>
Change-Id: I86b70adb121bf824ccabb6968103b7f6ffc3150d
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/17935


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
Reviewed-by: default avatarMichal Berger <michal.berger@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
parent b419ad2c
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -170,6 +170,7 @@ if [ $SPDK_RUN_FUNCTIONAL_TEST -eq 1 ]; then
	run_test "thread" $rootdir/test/thread/thread.sh
	run_test "accel" $rootdir/test/accel/accel.sh
	run_test "app_cmdline" $rootdir/test/app/cmdline.sh
	run_test "version" $rootdir/test/app/version.sh

	if [ $SPDK_TEST_BLOCKDEV -eq 1 ]; then
		run_test "blockdev_general" $rootdir/test/bdev/blockdev.sh

python/setup.py

0 → 100755
+10 −0
Original line number Diff line number Diff line
#!/usr/bin/env python3
# SPDX-License-Identifier: BSD-3-Clause
# Copyright (C) 2023 Intel Corporation.  All rights reserved.

from distutils.core import setup
from setuptools import find_packages
from spdk import __version__


setup(name='spdk', version=__version__, packages=find_packages())
+2 −0
Original line number Diff line number Diff line
#  SPDX-License-Identifier: BSD-3-Clause
#  Copyright (C) 2021 Intel Corporation.
#  All rights reserved.

__version__ = "23.5rc0"

test/app/version.sh

0 → 100755
+31 −0
Original line number Diff line number Diff line
#!/usr/bin/env bash
# SPDX-License-Identifier: BSD-3-Clause
# Copyright (C) 2023 Intel Corporation
# All rights reserved.
#

testdir=$(readlink -f $(dirname $0))
rootdir=$(readlink -f $testdir/../..)

source "$rootdir/test/common/autotest_common.sh"

get_header_version() {
	grep -E "^#define SPDK_VERSION_${1^^}[[:space:]]+" "$rootdir/include/spdk/version.h" \
		| cut -f2 | tr -d \"
}

major=$(get_header_version major)
minor=$(get_header_version minor)
patch=$(get_header_version patch)
suffix=$(get_header_version suffix)

version="${major}.${minor}"

# If patch is zero, we don't keep it in the version
((patch != 0)) && version="${version}.${patch}"
# In python world, the version format is a little different than what we use (see PEP 440), so we
# need to replace "-pre" with "rc0"
version="${version}${suffix/-pre/rc0}"

PYTHONPATH="$PYTHONPATH:$rootdir/python" py_version=$(python3 -c 'import spdk; print(spdk.__version__)')
[[ "$py_version" == "$version" ]]