{ "info": { "author": "Rafael Oliveira", "author_email": "rafaelbco@gmail.com", "bugtrack_url": null, "classifiers": [ "Framework :: Buildout", "Framework :: Buildout :: Recipe", "Intended Audience :: Developers", "License :: OSI Approved :: GNU General Public License (GPL)", "Programming Language :: Python", "Programming Language :: Python :: 2", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.3", "Topic :: Software Development :: Build Tools" ], "description": ".. contents::\n\n.. image:: https://travis-ci.org/collective/collective.recipe.environment.svg?branch=master\n :target: https://travis-ci.org/collective/collective.recipe.environment\n :alt: Build status\n\n.. contents::\n\nOverview\n========\n\nThis recipe allows to set and get environment variables during the execution of a buildout.\n\nThe recipe mirrors the current environment variables into its section, so that e.g.\n``${environment:USER}`` will give the current user.\n\nTo set an environment variable you just set it in the section.\n\nThe environment variables are set and get during the initialization of the ``Recipe`` instance,\ni.e. after ``buildout.cfg`` is read but before any recipe is installed or updated.\n\nExample usage: Use an environment variable\n==========================================\n\nWe'll start by creating a buildout that uses the recipe::\n\n >>> write('buildout.cfg',\n ... \"\"\"\n ... [buildout]\n ... parts = environment print\n ...\n ... [some-section]\n ... some-option = ${environment:SOME_VARIABLE}\n ...\n ... [environment]\n ... recipe = collective.recipe.environment\n ...\n ... [print]\n ... recipe = mr.scripty\n ... install =\n ... ... print(self.buildout['some-section']['some-option'])\n ... ... return []\n ... \"\"\")\n\nThe `mr.scripty`_ recipe is used to print out the value of the ${some-section:some-option}\noption.\n\nNow we set the environment variable::\n\n >>> import os\n >>> os.environ['SOME_VARIABLE'] = 'some_value'\n\nRunning the buildout gives us::\n\n >>> run_buildout()\n START...\n some_value\n ...END\n\nExample usage: Set an environment variable\n==========================================\n\nWe'll start by creating a buildout that uses the recipe::\n\n >>> write('buildout.cfg',\n ... \"\"\"\n ... [buildout]\n ... parts = environment print\n ...\n ... [some-section]\n ... some-option = value2\n ...\n ... [environment]\n ... recipe = collective.recipe.environment\n ... var1 = value1\n ... var2 = ${some-section:some-option}\n ...\n ... [print]\n ... recipe = mr.scripty\n ... install =\n ... ... import os\n ... ... for var in ('var1', 'var2'):\n ... ... print('%s = %s' % (var, os.environ[var]))\n ... ... return []\n ... \"\"\")\n\nThe `mr.scripty`_ recipe is used to print out the values of the environment variables.\n\nRunning the buildout gives us::\n\n >>> run_buildout()\n START...\n var1 = value1\n var2 = value2\n ...END\n\nSimilar recipes\n===============\n\nThe functionality to mirror the environment variables into the recipe's section is largely copied\nfrom `gocept.recipe.env`_.\n\n\nRegression test: Values containing variable substitution syntax breaks things\n=============================================================================\n\nProblem: if an environment variable value contains something looking like variable substitution\nin Buildout syntax then things break. We fix this by escaping the variable substitutions using\ntwo dollar signs. Eg.: ``${foo}`` becomes ``$${foo}``.\n\nLet's see if it works.\n\nSet environment variables::\n\n >>> os.environ['PROBLEM_VAR_1'] = '${foo}'\n >>> os.environ['PROBLEM_VAR_2'] = '${foo:bar}'\n >>> os.environ['PROBLEM_VAR_3'] = 'Contains ${foo} and also ${foo:bar}.'\n >>> os.environ['LEGAL_VAR_1'] = '$foo'\n >>> os.environ['LEGAL_VAR_2'] = '{foo}'\n\nWrite a buildout using those variables::\n\n >>> write('buildout.cfg',\n ... \"\"\"\n ... [buildout]\n ... parts = environment print\n ...\n ... [some-section]\n ... option-1 = ${environment:PROBLEM_VAR_1}\n ... option-2 = ${environment:PROBLEM_VAR_2}\n ... option-3 = ${environment:PROBLEM_VAR_3}\n ... option-4 = ${environment:LEGAL_VAR_1}\n ... option-5 = ${environment:LEGAL_VAR_2}\n ...\n ... [environment]\n ... recipe = collective.recipe.environment\n ...\n ... [print]\n ... recipe = mr.scripty\n ... install =\n ... ... section = self.buildout['some-section']\n ... ... for (k, v) in sorted(section.items()):\n ... ... print('{} = {}'.format(k, v))\n ... ... return []\n ...\n ... \"\"\")\n\nRunning the buildout gives us::\n\n >>> run_buildout()\n START...\n option-1 = $${foo}\n option-2 = $${foo:bar}\n option-3 = Contains $${foo} and also $${foo:bar}.\n option-4 = $foo\n option-5 = {foo}\n ...END\n\n.. References\n.. _`mr.scripty`: http://pypi.python.org/pypi/mr.scripty\n.. _`gocept.recipe.env`: http://pypi.python.org/pypi/gocept.recipe.env\n\nChangelog\n=========\n\n1.1.0 (2017-07-27)\n------------------\n\nNew features:\n\n- Fix code for Python 3 compatiblity.\n [cas--]\n\n\n1.0.0 (2017-07-20)\n------------------\n\nBreaking changes:\n\n- Fix bug: Values containing variable substitution syntax breaks things. This is a breaking change\n because problematic values are escaped, eg. \"${foo}\" becomes \"$${foo}\".\n\n0.2.0 (2012-08-21)\n------------------\n\n- Now it's possible to read environment variables.\n\n0.1b1 (2011-08-18)\n------------------\n\n- First release.", "description_content_type": null, "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/collective/collective.recipe.environment", "keywords": "zc.buildout buildout recipe", "license": "GPL", "maintainer": "", "maintainer_email": "", "name": "collective.recipe.environment", "package_url": "https://pypi.org/project/collective.recipe.environment/", "platform": "", "project_url": "https://pypi.org/project/collective.recipe.environment/", "project_urls": { "Homepage": "https://github.com/collective/collective.recipe.environment" }, "release_url": "https://pypi.org/project/collective.recipe.environment/1.1.0/", "requires_dist": null, "requires_python": "", "summary": "Buildout recipe to set and get environment variables.", "version": "1.1.0" }, "last_serial": 3053910, "releases": { "0.1b1": [ { "comment_text": "", "digests": { "md5": "3e8fd9a65fd6908ba2d106e1a1760505", "sha256": "61505e42d6386de661bde408454f37aea9bb28288bcc8b87912b19c7ada32f6d" }, "downloads": -1, "filename": "collective.recipe.environment-0.1b1.tar.gz", "has_sig": false, "md5_digest": "3e8fd9a65fd6908ba2d106e1a1760505", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4463, "upload_time": "2011-08-18T05:11:10", "url": "https://files.pythonhosted.org/packages/2c/2b/5de429c49ec683b6084de7527a7619ec7244491ecfc895980f6c2fe0602f/collective.recipe.environment-0.1b1.tar.gz" } ], "0.2.0": [ { "comment_text": "", "digests": { "md5": "6f8d64130a12aca3e7923c3e561f7669", "sha256": "bbbd371f37ceff46817e9cb80590f4791d8609182508aeb3bdebf8ce8b09ae99" }, "downloads": -1, "filename": "collective.recipe.environment-0.2.0.tar.gz", "has_sig": false, "md5_digest": "6f8d64130a12aca3e7923c3e561f7669", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4924, "upload_time": "2012-08-21T16:56:49", "url": "https://files.pythonhosted.org/packages/40/69/8661c45b5ec6b2aea932d95af6cb55ef990b2ff5af10726bf2faed2e8d6a/collective.recipe.environment-0.2.0.tar.gz" } ], "1.0.0": [ { "comment_text": "", "digests": { "md5": "8b03c71297dd99f37451f6273aa07d6d", "sha256": "ea119316cbe8c745bf7e4f5e975444b0b3228860284150a99cd0d68ad30ff2bf" }, "downloads": -1, "filename": "collective.recipe.environment-1.0.0.tar.gz", "has_sig": false, "md5_digest": "8b03c71297dd99f37451f6273aa07d6d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5164, "upload_time": "2017-07-20T18:38:45", "url": "https://files.pythonhosted.org/packages/4e/de/1b5a8b0c6de4e03a15b4075831b75019be6be2ff5495a6054a3bc76018ef/collective.recipe.environment-1.0.0.tar.gz" } ], "1.1.0": [ { "comment_text": "", "digests": { "md5": "61b4f05e94c532c24e5aeda51ce073eb", "sha256": "0776a68ebf4e10d879733a514b998a8540fa70083283913b02e6f6641027313f" }, "downloads": -1, "filename": "collective.recipe.environment-1.1.0.tar.gz", "has_sig": false, "md5_digest": "61b4f05e94c532c24e5aeda51ce073eb", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5405, "upload_time": "2017-07-27T20:52:46", "url": "https://files.pythonhosted.org/packages/e4/01/c2b6bfe67636193c39c3decb8720aab526e5fb67c12a72e5d38a4eaae01b/collective.recipe.environment-1.1.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "61b4f05e94c532c24e5aeda51ce073eb", "sha256": "0776a68ebf4e10d879733a514b998a8540fa70083283913b02e6f6641027313f" }, "downloads": -1, "filename": "collective.recipe.environment-1.1.0.tar.gz", "has_sig": false, "md5_digest": "61b4f05e94c532c24e5aeda51ce073eb", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5405, "upload_time": "2017-07-27T20:52:46", "url": "https://files.pythonhosted.org/packages/e4/01/c2b6bfe67636193c39c3decb8720aab526e5fb67c12a72e5d38a4eaae01b/collective.recipe.environment-1.1.0.tar.gz" } ] }