4.5.4. Python 程序示例的 spec 文件示例
您可以对使用 Python 编程语言编写的 pello 程序使用以下示例 spec 文件作为参考。
使用 Python 编写的 pello 程序的 spec 文件示例
Name: pello
Version: 0.1.1
Release: 1%{?dist}
Summary: Hello World example implemented in Python
License: GPLv3+
URL: https://www.example.com/%{name}
Source0: https://www.example.com/%{name}/releases/%{name}-%{version}.tar.gz
BuildRequires: python
Requires: python
Requires: bash
BuildArch: noarch
%description
The long-tail description for our Hello World Example implemented in Python.
%prep
%setup -q
%build
python -m compileall %{name}.py
%install
mkdir -p %{buildroot}/%{_bindir}
mkdir -p %{buildroot}/usr/lib/%{name}
cat > %{buildroot}/%{_bindir}/%{name} <<EOF
#!/bin/bash
/usr/bin/python /usr/lib/%{name}/%{name}.pyc
EOF
chmod 0755 %{buildroot}/%{_bindir}/%{name}
install -m 0644 %{name}.py* %{buildroot}/usr/lib/%{name}/
%files
%license LICENSE
%dir /usr/lib/%{name}/
%{_bindir}/%{name}
/usr/lib/%{name}/%{name}.py*
%changelog
* Tue May 31 2016 Adam Miller <maxamillion@fedoraproject.org> - 0.1.1-1
- First pello package
Requires指令指定软件包的运行时依赖项,其中包括两个软件包:-
python软件包需要在运行时执行字节编译的代码。 -
bash软件包需要执行小入口点脚本。
-
-
BuildRequires指令指定软件包的 build-time 依赖项,它只包括python软件包。pello程序需要python来执行字节编译构建过程。 -
%build部分指定如何构建软件,创建脚本的字节编译版本。请注意,在实际打包中,它通常会根据所使用的发行版自动完成。 -
%install部分对应于这样的事实,即您必须将字节文件安装到系统上的库目录中,以便可以访问它。
在 spec 文件中内联创建包装程序脚本的示例表明 spec 文件本身是可以写成脚本的。此打包程序脚本使用 此文档 执行 Python 字节编译的代码。