{"id":123,"date":"2011-12-06T21:47:38","date_gmt":"2011-12-06T20:47:38","guid":{"rendered":"http:\/\/blog.gocept.com\/?p=123"},"modified":"2012-12-03T15:08:46","modified_gmt":"2012-12-03T14:08:46","slug":"getting-sys-path-out-of-buildout","status":"publish","type":"post","link":"https:\/\/blog.gocept.com\/2011\/12\/06\/getting-sys-path-out-of-buildout\/","title":{"rendered":"Getting sys.path out of buildout"},"content":{"rendered":"

A wrinkly part of buildout<\/a>‘s design is that the PYTHONPATH is not easily available outside of scripts generated by buildout itself.<\/p>\n

I’ve been using the following workaround in some of my development tools for a while and found it quite helpful, even though it’s hacky and rough around the edges:<\/p>\n

#!\/bin\/bash\r\nif [ ! -e bin\/wpy ]; then\r\n\u00a0\u00a0\u00a0 bin\/buildout install wpy\r\nfi\r\nexport PYTHONPATH=$(bin\/wpy -c \"import sys; print ':'.join([p for p in sys.path if not p.startswith('\/usr')])\")\r\n# do real work here<\/pre>\n

This needs a part that installs a python interpreter into the buildout; I’m using this in my ~\/.buildout\/default.cfg, since all projects I deal with have a [test] part:<\/p>\n

[wpy]\r\nrecipe = zc.recipe.egg\r\neggs = ${test:eggs}\r\ninterpreter = wpy<\/pre>\n

A variation on this theme is this script which generates a TAGS file without the need for a special recipe (like z3c.recipe.tag<\/a>) just to get the PYTHONPATH:<\/p>\n

#!\/bin\/bash\r\nif [ ! -e bin\/wpy ]; then\r\n\u00a0\u00a0\u00a0 bin\/buildout install wpy\r\nfi\r\nexport IFS=\r\nPATHS=$(bin\/wpy -c \"import sys; print '\\n'.join([p for p in sys.path if not p.startswith('\/usr')])\")\r\necho $PATHS | ctags --python-kinds=-i -R -e -L -<\/pre>\n","protected":false},"excerpt":{"rendered":"

A wrinkly part of buildout‘s design is that the PYTHONPATH is not easily available outside of scripts generated by buildout itself. I’ve been using the following workaround in some of my development tools for a while and found it quite helpful, even though it’s hacky and rough around the edges: #!\/bin\/bash if [ ! -e … Continue reading “Getting sys.path out of buildout”<\/span><\/a><\/p>\n","protected":false},"author":10315341,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_coblocks_attr":"","_coblocks_dimensions":"","_coblocks_responsive_height":"","_coblocks_accordion_ie_support":"","advanced_seo_description":"","jetpack_seo_html_title":"","jetpack_seo_noindex":false,"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_newsletter_tier_id":0,"footnotes":"","jetpack_publicize_message":"","jetpack_is_tweetstorm":false,"jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","enabled":false}}},"categories":[10221],"tags":[],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_likes_enabled":true,"jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/pFP3y-1Z","jetpack-related-posts":[{"id":268,"url":"https:\/\/blog.gocept.com\/2012\/11\/09\/python-2-and-3-compatible-builds-with-zc-buildout\/","url_meta":{"origin":123,"position":0},"title":"Python 2 and 3 compatible builds with zc.buildout","author":"","date":"November 9, 2012","format":false,"excerpt":"Creating a single-source build environment with zc.buildout that works for both Python 2 and 3 is a bit of a hassle. This blog post shows how to do it for a minimal demo project. During the sprints at PyCon DE 2012, we tried to make the upcoming 1.0 release of\u2026","rel":"","context":"In "en"","block_context":{"text":"en","link":"https:\/\/blog.gocept.com\/category\/en\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":3219,"url":"https:\/\/blog.gocept.com\/2018\/04\/17\/allow-hosts-in-buildout-considered-harmful\/","url_meta":{"origin":123,"position":1},"title":"“allow-hosts” in buildout considered harmful","author":"Michael Howitz","date":"April 17, 2018","format":false,"excerpt":"Today we had the following error message when re-installing a project from scratch: While: Installing. Getting section application. Initializing section application. Installing recipe zc.zope3recipes. Getting distribution for 'zc.zope3recipes==0.13.0'. Error: Couldn't find a distribution for 'zc.zope3recipes==0.13.0'. Yes this is a really old recipe but it still exists on PyPI. We are\u2026","rel":"","context":"In "en"","block_context":{"text":"en","link":"https:\/\/blog.gocept.com\/category\/en\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":1340,"url":"https:\/\/blog.gocept.com\/2013\/07\/31\/reproducable-automated-deployments-on-raspberrypi-with-batou\/","url_meta":{"origin":123,"position":2},"title":"Reproducable automated deployments on RaspberryPi with batou","author":"Daniel Havlik","date":"July 31, 2013","format":false,"excerpt":"For continuous integration during development, we use Jenkins to automatically run tests for all projects we maintain. Some time ago we wanted to increase visibility of the results, so we set up a Raspberry Pi driving a few meters of LPD8806-based LED strip on which we can address single LEDs\u2026","rel":"","context":"In "en"","block_context":{"text":"en","link":"https:\/\/blog.gocept.com\/category\/en\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":1525,"url":"https:\/\/blog.gocept.com\/2015\/03\/06\/manage-javascript-dependencies-with-bowerstatic\/","url_meta":{"origin":123,"position":3},"title":"Manage JavaScript dependencies with BowerStatic","author":"","date":"March 6, 2015","format":false,"excerpt":"Last month I explained how to use Fanstatic to manage JS dependencies. Since we were more and more displeased by using Fanstatic, we recently switched to BowerStatic, the new kid on the block. Since the setup is a bit more complicated and you need more tools to have the same\u2026","rel":"","context":"In "en"","block_context":{"text":"en","link":"https:\/\/blog.gocept.com\/category\/en\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":1262,"url":"https:\/\/blog.gocept.com\/2013\/04\/17\/running-tests-using-gocept-selenium-on-travis-ci\/","url_meta":{"origin":123,"position":4},"title":"Running tests using gocept.selenium on Travis-CI","author":"Michael Howitz","date":"April 17, 2013","format":false,"excerpt":"Travis-CI\u00a0is a\u00a0free hosted continuous integration platform for the open source community. It has a good integration with Github, so each push to a project runs the tests \u00a0of the project. gocept.selenium\u00a0is a python package our company has developed as a test-friendly Python API for Selenium\u00a0which allows to run tests in\u2026","rel":"","context":"In "en"","block_context":{"text":"en","link":"https:\/\/blog.gocept.com\/category\/en\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":1361,"url":"https:\/\/blog.gocept.com\/2013\/08\/28\/run-tests-using-layers-with-py-test\/","url_meta":{"origin":123,"position":5},"title":"Run tests using layers with py.test","author":"Michael Howitz","date":"August 28, 2013","format":false,"excerpt":"TL;DR Use gocept.pytestlayer. Long Story We have many test suites which use test layers (e. g. the ones from plone.testing). We want to use py.test\u00a0and all its fancy features to have a modern test runner. There was no way to convert such tests partly: either you have to port the\u2026","rel":"","context":"In "en"","block_context":{"text":"en","link":"https:\/\/blog.gocept.com\/category\/en\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"_links":{"self":[{"href":"https:\/\/blog.gocept.com\/wp-json\/wp\/v2\/posts\/123"}],"collection":[{"href":"https:\/\/blog.gocept.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.gocept.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.gocept.com\/wp-json\/wp\/v2\/users\/10315341"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.gocept.com\/wp-json\/wp\/v2\/comments?post=123"}],"version-history":[{"count":3,"href":"https:\/\/blog.gocept.com\/wp-json\/wp\/v2\/posts\/123\/revisions"}],"predecessor-version":[{"id":328,"href":"https:\/\/blog.gocept.com\/wp-json\/wp\/v2\/posts\/123\/revisions\/328"}],"wp:attachment":[{"href":"https:\/\/blog.gocept.com\/wp-json\/wp\/v2\/media?parent=123"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.gocept.com\/wp-json\/wp\/v2\/categories?post=123"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.gocept.com\/wp-json\/wp\/v2\/tags?post=123"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}