Commit 9aeee27d authored by Jérome Perrin's avatar Jérome Perrin

Merge remote-tracking branch 'upstream/master' into zope4py2

parents 9d467bd9 29565304
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
extends = extends =
../pygolang/buildout.cfg ../pygolang/buildout.cfg
parts =
[virtual-env-base] [virtual-env-base]
recipe = slapos.recipe.build recipe = slapos.recipe.build
name = ${:_buildout_section_name_} name = ${:_buildout_section_name_}
...@@ -10,64 +12,133 @@ init = ...@@ -10,64 +12,133 @@ init =
from zc.buildout.easy_install import working_set from zc.buildout.easy_install import working_set
import os import os
name = options['name'] name = options['name']
eggs = options['eggs'] eggs = options.get('eggs')
try: self.message = options.get('message')
scripts = "scripts = " + options['scripts'] self.chain = options.get('chain')
except KeyError: environment = options.get('environment')
scripts = "" scripts = options.get('scripts')
self.buildout.parse(""" eggs_template = """
[.%(name)s.install-eggs] [.%(name)s.install-eggs]
recipe = zc.recipe.egg recipe = zc.recipe.egg
eggs = %(eggs)s eggs =
%(eggs)s
%(scripts)s %(scripts)s
[.%(name)s.install-interpreter] [.%(name)s.install-interpreter]
<= python-interpreter <= python-interpreter
eggs += %(eggs)s eggs +=
""" % locals()) %(eggs)s
"""
instance_template = """
[.%(name)s.instance]
recipe = slapos.recipe.template
output = ${buildout:directory}/instance.cfg
depends = $%(cookbook)s
inline =
[buildout]
parts = publish
eggs-directory = ${buildout:eggs-directory}
develop-eggs-directory = ${buildout:develop-eggs-directory}
[publish]
recipe = slapos.cookbook:publish
activate-script = %(location)s
"""
if eggs:
self.buildout.parse(eggs_template % {
"eggs": "\n ".join(e.strip() for e in eggs.splitlines()),
"name": name,
"scripts": "scripts = " + scripts if scripts else "",
})
if is_true(options.get('default-instance')): if is_true(options.get('default-instance')):
cookbook = "{slapos-cookbook:recipe}" self.buildout.parse(instance_template % {
self.buildout.parse(""" "cookbook": "{slapos-cookbook:recipe}",
[.%(name)s.instance] "location": location,
recipe = slapos.recipe.template "name": name,
output = ${buildout:directory}/instance.cfg })
depends = $%(cookbook)s
inline = env = {
[buildout] "PATH": self.buildout['buildout']['bin-directory'] + ":\$PATH",
parts = publish "PS1": "\"(" + self.name + ") \$PS1\"",
}
eggs-directory = ${buildout:eggs-directory}
develop-eggs-directory = ${buildout:develop-eggs-directory} if environment:
for line in environment.splitlines():
[publish] key, value = line.split("=", 1)
recipe = slapos.cookbook:publish env[key.strip()] = value.strip()
activate-script = %(location)s
""" % locals()) self.env = env
install = install =
message = ""
if self.message:
message = "echo " + "\n echo ".join(
"%r" % line for line in self.message.splitlines())
message += "\n echo \'\'"
chain = ""
if self.chain:
chain = "source " + "\n source ".join(
"%r" % line for line in self.chain.splitlines())
with open(location, "w") as f: with open(location, "w") as f:
f.write(options['template'] % { f.write(options['template'] % {
"path" : self.buildout['buildout']['bin-directory'], "env": " ".join("%s %s" % (k, v) for k, v in self.env.items()),
"name" : self.name, "message": message,
"chain": chain,
}) })
# Template virtual env for bash shell in posix # Template virtual env for bash shell in posix
[virtual-env-base:posix] [virtual-env-base:posix]
template = template =
deactivate () { if type deactivate > /dev/null 2>&1
set PATH PS1 then
export _OLD_PARAM=( "$@")
set %(env)s
while [ "$1" ]; do while [ "$1" ]; do
eval "if [ \"\$_OLD_VENV_$1\" ]; then $1=\$_OLD_VENV_$1; else unset $1; fi; unset \$_OLD_VENV_$1" if ! ( echo $_LIST_OLD_VENV | grep $1 ) > /dev/null 2>&1
then
eval "export _OLD_VENV_$1=\$$1"
eval "export _LIST_OLD_VENV=\"$1 \$_LIST_OLD_VENV\""
fi
eval "export $1=\"$2\""
shift
shift shift
done done
unset -f deactivate if [[ -n "$_OLD_PARAM" ]]; then
} set "$${_OLD_PARAM[@]}"
fi
unset _OLD_PARAM
VENV_PATH=%(path)s %(chain)s
_OLD_VENV_PATH=$PATH %(message)s
_OLD_VENV_PS1=$PS1 else
PATH=$VENV_PATH:$PATH deactivate () {
PS1='(%(name)s) '$PS1 set $_LIST_OLD_VENV
while [ "$1" ]; do
eval "if [ \"\$_OLD_VENV_$1\" ]; then $1=\$_OLD_VENV_$1; else unset $1; fi; unset \$_OLD_VENV_$1"
shift
done
unset -f deactivate
unset _LIST_OLD_VENV
}
export _OLD_PARAM=( "$@" )
set %(env)s
while [ "$1" ]; do
eval "_OLD_VENV_$1=\$$1"
eval "export $1=\"$2\""
eval "export _LIST_OLD_VENV=\"$1 \$_LIST_OLD_VENV\""
shift
shift
done
if [[ -n "$_OLD_PARAM" ]]; then
set "$${_OLD_PARAM[@]}"
fi
unset _OLD_PARAM
%(chain)s
%(message)s
fi
Virtual environment
===================
Introduction
------------
The virtual environment macro allows you to quickly create a development environment.
Options
-------
Several options are available to customize your virtual environment :
name
~~~~
The ``name`` option is the name that will be displayed when the environment is activated. For example::
name = virtual-env
gives::
>> source activate
( virtual-env ) >>
**Note:** By default, ``name`` is the name of the Buildout section that uses the macro.
location
~~~~~~~~
The ``location`` option is where the script to be sourced will be stored. For example::
location = project/activate
gives::
>> source project/activate
( virtual-env ) >>
**Note:** Don't forget to add the name of the script in the path.
eggs
~~~~
This option should not be used to install eggs during instantiation (in an instance file).
It works the same way as ``zc.recipe.eggs``, you can add to the line several eggs to download for use in the virtual environment.
A custom Python with the chosen eggs will then be generated. For example::
eggs = numpy
gives::
( virtual-env ) >> python
python
>>> import numpy
scripts
~~~~~~~
This option should not be used to install scripts during instantiation (in an instance file).
It works in the same way as in ``zc.recipe.eggs``, you can add to the line several scripts to generate for use in the virtual environment.For example::
eggs = Django
scripts = django-admin
gives::
( virtual-env ) >> django-admin
**Note:** By default if the option is not used, all scripts will be installed.
default-instance
~~~~~~~~~~~~~~~~
The ``default-instance`` option takes the value ``true`` or ``false``.
If set to ``true``, it will create a minimal instance that will publish the path of the script to be sourced.
If it is set to ``false``, you will be able to create your own custom instance.
**Note:** If you want to use the macro in an ``instance`` file, you should set this option to ``false``.
environment
~~~~~~~~~~~
The ``environment`` option allows you to choose the value of the environment variables of the virtual environment.
They are to be written on the line in the form ``VAR = value``. For example::
environment =
VAR1 = value1
VAR2 = value2
gives::
( virtual-env ) >> echo $VAR1
value1
**Note:** If you want to keep the other values as well, like for PATH for example, you have to do::
PATH = new_val:$PATH
message
~~~~~~~
The ``message`` option allows to display a message when sourcing the virtual environment.
The message will be considered as a string. For example::
message =
You are in a virtual environment.
gives::
>> source activate
You are in a virtual environment.
( virtual-env) >>
chain
~~~~~
The ``chain`` option allows you to chain several scripts created by the macro as if it were one. This can be useful if one script is generated in a ``software`` file and another in an ``instance`` file.
When deactivating, the state of the environment will return to the initial state.
To use this option you just have to specify the script to source by running the script. For example::
chain = project/another_activate
Deactivate
----------
Once you want to exit the virtual environment, you just have to run the ``deactivate`` function. Like::
( virtual-env ) >> deactivate
>>
...@@ -19,7 +19,7 @@ parts = ...@@ -19,7 +19,7 @@ parts =
python3 python3
[python3] [python3]
<= python3.7 <= python3.8
[python3-common] [python3-common]
recipe = slapos.recipe.cmmi recipe = slapos.recipe.cmmi
...@@ -61,7 +61,32 @@ md5sum = 986078f11b39074be22a199e56491d98 ...@@ -61,7 +61,32 @@ md5sum = 986078f11b39074be22a199e56491d98
[python3.7] [python3.7]
<= python3-common <= python3-common
version = 3.7 version = 3.7
package_version = 3.7.7 package_version = 3.7.9
md5sum = 172c650156f7bea68ce31b2fd01fa766 md5sum = 389d3ed26b4d97c741d9e5423da1f43b
patch-options =
patches =
[python3.8]
<= python3-common
version = 3.8
package_version = 3.8.9
md5sum = 51b5bbf2ab447e66d15af4883db1c133
patch-options =
patches =
[python3.9]
<= python3-common
version = 3.9
package_version = 3.9.13
md5sum = 5e2411217b0060828d5f923eb422a3b8
patch-options =
patches =
[python3.10]
<= python3-common
version = 3.10
package_version = 3.10.5
md5sum = f05727cb3489aa93cd57eb561c16747b
patch-options = patch-options =
patches = patches =
...@@ -15,6 +15,11 @@ extends = ...@@ -15,6 +15,11 @@ extends =
[systemd-markupsafe-download] [systemd-markupsafe-download]
recipe = slapos.recipe.build:download recipe = slapos.recipe.build:download
shared = true shared = true
url = https://files.pythonhosted.org/packages/bf/10/ff66fea6d1788c458663a84d88787bae15d45daa16f6b3ef33322a51fc7e/${:filename}
filename = MarkupSafe-2.0.1.tar.gz
md5sum = 892e0fefa3c488387e5cc0cad2daa523
[systemd-markupsafe-download:sys.version_info < (3,8)]
url = https://files.pythonhosted.org/packages/4d/de/32d741db316d8fdb7680822dd37001ef7a448255de9699ab4bfcbdf4172b/${:filename} url = https://files.pythonhosted.org/packages/4d/de/32d741db316d8fdb7680822dd37001ef7a448255de9699ab4bfcbdf4172b/${:filename}
filename = MarkupSafe-1.0.tar.gz filename = MarkupSafe-1.0.tar.gz
md5sum = 2fcedc9284d50e577b5192e8e3578355 md5sum = 2fcedc9284d50e577b5192e8e3578355
......
...@@ -139,7 +139,7 @@ zc.recipe.egg = 2.0.3+slapos003 ...@@ -139,7 +139,7 @@ zc.recipe.egg = 2.0.3+slapos003
traitlets = 4.3.3 traitlets = 4.3.3
Jinja2 = 2.11.3 Jinja2 = 2.11.3
Importing = 1.10 Importing = 1.10
MarkupSafe = 1.0 MarkupSafe = 2.0.1
PyYAML = 5.4.1 PyYAML = 5.4.1
Werkzeug = 2.0.2 Werkzeug = 2.0.2
ZConfig = 2.9.3 ZConfig = 2.9.3
...@@ -203,7 +203,7 @@ slapos.rebootstrap = 4.5 ...@@ -203,7 +203,7 @@ slapos.rebootstrap = 4.5
slapos.recipe.build = 0.55 slapos.recipe.build = 0.55
slapos.recipe.cmmi = 0.19 slapos.recipe.cmmi = 0.19
slapos.recipe.template = 5.0 slapos.recipe.template = 5.0
slapos.toolbox = 0.127 slapos.toolbox = 0.128
stevedore = 1.21.0:whl stevedore = 1.21.0:whl
subprocess32 = 3.5.4 subprocess32 = 3.5.4
unicodecsv = 0.14.1 unicodecsv = 0.14.1
...@@ -262,6 +262,9 @@ click = 6.7 ...@@ -262,6 +262,9 @@ click = 6.7
distro = 1.6.0 distro = 1.6.0
Werkzeug = 1.0.1 Werkzeug = 1.0.1
[versions:sys.version_info < (3,8)]
MarkupSafe = 1.0
[networkcache] [networkcache]
download-cache-url = http://shacache.nxdcdn.com download-cache-url = http://shacache.nxdcdn.com
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment