{ "info": { "author": "Michael Mulich | WebLion Group, Penn State University", "author_email": "support@weblion.psu.edu", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Framework :: Buildout", "Intended Audience :: Developers", "License :: OSI Approved :: Zope Public License", "Topic :: Software Development :: Build Tools", "Topic :: Software Development :: Libraries :: Python Modules" ], "description": "================\nIsolation Recipe\n================\n\nThis buildout recipe's sole purpose is to isolate distribution packages and\nthere dependencies. This recipe was originally developed to be used in the\npackaging of Zope2 for the Debian operating system. The recipe can additionally\nbe used to populate a Python enviroment (or virtual environment). This can be\nhandy in situations where buildout is required to build the application, but\nthe developer/system administrator wants to use the application in a typical\nPython environment.\n\nIsolation of distributions\n==========================\n\nThe `buildout.recipe.isolation` recipe can be used to isolate distributions and\ntheir dependencies in a single directory. The recipe takes a number of options:\n\ndists\n A list of distributions to isolate given as one or more setuptools\n requirement strings. Each requirements string should be given on a\n separate line. The default is to use the part name as the distribution.\n\nexclude-dists (optional)\n A list of distributions that should be excluded from the isolation.\n\ndists-location (optional)\n A directory location where the isolated distributions should be put.\n This option\n defaults to a location in the buildout parts directory under the section\n name where the recipe is being used.\n\nscripts-location (optional)\n A directory location where the distribution scripts should be isolated.\n This option defaults to a location in the buildout parts directory under\n the part (or section) name followed by '-scripts' (e.g. for a part\n named *isolated* the default scripts directory name would be\n `isolated-scripts`).\n\n.. _pth_location_opt:\n\npth-location (optional)\n A directory location where a `.pth` file will be created for this isolation.\n This option defaults to a location in the buildout parts directory under\n the part (or section) name followed by '-pth' (e.g. for a part named\n *isolated*, the default pth directory name would be `isolated-pth`).\n\n __ pth_file_location_opt_\n\n The final name of the pth file will be the part name with a `.pth`\n extension. To reference the resulting `.pth` file, use the\n `pth-file-location`__ options.\n\n.. _pth_file_location_opt:\n\npth-file-location (reference only)\n A location where the `.pth` file lives. The resulting `.pth` file is used\n during the script generation process to provide a list of distributions\n that are isolated somewhere else on the filesystem.\n\n .. note:: This option can only be referenced. Later versions of this recipe\n may provide a means to change the pth filename.\n\nextra-pth (optional)\n A list of `.pth` files to include as part of the script initialization.\n\n This option resolves dependency issues caused by dependency isolation.\n For instance, if you are using `exclude-dists` and those distributions\n that are being exluded are required to run a script, you probably want\n to include the `.pth` file with locations to those dependencies.\n\nexclude-own-pth (optional)\n A boolean option, that when set will exclude the in context part's generated\n `.pth` file from inclusion in scripts. This option is closely tied to\n pth-file-location and extra-pth. This option is false by default.\n\n The reason this option has been included is because the locations in the\n `.pth` file main already be included in the python path via the `.pth`\n file's location in site-packages.\n\nexecutable (optional)\n The location of the Python executable. By default this is `sys.executable`.\n \n The executable specified is not executed in the recipe. The location is\n used as the shebang line during the scripts generation.\n\n.. _stage_locally_opt:\n\nstage-locally (optional)\n A boolean option to specify whether we should stage the resources or\n put them in there final destination. If this option is true, the values\n specified for `dist-location`, `script-location` and `pth-location` are\n used to generate the resources, but the resources are placed in\n the default parts locations. This option is handy for staged installation.\n\nRecipe deliverables\n-------------------\n\n- A directory that contains a specified distribution(s) package and its\n dependency package(s).\n- A directory that contains a `.pth` file, which lists the absolute path\n for each package in the isolation context.\n- A directory that contains the scripts that have been generated from the\n distribution(s) package and its dependency packages.\n\nHow it works\n============\n\n\n\nWe have a sample buildout. Let's update it's configuration file to\ninstall the demo package.\n\n >>> write(sample_buildout, 'buildout.cfg',\n ... \"\"\"\n ... [buildout]\n ... parts = demo\n ...\n ... [demo]\n ... recipe = buildout.recipe.isolation\n ... dists = demo<0.3\n ... find-links = %(server)s\n ... index = %(server)s/index\n ... \"\"\" % dict(server=link_server))\n\nIn this example, we limited ourselves to revisions before 0.3. We also\nspecified where to find distributions using the find-links option.\n\nIn order to control the distribution test data, we decided to use buildout's\ntesting index, shown below::\n\n >>> print get(link_server),\n \n bigdemo-0.1-pyN.N.egg
\n demo-0.1-py2.3.egg
\n demo-0.2-py2.3.egg
\n demo-0.3-py2.3.egg
\n demo-0.4c1-py2.3.egg
\n demoneeded-1.0.zip
\n demoneeded-1.1.zip
\n demoneeded-1.2c1.zip
\n extdemo-1.4.zip
\n index/
\n other-1.0-py2.3.egg
\n \n\nWe will be using this index through the testing structure and further\nexplaining the relationships before each of these distributions.\n\nLet's run the buildout::\n\n >>> import os\n >>> print system(buildout), #doctest: +ELLIPSIS\n Installing demo.\n Getting distribution for 'demo<0.3'.\n Got demo 0.2.\n Getting distribution for 'demoneeded'.\n install_dir ...\n Got demoneeded 1.2c1.\n demo: Copying demo to the destination directory.\n demo: Copying demoneeded to the destination directory.\n demo: Generated script '/sample-buildout/parts/demo-scripts/demo'.\n\nNow, if we look at the buildout parts directory for the isolation::\n\n >>> ls(sample_buildout, 'parts/demo')\n - demo-0.2-py2.3.egg\n d demoneeded-1.2c1-py2.3.egg\n\nThese distributions have been entered into a `.pth` file as well. This file\nis not directly useful to the buildout, but has it's place in a Python\nenvironment. The contents of the `.pth` file will be the absolute path for each\nof the distributions that have been installed into the isolation. Let's have\na look::\n\n >>> cat(sample_buildout, 'parts/demo-pth', 'demo.pth')\n /sample-buildout/parts/demo/demo-0.2-py2.6.egg\n /sample-buildout/parts/demo/demoneeded-1.2c1-py2.6.egg\n\n__ pth_file_location_opt_\n\nBy default the name of the `.pth` files will be the name of the buildout\nsection, which in this case is demo. You can change the location of the\n`.pth` file using the `pth-file-location`__ option.\n\n.. note:: When using the `pth-file-location` option, the directory that the\n `.pth` file will reside, must exist prior to running the buildout.\n If directory does not exist, an `IOError` will be raised and the\n buildout will fail.\n\nDependency exclusion\n--------------------\n\nLet's now try a buildout with a slightly larger example that we can use to\nillustrate the exclude dependencies from a certain isolation.\n\nLet's create a new buildout configuration based on the previous one. This\nconfiguration is setup to isolate the bigdemo distribution and its\ndependencies, but exclude the demoneeded dependency.\n\n >>> write(sample_buildout, 'buildout.cfg',\n ... \"\"\"\n ... [buildout]\n ... parts =\n ... demoneeded\n ... demo\n ... find-links = %(server)s\n ... index = %(server)s/index\n ...\n ... [demoneeded]\n ... recipe = buildout.recipe.isolation\n ... dists = demoneeded\n ...\n ... [demo]\n ... recipe = buildout.recipe.isolation\n ... dists = bigdemo\n ... exclude-dists = ${demoneeded:dists}\n ... \"\"\" % dict(server=link_server))\n\n >>> print system(buildout), #doctest: +ELLIPSIS\n Uninstalling demo.\n Installing demoneeded.\n demoneeded: Copying demoneeded to the destination directory.\n Installing demo.\n Getting distribution for 'bigdemo'.\n Got bigdemo 0.1.\n Getting distribution for 'demo'.\n Got demo 0.4c1.\n demo: Copying demo to the destination directory.\n demo: Copying bigdemo to the destination directory.\n demo: Generated script '/sample-buildout/parts/demo-scripts/demo'.\n\nCheck the isolated results:\n\n >>> ls(sample_buildout, 'parts/demo')\n - bigdemo-0.1-py2.6.egg\n - demo-0.4c1-py2.6.egg\n >>> ls(sample_buildout, 'parts/demoneeded')\n d demoneeded-1.2c1-py2.6.egg\n\nScript generation\n-----------------\n\nSome distributions supply command-line scripts with there packages. Buildout\ntypically generates these scripts for us, because it needs to supply the built\npackages to to script. It does this by injecting the distribution locations\ninto the Python system path. In some cases we do not want to inject anything\ninto the Python system path, because we may have deposited the generated .pth\nfile in a virtual environment's site-packages directory. While in other cases,\nwe might want to supply our .pth file as a mean for import resolution. Let's\ntake a closer look at both cases.\n\nFor the general case, we will likely want to supply our .pth file to the\nscript. Additionally, we will probably want to supply any .pth files that\ndependent isolations may have generated. Here is an example.\n\n >>> import sys\n >>> write(sample_buildout, 'buildout.cfg',\n ... \"\"\"\n ... [buildout]\n ... parts =\n ... demoneeded\n ... demo\n ... find-links = %(server)s\n ... index = %(server)s/index\n ...\n ... [demoneeded]\n ... recipe = buildout.recipe.isolation\n ... dists = demoneeded\n ...\n ... [demo]\n ... recipe = buildout.recipe.isolation\n ... dists = bigdemo\n ... exclude-dists = ${demoneeded:dists}\n ... extra-pth = ${demoneeded:pth-file-location}\n ... executable = %(python)s\n ... \"\"\" % dict(server=link_server, python=sys.executable))\n >>> print system(buildout), #doctest: +ELLIPSIS\n Uninstalling demo.\n Uninstalling demoneeded.\n Installing demoneeded.\n demoneeded: Copying demoneeded to the destination directory.\n Installing demo.\n demo: Copying demo to the destination directory.\n demo: Copying bigdemo to the destination directory.\n demo: Generated script '/sample-buildout/parts/demo-scripts/demo'.\n\nThe resulting script should have two .pth files in it. The demo.pth file has\nbeen defined and generated from the recipe in context. The demoneeded.pth file\nwas generated by the demoneeded section and pulled in using the extra-pth\nrecipe option.\n\n >>> if sys.platform == 'win32':\n ... script_name = 'demo-script.py'\n ... else:\n ... script_name = 'demo'\n >>> script_dir = 'parts/demo-scripts'\n >>> f = open(os.path.join(sample_buildout, script_dir, script_name))\n >>> shebang = f.readline().strip()\n >>> if shebang[:3] == '#!\"' and shebang[-1] == '\"':\n ... shebang = '#!'+shebang[3:-1]\n >>> shebang == '#!' + os.path.realpath(sys.executable)\n True\n >>> print f.read(), # doctest: +NORMALIZE_WHITESPACE\n \n import sys\n def pth_injector(pth_file):\n path_file = open(pth_file, 'r')\n sys.path[0:0] = [line\n for line in path_file.read().split('\\n')\n if line is not None]\n \n pth_files = ['/sample-buildout/parts/demo-pth/demo.pth', '/sample-buildout/parts/demoneeded-pth/demoneeded.pth']\n for pth in pth_files:\n pth_injector(pth)\n \n import eggrecipedemo\n \n if __name__ == '__main__':\n eggrecipedemo.main()\n >>> f.close()\n\nThe second case is where we have deposited the .pth files into a virtual\nenvironment. Let's setup a *fake* virtual environment structure inside the\nbuildout structure for demonstration sake.\n\n >>> virtenv = os.path.join(sample_buildout, 'virtenv')\n >>> mkdir(virtenv)\n >>> mkdir(virtenv, 'bin')\n >>> mkdir(virtenv, 'lib')\n >>> mkdir(virtenv, 'lib', 'python2.6')\n >>> mkdir(virtenv, 'lib', 'python2.6', 'site-packages')\n >>> site_pkgs = os.path.join(virtenv, 'lib', 'python2.6', 'site-packages')\n\nAll we really need for the purpose of this demonstration is the site-packages\ndirectory.\n\n >>> write(sample_buildout, 'buildout.cfg',\n ... \"\"\"\n ... [buildout]\n ... parts =\n ... demoneeded\n ... demo\n ... find-links = %(server)s\n ... index = %(server)s/index\n ...\n ... [demoneeded]\n ... recipe = buildout.recipe.isolation\n ... dists = demoneeded\n ... pth-file-location = %(site_pkgs)s\n ...\n ... [demo]\n ... recipe = buildout.recipe.isolation\n ... dists = bigdemo\n ... exclude-dists = ${demoneeded:dists}\n ... pth-file-location = %(site_pkgs)s\n ... exclude-own-pth = trUE\n ... python = %(python)s\n ... \"\"\" % dict(server=link_server, python=sys.executable,\n ... site_pkgs=site_pkgs))\n >>> print system(buildout), #doctest: +ELLIPSIS\n Uninstalling demo.\n Uninstalling demoneeded.\n Installing demoneeded.\n demoneeded: Copying demoneeded to the destination directory.\n Installing demo.\n demo: Copying demo to the destination directory.\n demo: Copying bigdemo to the destination directory.\n demo: Generated script '/sample-buildout/parts/demo-scripts/demo'.\n\nNow if we print out the demo script, we'll find no mention of the .pth files.\n\n >>> f = open(os.path.join(sample_buildout, script_dir, script_name))\n >>> shebang = f.readline().strip()\n >>> if shebang[:3] == '#!\"' and shebang[-1] == '\"':\n ... shebang = '#!'+shebang[3:-1]\n >>> shebang == '#!' + os.path.realpath(sys.executable)\n True\n >>> print f.read(), # doctest: +NORMALIZE_WHITESPACE\n \n import eggrecipedemo\n \n if __name__ == '__main__':\n eggrecipedemo.main()\n >>> f.close()\n\nWhy does this work? If we were to use the virtual environments Python\nexecutable, it would load the site-packages directory and any .pth files in\nit. This would in turn load the modules we built using the buildout.\n\n.. note:: We aren't actually using the virtual environments Python executable\n in this test case, but it is a simple matter of changing the executable\n value in the system_python section of this buildout.cfg.\n\nStaging the isolation\n---------------------\n\n__ stage_locally_opt_\n\nIn some situations it is handy to build the packages locally before\ntransfering these resources to a final destination. To do this we stage the\nisolation process with the `stage-locally`__ option.\n\nThis option will allow you to set the `dists-location`, `scripts-location` and\n`pth-file-location` as final destinations, but place the results in their\ndefault build location. The default build location, if you recall, is in the\nbuildout's parts directory.\n\n.. note:: The following example isn't necessarily useful beyond the test that\n it satisfies. If you're trying to figure out how to use the staging parts\n of this recipe and run into issues or parts you don't understand, please\n feel free to contact the author (see the package metadata for the address).\n\nLet's have a look at how this works by creating similar buildout to those about\nexecept now we are setting the `stage-locally` option to `true`::\n\n\n >>> write(sample_buildout, 'buildout.cfg',\n ... \"\"\"\n ... [buildout]\n ... parts =\n ... demo\n ... find-links = %(server)s\n ... index = %(server)s/index\n ...\n ... [demo]\n ... recipe = buildout.recipe.isolation\n ... dists = bigdemo\n ... dists-location = %(site_pkgs)s\n ... scripts-location = %(bin_dir)s\n ... pth-location = %(site_pkgs)s\n ... executable = %(python)s\n ... stage-locally = true\n ... \"\"\" % dict(server=link_server,\n ...\t bin_dir=os.path.join(virtenv, 'bin'),\n ...\t \t python=os.path.join(virtenv, 'bin', 'python'),\n ... \t site_pkgs=site_pkgs))\n >>> print system(buildout), #doctest: +ELLIPSIS\n Uninstalling demo.\n Uninstalling demoneeded.\n Installing demo.\n demo: Copying demo to the staging directory.\n demo: Copying demoneeded to the staging directory.\n demo: Copying bigdemo to the staging directory.\n demo: Can't find the executable on the filesystem. Perhaps this setup is not destine to be used on this machine. So we are using the given executable value /sample-buildout/virtenv/bin/python as is.\n demo: Generated script '/sample-buildout/parts/demo-scripts/demo'.\n\nTo verify that things have been staged, let's have a closer look at the demo\nscript to verify everything went as planned. For one, we expect the script\nto be in the parts directory::\n\n >>> parts_dir = os.path.join(sample_buildout, 'parts')\n >>> demo_script = os.path.join(parts_dir, 'demo-scripts', 'demo')\n >>> os.path.exists(demo_script)\n True\n >>> cat(demo_script)\n #!/sample-buildout/virtenv/bin/python\n \n import sys\n def pth_injector(pth_file):\n path_file = open(pth_file, 'r')\n sys.path[0:0] = [line\n for line in path_file.read().split('\\n')\n if line is not None]\n \n pth_files = ['/sample-buildout/virtenv/lib/python2.6/site-packages/demo.pth']\n for pth in pth_files:\n pth_injector(pth)\n \n import eggrecipedemo\n \n if __name__ == '__main__':\n eggrecipedemo.main()\n\nAnd also we want to check that the pth locations are correct and that the pth\nitself is in the staging area with parts::\n\n >>> demo_pth = os.path.join(parts_dir, 'demo-pth', 'demo.pth')\n >>> cat(demo_pth)\n /sample-buildout/virtenv/lib/python2.6/site-packages/demo-0.4c1-py2.1.egg\n /sample-buildout/virtenv/lib/python2.6/site-packages/demoneeded-1.2c1-py2.1.egg\n /sample-buildout/virtenv/lib/python2.6/site-packages/bigdemo-0.1-py2.1.egg\n\n\nIssues and help\n---------------\n\nIf you have issues or need assistance, file a bug report on `WebLion's project\nsite `_ or contact us via `IRC `_ or email.", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://weblion.psu.edu/trac/weblion/browser/weblion/buildout.recipe.isolation", "keywords": "development build", "license": "GPL 2", "maintainer": null, "maintainer_email": null, "name": "buildout.recipe.isolation", "package_url": "https://pypi.org/project/buildout.recipe.isolation/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/buildout.recipe.isolation/", "project_urls": { "Download": "UNKNOWN", "Homepage": "http://weblion.psu.edu/trac/weblion/browser/weblion/buildout.recipe.isolation" }, "release_url": "https://pypi.org/project/buildout.recipe.isolation/0.2.0/", "requires_dist": null, "requires_python": null, "summary": "Recipe for isolating Python distributions (packages and scripts).", "version": "0.2.0" }, "last_serial": 787110, "releases": { "0.1.1": [ { "comment_text": "", "digests": { "md5": "ea1db575b5d4c677fb4da36f28a51a91", "sha256": "f113cc08ed26503480e2a4ee39a596e16b77bb162844c707c1932bdbe45342c9" }, "downloads": -1, "filename": "buildout.recipe.isolation-0.1.1.tar.gz", "has_sig": false, "md5_digest": "ea1db575b5d4c677fb4da36f28a51a91", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 12043, "upload_time": "2010-09-15T20:12:39", "url": "https://files.pythonhosted.org/packages/73/cd/8cf03546cc4d938bc9a8a7b9197604f863add89d450461e05c5666ed5b2c/buildout.recipe.isolation-0.1.1.tar.gz" } ], "0.2.0": [ { "comment_text": "", "digests": { "md5": "501881dfc4b1306f5a0b7eaf934726f2", "sha256": "6d9a8c1c4bc6e9ea98b2066ec8e19106486b2074c65b649b0b62c612a692e2c3" }, "downloads": -1, "filename": "buildout.recipe.isolation-0.2.0.tar.gz", "has_sig": false, "md5_digest": "501881dfc4b1306f5a0b7eaf934726f2", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 17032, "upload_time": "2010-10-05T20:00:36", "url": "https://files.pythonhosted.org/packages/37/14/30539ce8cc22c4b89f0832c015b4daafad0b6e878dd06ce7fcd1a13e7618/buildout.recipe.isolation-0.2.0.tar.gz" } ], "0.3a1": [ { "comment_text": "", "digests": { "md5": "0d4a6ff24b78055fc34cf7eb4fe7cc27", "sha256": "202e61d97050e7c74e7eb5ef5cb901deec9cd281e571bf212fe2c27908302cb6" }, "downloads": -1, "filename": "buildout.recipe.isolation-0.3a1.tar.gz", "has_sig": false, "md5_digest": "0d4a6ff24b78055fc34cf7eb4fe7cc27", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 23269, "upload_time": "2012-04-09T15:15:43", "url": "https://files.pythonhosted.org/packages/d0/d3/f9235d9d240daba58aee6b34978aae2b7296167e525c13a67b91c39cadf0/buildout.recipe.isolation-0.3a1.tar.gz" }, { "comment_text": "", "digests": { "md5": "a66132edf5ac2b18e3182bb71e57511b", "sha256": "2e36e02f88d828743cd96e5901c6ebb555b267a9bf3b25a3f0c9eaff059508cb" }, "downloads": -1, "filename": "buildout.recipe.isolation-0.3a1.zip", "has_sig": false, "md5_digest": "a66132edf5ac2b18e3182bb71e57511b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 33492, "upload_time": "2012-04-09T15:15:44", "url": "https://files.pythonhosted.org/packages/b0/01/3cf1ef7b06817f5b4271ba42c4663094901227656d2eb8abebfa4dd375ec/buildout.recipe.isolation-0.3a1.zip" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "501881dfc4b1306f5a0b7eaf934726f2", "sha256": "6d9a8c1c4bc6e9ea98b2066ec8e19106486b2074c65b649b0b62c612a692e2c3" }, "downloads": -1, "filename": "buildout.recipe.isolation-0.2.0.tar.gz", "has_sig": false, "md5_digest": "501881dfc4b1306f5a0b7eaf934726f2", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 17032, "upload_time": "2010-10-05T20:00:36", "url": "https://files.pythonhosted.org/packages/37/14/30539ce8cc22c4b89f0832c015b4daafad0b6e878dd06ce7fcd1a13e7618/buildout.recipe.isolation-0.2.0.tar.gz" } ] }