[Rpmbuild] Python 2.7.6

reference

https://github.com/pingviini/rhel6-rpmbuild/blob/master/rpmbuild/SPECS/python27.spec

python27.spec


#----------------------------------------------------------
# yum install -y rpmdevtools tar wget
# yum install -y bzip2-devel db4-devel expat-devel openssl-devel readline-devel sqlite-devel zlib-devel
# yum groupinstall "Development Tools"
# useradd rpmbuilder
# su - rpmbuilder
# rpmdev-setuptree || mkdir -p rpmbuild/{BUILD,BUILDROOT,RPMS,SOURCES,SPECS,SRPMS}
# wget https://www.python.org/ftp/python/2.7.6/Python-2.7.6.tgz -O rpmbuild/SOURCES/Python-2.7.6.tgz
# cd rpmbuild/SPECS/
# rpmdev-newspec python27
# vim python27.spec
# rpmbuild -bb --clean python27.spec
#----------------------------------------------------------
#--- GLOBAL-MODIFIABLE CONFIGS ---
#----------------------------------------------------------
%define _topdir             %(echo $HOME)/rpmbuild
%define _smp_mflags         -j3
%define __arch_install_post /usr/lib/rpm/check-buildroot
%define debug_package       %{nil}

#----------------------------------------------------------
#--- USER-MODIFIABLE CONFIGS ---
#----------------------------------------------------------
%define name        Python
%define binsuffix   27
%define version     2.7.6
%define libvers     2.7
%define vendor      mykysyk
%define release     1
%define __prefix    /usr/local

#----------------------------------------------------------
#--- SUMMARY ---
#----------------------------------------------------------
Summary: An interpreted, interactive, object-oriented programming language.
Name: %{name}%{binsuffix}
Version: %{version}
Release: %{release}.%{vendor}.%((grep -q '6\.' /etc/issue && echo el6)||echo el5)
License: PSF
Group: Development/Languages
Source: https://www.python.org/ftp/python/%{version}/Python-%{version}.tgz
BuildRoot: %{_tmppath}/%{name}-%{version}-root
BuildRequires: glibc-devel
BuildRequires: bzip2-devel
BuildRequires: db4-devel
BuildRequires: expat-devel
BuildRequires: openssl-devel
BuildRequires: readline-devel
BuildRequires: sqlite-devel
BuildRequires: zlib-devel
Prefix: %{__prefix}

%description
Python

%changelog
* Sun May 18 2014 mykysyk <mykysyk> [2.7.6-1]
- Initial RPM releas

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

#----------------------------------------------------------
#--- BUILD ---
#----------------------------------------------------------
%build

#--- CONFIGURE
./configure \
    --enable-unicode=ucs4 \
    --enable-shared \
    --enable-ipv6 \
    --with-system-ffi \
    --with-system-expat \
    --prefix=%{__prefix}

#--- MAKE
make %{?_smp_mflags}

#----------------------------------------------------------
#--- INSTALL ---
#----------------------------------------------------------
%install

[ -d "$RPM_BUILD_ROOT" -a "$RPM_BUILD_ROOT" != "/" ] && rm -rf $RPM_BUILD_ROOT

#--- MAKE INSTALL
make install DESTDIR=$RPM_BUILD_ROOT

rm -f  $RPM_BUILD_ROOT%{__prefix}/bin/python
rm -f  $RPM_BUILD_ROOT%{__prefix}/bin/python-*
rm -f  $RPM_BUILD_ROOT%{__prefix}/bin/python2
rm -f  $RPM_BUILD_ROOT%{__prefix}/bin/python2-*
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%{__prefix}/lib/pkgconfig
find   $RPM_BUILD_ROOT -type f -print0 |
       xargs -0 grep -l /usr/local/bin/python |
       while read file
       do
          sed -i 's|^#!.*python|#!/usr/bin/env python'"%{libvers}"'|'  $file
       done
mkdir -p $RPM_BUILD_ROOT/etc/ld.so.conf.d
echo "%{__prefix}/lib" > $RPM_BUILD_ROOT/etc/ld.so.conf.d/python%{binsuffix}.conf

%post -p /sbin/ldconfig

%postun -p /sbin/ldconfig

%clean
[ -n "$RPM_BUILD_ROOT" -a "$RPM_BUILD_ROOT" != / ] && rm -rf $RPM_BUILD_ROOT

#----------------------------------------------------------
#--- FILES ---
#----------------------------------------------------------
%files
%defattr(-,root,root)
%{__prefix}/bin/python*
%{__prefix}/lib/python%{libvers}/*
%{__prefix}/lib/libpython*
%{__prefix}/include/python%{libvers}/*.h
%{__prefix}/share/man/man1/*
%config(noreplace) /etc/ld.so.conf.d/python27.conf

UCS2 and UCS4 reference http://docs.python.jp/2/c-api/unicode.html http://dsas.blog.klab.org/archives/51322951.html

shell


python -c 'import sys;print sys.maxunicode'

ucs2


65535

ucs4


1114111

Recommended Posts

[Rpmbuild] Python 3.7.3.
[Rpmbuild] Python 2.7.6
Python
kafka python
Python basics ⑤
python + lottery 6
Python Summary
Built-in python
Python technique
Studying python
Python 2.7 Countdown
Python memorandum
python tips
python function ①
Python basics
Python memo
ufo-> python (3)
install python
Python Singleton
Python basics ④
Python Memorandum 2
python memo
Python Jinja2
Python increment
atCoder 173 Python
[Python] function
Python installation
python tips
Installing Python 3.4.3.
Try python
Python iterative
Python algorithm
Python2 + word2vec
[Python] Variables
Python functions
Python sys.intern ()
Python tutorial
Python decimals
python underscore
Start python
[Python] Sort
Note: Python
python log
Python basics
[Scraping] Python scraping
Python update (2.6-> 2.7)
python memo
Python memorandum
Python # sort
ufo-> python
Python nslookup
Hannari Python 2020
Prorate Python (1)
python memorandum
Download python
python memorandum
Python memo
started python
Python #JSON
python quiz
Python encoding