%global _name vllm
%global _description A high-throughput and memory-efficient inference and serving engine for LLMs

Name:       vllm
Version:    0.6.6.post1
Release:    2
Summary:    Powerful engine for LLMs
License:    (Apache-2.0 AND BSD-3-Clause) OR BSD-3-CLause
URL:        https://github.com/vllm-project/vllm
Source0:    https://gitee.com/src-openeuler/vllm/raw/master/vllm-%{version}.tar.gz

BuildArch:  noarch

%description
%{_description}

%package -n python3-%{_name}
Summary:    %{summary}
Buildrequires:  cmake python3-pip python3-devel python3-setuptools python3-pytest
Buildrequires:  python3-setuptools_scm python3-wheel python3-grpcio
Buildrequires:  python3-pytorch
%{?python_provide:%python_provide python3-%{_name}}

%description -n python3-%{_name}
%{_description}

%package_help

%prep
%autosetup -n %{name}-%{version} -N

%build
export SETUPTOOLS_SCM_PRETEND_VERSION=%{version}
export VLLM_TARGET_DEVICE=empty
%py3_build

%install
export SETUPTOOLS_SCM_PRETEND_VERSION=%{version}
export VLLM_TARGET_DEVICE=empty
%py3_install

VERSION_FILE=$(find %{buildroot} -name '_version.py')
if [ -f "$VERSION_FILE" ]; then
    sed -i 's/^version = /__version__ = /g' "$VERSION_FILE"
    sed -i 's/^version_tuple = /__version_tuple__ = /g' "$VERSION_FILE"
fi

pushd %{buildroot}
if [ -d usr/lib ]; then
	find usr/lib -type f -printf "/%h/%f\n" >> filelist.lst
fi
if [ -d usr/lib64 ]; then
	find usr/lib64 -type f -printf "/%h/%f\n" >> filelist.lst
fi
if [ -d usr/bin ]; then
	find usr/bin -type f -printf "/%h/%f\n" >> filelist.lst
fi
if [ -d usr/sbin ]; then
	find usr/sbin -type f -printf "/%h/%f\n" >> filelist.lst
fi
if [ -d usr/share/man ]; then
	find usr/share/man -type f -printf "/%h/%f.gz\n" >> doclist.lst
fi
popd
mv %{buildroot}/filelist.lst .

%check

%files -n python3-%{_name} -f filelist.lst

%changelog
* Thu Mar 27 2025 renwenjie<renwenjie5@huawei.com> - 0.6.6.post1-2
- solve 'no module named vllm._version' problem and adapted for openeuler22.03

* Fri Feb 28 2025 renwenjie<renwenjie5@huawei.com> - 0.6.6.post1-1
- Package init
