Commit b5b159d3 authored by Thomas Leymonerie's avatar Thomas Leymonerie

slapos/recipe: Create slapos.recipe.egg to extend zc.recipe.egg and create a...

slapos/recipe: Create slapos.recipe.egg to extend zc.recipe.egg and create a script to activate virtual env
parent 3833123f
from setuptools import setup, find_packages
version = '0.54'
version = '0.54+tleymone1'
name = 'slapos.recipe.build'
long_description = open("README.rst").read() + "\n" + \
open("CHANGELOG.rst").read() + "\n"
......@@ -24,6 +24,7 @@ setup(name=name,
install_requires=[
'setuptools', # namespaces
'zc.buildout', # plays with buildout
'zc.recipe.egg', # for slapos.recipe.egg (inheriting)
],
extras_require={
'test' : ['zope.testing'],
......@@ -36,6 +37,7 @@ setup(name=name,
'default = slapos.recipe.build:Script',
'download = slapos.recipe.download:Recipe',
'download-unpacked = slapos.recipe.downloadunpacked:Recipe',
'egg = slapos.recipe.egg:Recipe',
'gitclone = slapos.recipe.gitclone:Recipe',
'npm = slapos.recipe.npm:Npm',
'vm.install-debian = slapos.recipe.vm:InstallDebianRecipe',
......
from zc.buildout.easy_install import working_set
from zc.recipe.egg import Egg
import os
import errno
template = """
alias deactivate=\'export PATH=\"$_OLD_VIRTUAL_PATH\" && unset _OLD_VIRTUAL_PATH && export PYTHONPATH=\"$_OLD_VIRTUAL_PYTHON_PATH\" && unset _OLD_VIRTUAL_PYTHON_PATH && unalias deactivate\'
export VIRTUAL_ENV=%s
_OLD_VIRTUAL_PATH=\"$PATH\"
export PATH=\"$VIRTUAL_ENV:$PATH\"
export VIRTUAL_PYTHON_PATH=%s
_OLD_VIRTUAL_PYTHON_PATH=\"$PYTHONPATH\"
export PYTHONPATH=\"$VIRTUAL_PYTHON_PATH:$PYTHONPATH\"
"""
class Recipe(Egg):
def install(self):
super(Recipe, self).install()
self.eggs = tuple(
egg.strip()
for egg in self.options['eggs'].splitlines()
if egg.strip()
)
options = self.options
self.eggs_set = working_set(
self.eggs,
[self.options['develop-eggs-directory'], self.options['eggs-directory']]
)
python_path = ":".join(tuple(dist.location for dist in self.eggs_set))
dst = os.path.abspath(self.options['script-path'])
self.makedirs(dst)
file = self.options['script-path']+"/env-script"
with open(file, "w") as f:
f.write(template % (options['bin-directory'], python_path))
print("/\/\/\ "+file+" /\/\/\ ")
def makedirs(self, path):
try:
os.makedirs(path)
except OSError as e:
if e.errno != errno.EEXIST:
raise
update = install
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