Bug 1153666
Summary: | NLTK doesn't work with Python 2.7 cartridge | ||
---|---|---|---|
Product: | OpenShift Container Platform | Reporter: | Brenton Leanhardt <bleanhar> |
Component: | ImageStreams | Assignee: | Jason DeTiberus <jdetiber> |
Status: | CLOSED ERRATA | QA Contact: | libra bugs <libra-bugs> |
Severity: | medium | Docs Contact: | |
Priority: | medium | ||
Version: | 2.2.0 | CC: | adellape, gpei, jokerman, libra-bugs, libra-onpremise-devel, mfojtik, mmccomas, pruan |
Target Milestone: | --- | ||
Target Release: | --- | ||
Hardware: | Unspecified | ||
OS: | Unspecified | ||
Whiteboard: | |||
Fixed In Version: | openshift-origin-cartridge-python-1.30.1.1-1 | Doc Type: | Bug Fix |
Doc Text: |
An update to Python 2.7 dependencies cause some dependencies using C extensions to not run properly when using the Python 2.7 cartridge, and applications using the cartridge could return an Internal Server Error. This bug fix updates the Python cartridge to set the WSGIApplicationGroupdirective to %{GLOBAL}, which forces a WSGI application to run within the first interpreter. As a result, applications using the cartridge are once again accessible. After applying this update, a cartridge upgrade is required.
|
Story Points: | --- |
Clone Of: | 1151494 | Environment: | |
Last Closed: | 2014-12-10 13:24:24 UTC | Type: | Bug |
Regression: | --- | Mount Type: | --- |
Documentation: | --- | CRM: | |
Verified Versions: | Category: | --- | |
oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | |
Cloudforms Team: | --- | Target Upstream Version: | |
Embargoed: | |||
Bug Depends On: | 1151494 | ||
Bug Blocks: |
Description
Brenton Leanhardt
2014-10-16 13:42:14 UTC
Verify this bug on puddle 2.2/2014-11-24.3 with package openshift-origin-cartridge-python-1.30.1.1-1.el6op.noarch 1. Create a python-2.7 app rhc app create py27 python-2.7 2. Create a directory named "nltk_data" in the app repo and set env var named "NLTK_DATA" $ mkdir py27/nltk_data $ rhc set-env NLTK_DATA=remote_directory_of_nltk_data_folder -a py27 3. Add 'nltk' and 'web.py' modules into setup.py file to install, like below: from setuptools import setup setup(name='YourAppName', version='1.0', description='OpenShift App', author='Your Name', author_email='example', url='http://www.python.org/sigs/distutils-sig/', install_requires=['nltk','web.py'], ) 4. Overwrite the wsgi.py file as below: #!/usr/bin/env python # -*- coding: utf-8 -*- import os virtenv = os.environ['APPDIR'] + '/virtenv/' os.environ['PYTHON_EGG_CACHE'] = os.path.join(virtenv, 'lib/python2.6/site-packages') virtualenv = os.path.join(virtenv, 'bin/activate_this.py') try: execfile(virtualenv, dict(__file__=virtualenv)) except IOError: pass # # IMPORTANT: Put any additional includes below this line. If placed above this # line, it's possible required libraries won't be in your searchable path # import nltk import web from nltk.tokenize import word_tokenize from nltk.tokenize import WordPunctTokenizer tokenizer = WordPunctTokenizer() urls = ( '/', 'index' ) render = web.template.render('app-root/repo/wsgi/templates/') class index: def GET(self): tokenizer.tokenize('Hello World') return 'Hello World' application = web.application(urls, globals()).wsgifunc() # # Below for testing only # if __name__ == '__main__': from wsgiref.simple_server import make_server httpd = make_server('localhost', 8051, application) # Wait for a single request, serve it and quit. httpd.handle_request() 5. Perform git push git add . && git commit -amp && git push 6. Access the app home page via browser After step 6, the app can be accessed and get "Hello World" text. Since the problem described in this bug report should be resolved in a recent advisory, it has been closed with a resolution of ERRATA. For information on the advisory, and where to find the updated files, follow the link below. If the solution does not work for you, open a new bug report. https://rhn.redhat.com/errata/RHBA-2014-1979.html |