Go to:
Gentoo Home
Documentation
Forums
Lists
Bugs
Planet
Store
Wiki
Get Gentoo!
Gentoo's Bugzilla – Attachment 236421 Details for
Bug 325379
Scripts generated by python.eclass's python_generate_wrapper_scripts() are not compatible with virtualenv
Home
|
New
–
[Ex]
|
Browse
|
Search
|
Privacy Policy
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch to python.eclass so that wrapper scripts handle virtualenvs correctly (?)
python_eclass_virtual_env.patch (text/plain), 4.84 KB, created by
Mike Nerone
on 2010-06-24 17:42:14 UTC
(
hide
)
Description:
Patch to python.eclass so that wrapper scripts handle virtualenvs correctly (?)
Filename:
MIME Type:
Creator:
Mike Nerone
Created:
2010-06-24 17:42:14 UTC
Size:
4.84 KB
patch
obsolete
>--- python.eclass.orig 2010-05-29 12:05:51.000000000 -0500 >+++ python.eclass 2010-06-24 12:39:53.635082688 -0500 >@@ -1032,24 +1032,80 @@ > import sys > > EPYTHON_re = re.compile(r"^python(\d+\.\d+)$") >+PYTHON_V_re = re.compile(r" (\d+\.\d+)") > python_shebang_re = re.compile(r"^#! *(${EPREFIX}/usr/bin/python|(${EPREFIX})?/usr/bin/env +(${EPREFIX}/usr/bin/)?python)") > python_verification_output_re = re.compile("^GENTOO_PYTHON_TARGET_SCRIPT_PATH supported\n$") > >+try: >+ virtual_env = os.environ['VIRTUAL_ENV'] >+except KeyError: >+ virtual_env = None >+ >+if virtual_env: >+ python_interpreter_path = os.path.join(virtual_env, 'bin', 'python') >+ try: >+ python_process = subprocess.Popen( >+ [python_interpreter_path, "--version"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT) >+ if python_process.wait() != 0: >+ raise ValueError >+ except (OSError, ValueError): >+ sys.stderr.write("Execution of '%s --version' failed\n" % python_interpreter_path) >+ sys.exit(1) >+ >+ PYTHON_V = python_process.stdout.read() >+ if not isinstance(PYTHON_V, str): >+ # Python 3 >+ PYTHON_V = PYTHON_V.decode() >+ PYTHON_V = PYTHON_V.rstrip("\n") >+ >+ PYTHON_V_matched = PYTHON_V_re.search(PYTHON_V) >+ if PYTHON_V_matched: >+ PYTHON_ABI = PYTHON_V_matched.group(1) >+ else: >+ sys.stderr.write("'%s --version' printed unrecognized value '%s'\n" % (python_interpreter_path, PYTHON_V)) >+ sys.exit(1) >+else: > EOF > if [[ "$?" != "0" ]]; then > die "${FUNCNAME}(): Generation of '$1' failed" > fi > if [[ "${respect_EPYTHON}" == "1" ]]; then > cat << EOF >> "${file}" >-EPYTHON = os.environ.get("EPYTHON") >-if EPYTHON: >- EPYTHON_matched = EPYTHON_re.match(EPYTHON) >- if EPYTHON_matched: >- PYTHON_ABI = EPYTHON_matched.group(1) >+ EPYTHON = os.environ.get("EPYTHON") >+ if EPYTHON: >+ EPYTHON_matched = EPYTHON_re.match(EPYTHON) >+ if EPYTHON_matched: >+ PYTHON_ABI = EPYTHON_matched.group(1) >+ else: >+ sys.stderr.write("EPYTHON variable has unrecognized value '%s'\n" % EPYTHON) >+ sys.exit(1) > else: >- sys.stderr.write("EPYTHON variable has unrecognized value '%s'\n" % EPYTHON) >- sys.exit(1) >-else: >+ try: >+ eselect_process = subprocess.Popen(["${EPREFIX}/usr/bin/eselect", "python", "show"${eselect_python_option:+, $(echo "\"")}${eselect_python_option}${eselect_python_option:+$(echo "\"")}], stdout=subprocess.PIPE) >+ if eselect_process.wait() != 0: >+ raise ValueError >+ except (OSError, ValueError): >+ sys.stderr.write("Execution of 'eselect python show${eselect_python_option:+ }${eselect_python_option}' failed\n") >+ sys.exit(1) >+ >+ EPYTHON = eselect_process.stdout.read() >+ if not isinstance(EPYTHON, str): >+ # Python 3 >+ EPYTHON = EPYTHON.decode() >+ EPYTHON = EPYTHON.rstrip("\n") >+ >+ EPYTHON_matched = EPYTHON_re.match(EPYTHON) >+ if EPYTHON_matched: >+ PYTHON_ABI = EPYTHON_matched.group(1) >+ else: >+ sys.stderr.write("'eselect python show${eselect_python_option:+ }${eselect_python_option}' printed unrecognized value '%s'\n" % EPYTHON) >+ sys.exit(1) >+EOF >+ if [[ "$?" != "0" ]]; then >+ die "${FUNCNAME}(): Generation of '$1' failed" >+ fi >+ else >+ cat << EOF >> "${file}" > try: > eselect_process = subprocess.Popen(["${EPREFIX}/usr/bin/eselect", "python", "show"${eselect_python_option:+, $(echo "\"")}${eselect_python_option}${eselect_python_option:+$(echo "\"")}], stdout=subprocess.PIPE) > if eselect_process.wait() != 0: >@@ -1074,32 +1130,6 @@ > if [[ "$?" != "0" ]]; then > die "${FUNCNAME}(): Generation of '$1' failed" > fi >- else >- cat << EOF >> "${file}" >-try: >- eselect_process = subprocess.Popen(["${EPREFIX}/usr/bin/eselect", "python", "show"${eselect_python_option:+, $(echo "\"")}${eselect_python_option}${eselect_python_option:+$(echo "\"")}], stdout=subprocess.PIPE) >- if eselect_process.wait() != 0: >- raise ValueError >-except (OSError, ValueError): >- sys.stderr.write("Execution of 'eselect python show${eselect_python_option:+ }${eselect_python_option}' failed\n") >- sys.exit(1) >- >-EPYTHON = eselect_process.stdout.read() >-if not isinstance(EPYTHON, str): >- # Python 3 >- EPYTHON = EPYTHON.decode() >-EPYTHON = EPYTHON.rstrip("\n") >- >-EPYTHON_matched = EPYTHON_re.match(EPYTHON) >-if EPYTHON_matched: >- PYTHON_ABI = EPYTHON_matched.group(1) >-else: >- sys.stderr.write("'eselect python show${eselect_python_option:+ }${eselect_python_option}' printed unrecognized value '%s'\n" % EPYTHON) >- sys.exit(1) >-EOF >- if [[ "$?" != "0" ]]; then >- die "${FUNCNAME}(): Generation of '$1' failed" >- fi > fi > cat << EOF >> "${file}" > >@@ -1123,7 +1153,8 @@ > > if python_shebang_matched: > try: >- python_interpreter_path = "${EPREFIX}/usr/bin/%s" % EPYTHON >+ if not virtual_env: >+ python_interpreter_path = "${EPREFIX}/usr/bin/%s" % EPYTHON > os.environ["GENTOO_PYTHON_TARGET_SCRIPT_PATH_VERIFICATION"] = "1" > python_verification_process = subprocess.Popen([python_interpreter_path, "-c", "pass"], stdout=subprocess.PIPE) > del os.environ["GENTOO_PYTHON_TARGET_SCRIPT_PATH_VERIFICATION"]
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 325379
: 236421