python 2.7 自定义 RPM 编译[备忘]

要求

把 python 2.7 进行编译

安装目标位置

可执行文件位置   /apps/svr/python27

其他库文件, 头文件, doc 安装位置  /apps/lib/python27

对应源码 python-2.7.5.tar.gz

 

参见  python-2.7_centOS5.8.spec 文件

%define _topdir %(echo `cd ..; pwd`)
%define binsuffix 27
%define pybasever 2.7
%define version 2.7.5
%define name python
%define release 20140124vipclound.centOS58
############# edit by terry ############
%define _prefix                 /apps
%define _exec-prefix            /apps
%define _bindir                 /apps/svr/python27
%define _sbindir                /apps/svr/python27
%define _sysconfdir             /apps/conf
%define _includedir             /apps/lib
%define _libexecdir             /apps/lib
%define _infodir                /apps/lib
%define _oldincludedir          /apps/lib
%define _libdir                 /apps/lib
%define _defaultdocdir          /apps/lib

%define config_include_docs no

############# edit by terry ############

Name: %{name}%{binsuffix}
Version: %{version}
Release: 20140121.vipclound.el5
Summary: An interpreted, interactive, object-oriented programming language.
Group: Development/Languages
Source0: http://www.python.org/ftp/python/%{version}/Python-%{version}.tar.bz2

License: PSF
BuildRoot: %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX)

AutoReq: no
Provides: python(abi) = %{pybasever}

BuildRequires: autoconf
BuildRequires: bzip2
BuildRequires: bzip2-devel
BuildRequires: db4-devel
BuildRequires: expat-devel
BuildRequires: findutils
BuildRequires: gcc-c++
BuildRequires: glibc-devel
BuildRequires: make
BuildRequires: openssl-devel
BuildRequires: pkgconfig
BuildRequires: readline-devel
BuildRequires: sqlite-devel
BuildRequires: tar
BuildRequires: zlib-devel

%description
Python is an interpreted, interactive, object-oriented programming
language.  It incorporates modules, exceptions, dynamic typing, very high
level dynamic data types, and classes. Python combines remarkable power
with very clear syntax. It has interfaces to many system calls and
libraries, as well as to various window systems, and is extensible in C or
C++. It is also usable as an extension language for applications that need
a programmable interface.  Finally, Python is portable: it runs on many
brands of UNIX, on PCs under Windows, MS-DOS, and OS/2, and on the
Mac.

%package devel
Summary: The libraries and header files needed for Python extension development.
Requires: %{name} = %{version}-%{release}
Group: Development/Libraries

%description devel
The Python programming language's interpreter can be extended with
dynamically loaded extensions and can be embedded in other programs.
This package contains the header files and libraries needed to do
these types of tasks.

Install python-devel if you want to develop Python extensions.  The
python package will also need to be installed.  You'll probably also
want to install the python-docs package, which contains Python
documentation.

%prep
%setup -n Python-%{version}

%build
%configure \
        --enable-ipv6 \
        --enable-unicode=ucs4 \
        --enable-shared \
        --with-system-ffi \
        --with-system-expat \

%{__make} %{?_smp_mflags}

%install
[ -d $RPM_BUILD_ROOT ] && rm -fr $RPM_BUILD_ROOT

%{__make} altinstall DESTDIR=$RPM_BUILD_ROOT
%{__rm} -f $RPM_BUILD_ROOT%{_prefix}/bin/python{,2}
%{__rm} -f $RPM_BUILD_ROOT%{_prefix}/bin/python{,2}-config
%{__rm} -f $RPM_BUILD_ROOT%{_prefix}/bin/2to3
%{__rm} -f $RPM_BUILD_ROOT%{_prefix}/bin/idle
%{__rm} -f $RPM_BUILD_ROOT%{_prefix}/bin/pydoc
%{__rm} -f $RPM_BUILD_ROOT%{_prefix}/bin/smtpd.py
%{__rm} -rf $RPM_BUILD_ROOT%{_libdir}/pkgconfig/
%{__ln_s} %{_libdir}/python2.7/config $RPM_BUILD_ROOT%{_prefix}/lib/python2.7/config
%{__ln_s} %{_libdir}/python2.7/lib-dynload $RPM_BUILD_ROOT%{_prefix}/lib/python2.7/lib-dynload

# 创建对应 ldconfig 库配置文件
mkdir -p $RPM_BUILD_ROOT/apps/conf/python27
touch $RPM_BUILD_ROOT/apps/conf/python27/python27.conf
echo "/apps/lib/" > $RPM_BUILD_ROOT/apps/conf/python27/python27.conf
echo "/apps/lib/python2.7/" > $RPM_BUILD_ROOT/apps/conf/python27/python27.conf

# 手动创建 man file 否则无法创建 RPM
gzip -c $RPM_BUILD_ROOT/%{_libdir}/man1/python2.7.1 >> $RPM_BUILD_ROOT/%{_libdir}/man1/python2.7.1.gz

######
# POST
######

%post
# 移动对应库文件
mv /apps/lib/libpython2.7.so.1.0 /apps/lib/python2.7/.
ln -s  /apps/lib/python2.7/libpython2.7.so.1.0 /apps/lib/python2.7/libpython2.7.so

# 删除库文件(已备份) 删除 MAN FILE
rm -rf %{_libdir}/libpython2.7.so.1.0
rm -rf %{_libdir}/libpython2.7.so
rm -rf /%{_libdir}/man1

mkdir /apps/svr/python -p

ln -s /apps/svr/python27/python2.7 /apps/svr/python/python

%postun
rm -rf /apps/lib/python2.7/libpython2.7.so.1.0 /apps/lib/python2.7/libpython2.7.so
rm -rf /apps/svr/python/python

%post  devel
# 移动头文件
mv /apps/include/python2.7/pyconfig.h /apps/lib/python2.7/.

total=`ls /apps/include/ | wc -l`
if [ $total -eq 1 ]
then
   rm -rf /apps/include
fi

%postun devel
rm -rf /apps/lib/python2.7/pyconfig.h

%clean
%{__rm} -rf $RPM_BUILD_ROOT

%files
%defattr(-,root,root,-)
%{_prefix}/lib/python2.7/*
%{_libdir}/python2.7/lib-dynload/*
%{_libdir}/libpython2.7.so*
%{_bindir}/python2.7*
# %{_mandir}/man1/python2.7.1
%{_bindir}/2to3
%{_bindir}/idle
%{_bindir}/pydoc
%{_bindir}/smtpd.py
%{_mandir}/man1/python2.7.1
%config(noreplace) /apps/conf/python27/python27.conf

#   /apps/svr/python27/2to3
#   /apps/svr/python27/idle
#   /apps/svr/python27/pydoc
#   /apps/svr/python27/smtpd.py

%doc
%{_mandir}/man1/python2.7.1.gz

%files devel
%defattr(-,root,root,-)
%{_prefix}/include/python2.7/*
%{_libdir}/python2.7/config/*

%changelog
* Mon Jan 21 2014 Terry Tsang <signmem@hotmail.com> - 2.7.5-1
- Initial RPM release

 

python-2.7_centOS5.8.spec 存放位置 /usr/src/redhat/SPECS/

python-2.7.5.tar.gz 存放位置 /usr/src/redhat/SOURCES/

 

编译方法

rpm -bb python-2.7_centOS5.8.spec

 

 

参见 python-2.7_centOS6.5.spec 文件

%define _topdir %(echo `cd ..; pwd`)
%define binsuffix 27
%define pybasever 2.7
%define version 2.7.5
%define name python
%define release 20140124vipclound.centOS65

############# edit by terry ############
%define _prefix                 /apps
%define _exec-prefix            /apps
%define _bindir                 /apps/svr/python27
%define _sbindir                /apps/svr/python27
%define _sysconfdir             /apps/conf
%define _includedir             /apps/lib
%define _libexecdir             /apps/lib
%define _infodir                /apps/lib
%define _oldincludedir          /apps/lib
%define _libdir                 /apps/lib
%define _defaultdocdir          /apps/lib
#%define _mandir                /apps/lib

%define config_include_docs no

############# edit by terry ############

Name: %{name}%{binsuffix}
Version: %{version}
Release: 20140121.vipclound.el6
Summary: An interpreted, interactive, object-oriented programming language.
Group: Development/Languages
Source0: http://www.python.org/ftp/python/%{version}/Python-%{version}.tar.bz2

License: PSF
BuildRoot: %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX)

AutoReq: no
Provides: python(abi) = %{pybasever}

BuildRequires: autoconf
BuildRequires: bzip2
BuildRequires: bzip2-devel
BuildRequires: db4-devel
BuildRequires: expat-devel
BuildRequires: findutils
BuildRequires: gcc-c++
BuildRequires: glibc-devel
# BuildRequires: gmp-devel
# BuildRequires: libffi-devel
# BuildRequires: libGL-devel
# BuildRequires: libX11-devel
BuildRequires: make
# BuildRequires: ncurses-devel
BuildRequires: openssl-devel
BuildRequires: pkgconfig
BuildRequires: readline-devel
BuildRequires: sqlite-devel
BuildRequires: tar
# BuildRequires: tcl-devel
# BuildRequires: tix-devel
# BuildRequires: tk-devel
BuildRequires: zlib-devel

%description
Python is an interpreted, interactive, object-oriented programming
language.  It incorporates modules, exceptions, dynamic typing, very high
level dynamic data types, and classes. Python combines remarkable power
with very clear syntax. It has interfaces to many system calls and
libraries, as well as to various window systems, and is extensible in C or
C++. It is also usable as an extension language for applications that need
a programmable interface.  Finally, Python is portable: it runs on many
brands of UNIX, on PCs under Windows, MS-DOS, and OS/2, and on the
Mac.

%package devel
Summary: The libraries and header files needed for Python extension development.
Requires: %{name} = %{version}-%{release}
Group: Development/Libraries

%description devel
The Python programming language's interpreter can be extended with
dynamically loaded extensions and can be embedded in other programs.
This package contains the header files and libraries needed to do
these types of tasks.

Install python-devel if you want to develop Python extensions.  The
python package will also need to be installed.  You'll probably also
want to install the python-docs package, which contains Python
documentation.

%prep
%setup -n Python-%{version}

%build
%configure \
        --enable-ipv6 \
        --enable-unicode=ucs4 \
        --enable-shared \
        --with-system-ffi \
        --with-system-expat \

%{__make} %{?_smp_mflags}

%install
[ -d $RPM_BUILD_ROOT ] && rm -fr $RPM_BUILD_ROOT

%{__make} altinstall DESTDIR=$RPM_BUILD_ROOT
%{__rm} -f $RPM_BUILD_ROOT%{_prefix}/bin/python{,2}
%{__rm} -f $RPM_BUILD_ROOT%{_prefix}/bin/python{,2}-config
%{__rm} -f $RPM_BUILD_ROOT%{_prefix}/bin/2to3
%{__rm} -f $RPM_BUILD_ROOT%{_prefix}/bin/idle
%{__rm} -f $RPM_BUILD_ROOT%{_prefix}/bin/pydoc
%{__rm} -f $RPM_BUILD_ROOT%{_prefix}/bin/smtpd.py
%{__rm} -rf $RPM_BUILD_ROOT%{_libdir}/pkgconfig/
%{__ln_s} %{_libdir}/python2.7/config $RPM_BUILD_ROOT%{_prefix}/lib/python2.7/config
%{__ln_s} %{_libdir}/python2.7/lib-dynload $RPM_BUILD_ROOT%{_prefix}/lib/python2.7/lib-dynload

# 创建对应 ldconfig 库配置文件
mkdir -p $RPM_BUILD_ROOT/apps/conf/python27
touch $RPM_BUILD_ROOT/apps/conf/python27/python27.conf
echo "/apps/lib/" > $RPM_BUILD_ROOT/apps/conf/python27/python27.conf
echo "/apps/lib/python2.7/" > $RPM_BUILD_ROOT/apps/conf/python27/python27.conf

# 手动创建 man file 否则无法创建 RPM
gzip -c $RPM_BUILD_ROOT/%{_libdir}/man1/python2.7.1 >> $RPM_BUILD_ROOT/%{_libdir}/man1/python2.7.1.gz

######
# POST
######

%post
# 移动对应库文件
mv /apps/lib/libpython2.7.so.1.0 /apps/lib/python2.7/.
ln -s  /apps/lib/python2.7/libpython2.7.so.1.0 /apps/lib/python2.7/libpython2.7.so

# 删除库文件(已备份) 删除 MAN FILE
rm -rf %{_libdir}/libpython2.7.so.1.0
rm -rf %{_libdir}/libpython2.7.so
rm -rf /%{_libdir}/man1

mkdir /apps/svr/python -p

ln -s /apps/svr/python27/python2.7 /apps/svr/python/python

%postun
rm -rf /apps/lib/python2.7/libpython2.7.so.1.0 /apps/lib/python2.7/libpython2.7.so
rm -rf /apps/svr/python/python

%post  devel
# 移动头文件
mv /apps/include/python2.7/pyconfig.h /apps/lib/python2.7/.

total=`ls /apps/include/ | wc -l`
if [ $total -eq 1 ]
then
   rm -rf /apps/include
fi

%postun devel
rm -rf /apps/lib/python2.7/pyconfig.h

%clean
%{__rm} -rf $RPM_BUILD_ROOT

%files
%defattr(-,root,root,-)
%{_prefix}/lib/python2.7/*
%{_libdir}/python2.7/lib-dynload/*
%{_libdir}/libpython2.7.so*
%{_bindir}/python2.7*
# %{_mandir}/man1/python2.7.1
%{_bindir}/2to3
%{_bindir}/idle
%{_bindir}/pydoc
%{_bindir}/smtpd.py
%{_mandir}/man1/python2.7.1
%{_bindir}/smtpd.pyc
%{_bindir}/smtpd.pyo
%config(noreplace) /apps/conf/python27/python27.conf

#   /apps/svr/python27/2to3
#   /apps/svr/python27/idle
#   /apps/svr/python27/pydoc
#   /apps/svr/python27/smtpd.py

%doc
%{_mandir}/man1/python2.7.1.gz

%files devel
%defattr(-,root,root,-)
%{_prefix}/include/python2.7/*
%{_libdir}/python2.7/config/*

%changelog
* Mon Jan 21 2014 Terry Tsang <signmem@hotmail.com> - 2.7.5-1
- Initial RPM release

 

python-2.7_centOS65.spec 存放位置 /root/rpmbuild/SPECS/

python-2.7.5.tar.gz 存放位置 /root/rpmbuild/SOURCES/

 

编译方法

rpm -bb python-2.7_centOS65.spec
时间: 2024-04-15 07:32:08

python 2.7 自定义 RPM 编译[备忘]的相关文章

zabbix-2.2.1 打造 server 端 自定义 rpm 方法 [备忘]

 zabbix-2.2.1 下载位置http://downloads.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/2.2.1/zabbix-2.2.1.tar.gz 目标: 创建 zabbix server 端 RPM 软件包, 方便进行软件分发安装位置: 应用程序: /apps/svr/zabbix 配置文件: /apps/conf 库文件: /apps/lib 头文件: /apps/include 启动程序: /apps

nagios-plugin-1.4.16 编译备忘

需要额外安装 fping 软件包http://apt.sw.be/redhat/el6/en/i386/rpmforge/RPMS/fping-3.4-1.el6.rf.i686.rpm   nagios-plugin-1.4.16.tar.gz ./configure --enable-libtap --enable-extra-opts --enable-redhat-pthread-workaround --enable-perl-modules --with-nagios-user=na

zabbix 配置管理[备忘]

参见 zabbix-2.2.1 打造 server 端 自定义 rpm 方法 [备忘] 文档, 编译 zabbix 服务器端   另外可选择使用直接编译方法进行 zabbix 软件安装 编译提示: zabbix-2.2.1 下载位置http://downloads.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/2.2.1/zabbix-2.2.1.tar.gz   解压后可选的编译参数 ./configure \ --enable

Python中利用函数装饰器实现备忘功能_python

"备忘"的定义 "memoization"(备忘)这个词是由Donald Michie在1968年提出的,它基于拉丁语单词"memorandum"(备忘录),意思是"被记住".虽然它和单词"memorization"在某种程度上有些相似,但它并不是该单词的错误拼写.实际上,Memoisation是一种用于通过计算来加速程序的技术,它通过记住输入量的计算结果,例如函数调用结果,来实现其加速目的.如果遇到相同的

RPM 编译错误信息备忘

参见下面 RPM 编译信息 warning: Installed (but unpackaged) file(s) found: /.channels/.alias/pear.txt /.channels/.alias/pecl.txt /.channels/.alias/phpdocs.txt /.channels/__uri.reg /.channels/doc.php.net.reg /.channels/pear.php.net.reg /.channels/pecl.php.net.r

Python中的字典遍历备忘_python

备忘一下python中的字典如何遍历,没有什么太多技术含量.仅供作为初学者的我参考. 复制代码 代码如下: #!/usr/bin/env python # coding=utf-8 demoDict = {'1':'Chrome', '2':'Android'} for key in demoDict.keys():     print key for value in demoDict.values():     print value for key in demoDict:     pri

nginx 编译错误解决方法 [备忘]

参见编译错误信息 can not detect int size 增加参数可以跳过 --with-ld-opt="-lstdc++" --with-cpp_test_module   参考编译错误信息 make[3]: Leaving directory `/apps/lib/openssl-1.0.0k/crypto' make[2]: Leaving directory `/apps/lib/openssl-1.0.0k' make[1]: *** [/apps/lib/opens

服务器迁移之debian重新配置Web服务的一些细节备忘

这次服务系统采用的是最新的Debian 7.0,但是有几个细节的忽略导致我折腾了一番,我再这里再做个记录吧   之前配置Linux服务器时采用的是Debian系统一直很稳定,这次准备迁移到新的服务器环境上,好在以前的配置我在博客都做了备忘,所以很容易就搞定了,这次服务系统采用的是最新的Debian 7.0,但是有几个细节的忽略导致我折腾了一番,我再这里再做个记录吧: 首先要安装编译环境,虽然我们通过apt-get可以方便的绕过手动编译的环节,但是一些程序包可能内置编译命令,可以编译一些扩展程序,

Express模版引擎hbs备忘

最近几天折腾了下express,想找个合适的模版引擎,下面是一些折腾过程的备忘 选择标准 选择一门模版语言时,可能会考虑的几点 语法友好(micro tmpl那种语法真是够了) 支持模版嵌套(子模版的概念) 支持模版继承(extend) 前后端共用 有容错处理(最好定位到具体出错位置) 支持预编译(性能好) 注意到hbs,似乎满足大部分的需求:https://github.com/donpark/hbs getting started demo地址:https://github.com/chyi