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 ..

要求

把 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

目录
相关文章
|
3月前
|
缓存 监控 供应链
唯品会自定义 API 自定义操作深度分析及 Python 实现
唯品会开放平台提供丰富API,支持商品查询、订单管理、促销活动等电商全流程操作。基于OAuth 2.0认证机制,具备安全稳定的特点。通过组合调用基础接口,可实现数据聚合、流程自动化、监控预警及跨平台集成,广泛应用于供应链管理、数据分析和智能采购等领域。结合Python实现方案,可高效完成商品搜索、订单分析、库存监控等功能,提升电商运营效率。
|
3月前
|
缓存 监控 供应链
京东自定义 API 操作深度分析及 Python 实现
京东开放平台提供丰富API接口,支持商品、订单、库存等电商全链路场景。通过自定义API组合调用,可实现店铺管理、数据分析、竞品监控等功能,提升运营效率。本文详解其架构、Python实现与应用策略。
缓存 监控 供应链
77 0
缓存 监控 数据挖掘
72 0
|
9月前
|
Rust JavaScript 前端开发
[oeasy]python075_什么是_动态类型_静态类型_强类型_弱类型_编译_运行
本文探讨了编程语言中的动态类型与静态类型、强类型与弱类型的概念。通过实例分析,如Python允许变量类型动态变化(如`age`从整型变为字符串),而C语言一旦声明变量类型则不可更改,体现了动态与静态类型的差异。此外,文章还对比了强类型(如Python,不允许隐式类型转换)和弱类型(如JavaScript,支持自动类型转换)的特点。最后总结指出,Python属于动态类型、强类型语言,对初学者友好但需注意类型混淆,并预告下期内容及提供学习资源链接。
261 22
|
9月前
|
缓存 Shell 开发工具
[oeasy]python071_我可以自己做一个模块吗_自定义模块_引入模块_import_diy
本文介绍了 Python 中模块的导入与自定义模块的创建。首先,我们回忆了模块的概念,即封装好功能的部件,并通过导入 `__hello__` 模块实现了输出 &quot;hello world!&quot; 的功能。接着,尝试创建并编辑自己的模块 `my_file.py`,引入 `time` 模块以获取当前时间,并在其中添加自定义输出。
170 5
|
11月前
|
数据挖掘 数据处理 开发者
Python3 自定义排序详解:方法与示例
Python的排序功能强大且灵活,主要通过`sorted()`函数和列表的`sort()`方法实现。两者均支持`key`参数自定义排序规则。本文详细介绍了基础排序、按字符串长度或元组元素排序、降序排序、多条件排序及使用`lambda`表达式和`functools.cmp_to_key`进行复杂排序。通过示例展示了如何对简单数据类型、字典、类对象及复杂数据结构(如列车信息)进行排序。掌握这些技巧可以显著提升数据处理能力,为编程提供更强大的支持。
538 10
|
Python
在Python中,自定义函数可以抛出自定义异常
在Python中,自定义函数可以抛出自定义异常
257 5
|
存储 开发者 Python
自定义Python的异常
自定义Python的异常
210 5
|
存储 JSON API
如何自定义Python环境变量?
如何自定义Python环境变量?
402 3

推荐镜像

更多