L'un des outils pour créer un environnement de jardin miniature Python est la construction. J'ai écrit un Makefile pour créer un environnement de buildout
On suppose que Python et virtualenv sont déjà disponibles.
Les commandes attendues sont:
make fait construire.
Makefile
J'utilise souvent Makefile lors de l'exécution de buildout. L'exemple suivant décrit les opérations minimales requises.
Makefile
# -*- coding: utf-8 -*-
# Need virtualenv
.PHONY: all clean build rebuild
all: env bin/buildout build
echo "buildout finished..."
clean:
rm -rf bin parts eggs develop-eggs .installed env bootstrap.py
build: bin/buildout
bin/buildout -c buildout.cfg
rebuild: clean build
echo
bin/buildout: env
curl https://raw.githubusercontent.com/buildout/buildout/master/bootstrap/bootstrap.py | env/bin/python
env:
virtualenv --no-site-packages env
env/bin/pip install -U setuptools
buildout.cfg Vous avez besoin du fichier de configuration buyout.cfg pour la construction. Ce paramètre ne fait rien.
buildout.cfg
[buildout]
parts =
Le fichier contient le Makefile et buildout.cfg ci-dessus dans le même répertoire.
(py3k)$ ls
Makefile buildout.cfg
Créons un make build.
(py3k)$ make build
virtualenv --no-site-packages env
Using real prefix '/home/examples/.anyenv/envs/pyenv/versions/3.4.2'
New python executable in env/bin/python3.4
Also creating executable in env/bin/python
Installing setuptools, pip...done.
env/bin/pip install -U setuptools
You are using pip version 6.0.3, however version 6.0.6 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
DEPRECATION: --download-cache has been deprecated and will be removed in the future. Pip now automatically uses and configures its cache.
Collecting setuptools from https://pypi.python.org/packages/3.4/s/setuptools/setuptools-11.3.1-py2.py3-none-any.whl#md5=59cd761f2f2b926313bed7f83337e4d7
Downloading setuptools-11.3.1-py2.py3-none-any.whl (500kB)
100% |################################| 503kB 7.3MB/s
Installing collected packages: setuptools
Found existing installation: setuptools 8.2.1
Uninstalling setuptools-8.2.1:
Successfully uninstalled setuptools-8.2.1
Successfully installed setuptools-11.3.1
curl https://raw.githubusercontent.com/buildout/buildout/master/bootstrap/bootstrap.py > bootstrap.py
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 6501 100 6501 0 0 17982 0 --:--:-- --:--:-- --:--:-- 18008
env/bin/python bootstrap.py
Creating directory '/home/examples/ng/var/src/develop/examples/buildout/simple/bin'.
Creating directory '/home/examples/ng/var/src/develop/examples/buildout/simple/parts'.
Creating directory '/home/examples/ng/var/src/develop/examples/buildout/simple/eggs'.
Creating directory '/home/examples/ng/var/src/develop/examples/buildout/simple/develop-eggs'.
Generated script '/home/examples/ng/var/src/develop/examples/buildout/simple/bin/buildout'.
bin/buildout -c buildout.cfg
(py3k)$
Vérifions dans le répertoire de travail.
(py3k)$ ls
Makefile bin buildout.cfg develop-eggs eggs env parts
(py3k)$ make clean
rm -rf bin parts eggs develop-eggs .installed env bootstrap.py
Confirmez que vous l'avez supprimé.
(py3k)$ ls
Makefile buildout.cfg
À ce moment, l'environnement créé par virualenv est également utilisé. C'est déjà enraciné.
Maintenant, exécutons build rebuild.
(py3k)$ make rebuild
rm -rf bin parts eggs develop-eggs .installed env bootstrap.py
virtualenv --no-site-packages env
Using real prefix '/home/examples/.anyenv/envs/pyenv/versions/3.4.2'
New python executable in env/bin/python3.4
Also creating executable in env/bin/python
Installing setuptools, pip...done.
env/bin/pip install -U setuptools
You are using pip version 6.0.3, however version 6.0.6 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
DEPRECATION: --download-cache has been deprecated and will be removed in the future. Pip now automatically uses and configures its cache.
Collecting setuptools from https://pypi.python.org/packages/3.4/s/setuptools/setuptools-11.3.1-py2.py3-none-any.whl#md5=59cd761f2f2b926313bed7f83337e4d7
Downloading setuptools-11.3.1-py2.py3-none-any.whl (500kB)
100% |################################| 503kB 3.4MB/s
Installing collected packages: setuptools
Found existing installation: setuptools 8.2.1
Uninstalling setuptools-8.2.1:
Successfully uninstalled setuptools-8.2.1
Successfully installed setuptools-11.3.1
curl https://raw.githubusercontent.com/buildout/buildout/master/bootstrap/bootstrap.py > bootstrap.py
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 6501 100 6501 0 0 16741 0 --:--:-- --:--:-- --:--:-- 16755
env/bin/python bootstrap.py
Creating directory '/home/examples/ng/var/src/develop/examples/buildout/simple/bin'.
Creating directory '/home/examples/ng/var/src/develop/examples/buildout/simple/parts'.
Creating directory '/home/examples/ng/var/src/develop/examples/buildout/simple/eggs'.
Creating directory '/home/examples/ng/var/src/develop/examples/buildout/simple/develop-eggs'.
Generated script '/home/examples/ng/var/src/develop/examples/buildout/simple/bin/buildout'.
bin/buildout -c buildout.cfg
echo
(py3k)$
Tout ce que je fais, c'est nettoyer puis construire.
Recommended Posts