Skip to content

Instantly share code, notes, and snippets.

@mnacharov
Last active April 16, 2018 01:22
Show Gist options
  • Save mnacharov/9ab2f6381d23ddfe70891f25b5ca888e to your computer and use it in GitHub Desktop.
Save mnacharov/9ab2f6381d23ddfe70891f25b5ca888e to your computer and use it in GitHub Desktop.
pyenv debian-package builder
pyenv (2017.02.09-1) stable; urgency=medium
* Initial Release
-- Mikhail Nacharov <www-webnach-ru> Thu, 09 Feb 2017 22:36:16 +0500
/etc/profile.d/pyenv.sh
Package: pyenv
Version: 2017.02.09-1
Maintainer: Mikhail Nacharov <www-webnach-ru>
Architecture: all
Section: python
Depends: make, gcc, libssl-dev, zlib1g-dev, libbz2-dev, libreadline-dev, libsqlite3-dev
Suggests: libxml2-dev, libxslt1-dev, zlib1g-dev, libmysqlclient-dev
Priority: optional
Origin: https://github.com/yyuu/pyenv
Description: Simple Python Version Management: pyenv.
pyenv lets you easily switch between multiple versions of Python.
It's simple, unobtrusive, and follows the UNIX tradition of
single-purpose tools that do one thing well.
.
This project was forked from rbenv and ruby-build, and
modified for Python.
# Makefile for update and build pyenv debian package #
# Used directories
PYENV_SRC=pyenv.src
PYENV_BUILD=pyenv
PYENV_TARGET=$(PYENV_BUILD)/usr/share/pyenv
# Files wich needs to be removed from debian package
NOT_NEEDED_FILES=.agignore CHANGELOG.md CONDUCT.md .git .gitignore LICENSE \
Makefile src test .travis.yml .vimrc plugins/.gitignore plugins/*/.git \
plugins/*/.gitignore plugins/*/test plugins/*/LICENSE
# Extract version from control for package name
VERSION="`cat pyenv/DEBIAN/control|grep 'Version:'|awk '{print $$2}'`"
build: pyenv
fakeroot dpkg-deb --build $(PYENV_BUILD)
mkdir -p dists
mv -v pyenv.deb dists/pyenv_$(VERSION)_all.deb
# configure build dir
pyenv: pyenv.src update
rm -Rf $(PYENV_BUILD);
`# move pyenv directory to PYENV_TARGET`
mkdir -p `dirname $(PYENV_TARGET)`
cp -R pyenv.src $(PYENV_TARGET)
cd $(PYENV_TARGET) && rm -Rf $(NOT_NEEDED_FILES)
`# users from pyenv group can write to those directories`
mkdir -p -m 775 $(PYENV_TARGET)/cache
mkdir -p -m 775 $(PYENV_TARGET)/shims
mkdir -p -m 775 $(PYENV_TARGET)/versions
`# install virtualenv for all new pythons`
echo "virtualenv" > $(PYENV_TARGET)/default-packages
`# all pythons must have envs for virutual environments`
cp mkdir-envs.bash $(PYENV_TARGET)/plugins/pyenv-default-packages/etc/pyenv.d/install/
`# copy profile.d and doc directory in usr`
mkdir -p $(PYENV_BUILD)/etc/profile.d
cp pyenv.sh $(PYENV_BUILD)/etc/profile.d
mkdir -p $(PYENV_BUILD)/usr/share/doc/pyenv
cp copyright $(PYENV_BUILD)/usr/share/doc/pyenv
gzip --best -k -c changelog.Debian > $(PYENV_BUILD)/usr/share/doc/pyenv/changelog.Debian.gz
`# package information`
mkdir $(PYENV_BUILD)/DEBIAN
for file in conffiles control postinst postrm preinst; do \
cp $$file $(PYENV_BUILD)/DEBIAN; \
done;
# initial clone - pyenv and relevant plugins
pyenv.src:
curl -L https://raw.githubusercontent.com/yyuu/pyenv-installer/master/bin/pyenv-installer \
| PYENV_ROOT=$(PYENV_SRC) bash
git clone https://github.com/jawshooah/pyenv-default-packages $(PYENV_SRC)/plugins/pyenv-default-packages
# pyenv-update do all work for us
update:
PYENV_ROOT=$(PYENV_SRC) PATH="$(PYENV_SRC)/bin:$(PATH)" pyenv update
# remove all temporary directories
clean:
rm -Rf $(PYENV_BUILD)
rm -Rf $(PYENV_SRC)
#!/usr/bin/env bash
if declare -Ff after_install >/dev/null; then
after_install 'mkdir -m 770 $PYENV_ROOT/versions/$VERSION_NAME/envs && \
chmod +t $PYENV_ROOT/versions/$VERSION_NAME/envs'
else
echo "pyenv: pyenv-default-packages plugin requires pyenv v0.1.0 or later" >&2
fi
chown root:pyenv -R /usr/share/pyenv
chmod g+s /usr/share/pyenv/versions
chmod +t /usr/share/pyenv/versions
groupdel pyenv
groupadd -f -r pyenv
if groups | grep &>/dev/null '\bpyenv\b'; then
export PYENV_ROOT="/usr/share/pyenv";
export PATH="$PYENV_ROOT/bin:$PATH";
eval "$(pyenv init -)";
eval "$(pyenv virtualenv-init -)";
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment