Skip to content

Instantly share code, notes, and snippets.

@YakDriver
Created March 2, 2018 02:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save YakDriver/fe10f4e45ae931069501a286a93dc9e8 to your computer and use it in GitHub Desktop.
Save YakDriver/fe10f4e45ae931069501a286a93dc9e8 to your computer and use it in GitHub Desktop.
adventures in RPM builds
pip install --index-url="https://pypi.org/simple" --upgrade virtualenv
sudo yum groupinstall -y development
sudo yum install -y zlib-dev openssl-devel sqlite-devel bzip2-devel
sudo yum install xz-libs
wget http://www.python.org/ftp/python/2.7.14/Python-2.7.14.tar.xz
xz -d Python-2.7.14.tar.xz
tar -xvf Python-2.7.14.tar
sudo yum groupinstall -y development
sudo yum install -y zlib-dev openssl-devel sqlite-devel bzip2-devel
sudo yum install xz-libs
wget http://www.python.org/ftp/python/3.6.4/Python-3.6.4.tar.xz
xz -d Python-3.6.4.tar.xz
tar -xvf Python-3.6.4.tar
cd Python-3.6.4
./configure --prefix=/opt/python3.6.4 --enable-shared
sudo make && sudo make altinstall
sudo chown maintuser:maintuser -R /opt/python3.6.4
sudo chown maintuser:maintuser /opt/python3.6.4/
cd /watchmaker
export LD_LIBRARY_PATH=/opt/python3.6.4/lib
virtualenv --python=/opt/python3.6.4/bin/python3.6 pyppyn-env
source pyppyn-env/bin/activate
pip install six
pip install click
pip install pyinstaller
pyinstaller setup.py
# on source server
python setup.py bdist_rpm
python setup.py bdist_rpm --spec-only
aws s3 cp dist "s3://pyppyn/rpm/" --recursive
# on destination server
aws s3 cp s3://pyppyn/rpm/watchmaker-0.9.3.dev0-1.noarch.rpm .
sudo rpm --install watchmaker-0.9.3.dev0-1.noarch.rpm
# 1)))))) get python bdist_rpm to build things most of the way
$ cd /watchmaker
$ python setup.py bdist_rpm --keep-temp
# in the ~/.rpmmacros file:
%_topdir /watchmaker/build/bdist.linux-x86_64/rpm
# in the /watchmaker/build/bdist.linux-x86_64/rpm/SPECS/watchmaker.spec file, to define a subpackage
%package -n python3
Provides: python3
Summary: Python 3.6.4
Group: Development/Libraries
%description -n python3
A binary install of Python3.6.4.
%prep
%setup -n %{name}-%{unmangled_version} -n %{name}-%{unmangled_version}
%build
python3 setup.py build
%install
python3 setup.py install --single-version-externally-managed -O1 --root=$RPM_BUILD_ROOT --record=INSTALLED_FILES
%clean
#rm -rf $RPM_BUILD_ROOT
%files -f INSTALLED_FILES
#%defattr(-,root,root)
%files -n python3
/opt/python3.6.4
# when it fails it will delete the whole build root
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment