Skip to content

Commit

Permalink
Patch jaydebeapi (#4402)
Browse files Browse the repository at this point in the history
* Patch jaydebeapi

We need to carry a custom patch for jaydebeapi as it doesn't support
latest jpype currently and no release is happening.

See baztian/jaydebeapi#107.

* Add patch for py3

* Fix py3 path

* Apply patch at the right time
  • Loading branch information
therve authored and derekwbrown committed Nov 9, 2019
1 parent 1fb75b9 commit 3a353a8
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
--- a/__init__.py
+++ b/__init__.py
@@ -173,7 +173,19 @@ def _jdbc_connect_jpype(jclassname, url, driver_args, jars, libs):
# jvm_path = ('/usr/lib/jvm/java-6-openjdk'
# '/jre/lib/i386/client/libjvm.so')
jvm_path = jpype.getDefaultJVMPath()
- jpype.startJVM(jvm_path, *args)
+ jpype_ver = 0.
+ if hasattr(jpype, '__version__'):
+ try:
+ ver_match = re.match('\d+\.\d+', jpype.__version__)
+ if ver_match:
+ jpype_ver = float(ver_match.group(0))
+ except ValueError:
+ pass
+ if jpype_ver < 0.7:
+ jpype.startJVM(jvm_path, *args)
+ else:
+ jpype.startJVM(jvm_path, *args, ignoreUnrecognized=True,
+ convertStrings=True)
if not jpype.isThreadAttachedToJVM():
jpype.attachThreadToJVM()
if _jdbc_name_to_const is None:
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
--- a/__init__.py
+++ b/__init__.py
@@ -173,7 +173,19 @@ def _jdbc_connect_jpype(jclassname, url, driver_args, jars, libs):
# jvm_path = ('/usr/lib/jvm/java-6-openjdk'
# '/jre/lib/i386/client/libjvm.so')
jvm_path = jpype.getDefaultJVMPath()
- jpype.startJVM(jvm_path, *args)
+ jpype_ver = 0.
+ if hasattr(jpype, '__version__'):
+ try:
+ ver_match = re.match('\d+\.\d+', jpype.__version__)
+ if ver_match:
+ jpype_ver = float(ver_match.group(0))
+ except ValueError:
+ pass
+ if jpype_ver < 0.7:
+ jpype.startJVM(jvm_path, *args)
+ else:
+ jpype.startJVM(jvm_path, *args, ignoreUnrecognized=True,
+ convertStrings=True)
if not jpype.isThreadAttachedToJVM():
jpype.attachThreadToJVM()
if _jdbc_name_to_const is None:
2 changes: 2 additions & 0 deletions omnibus/config/software/datadog-agent-integrations-py2.rb
Original file line number Diff line number Diff line change
Expand Up @@ -257,8 +257,10 @@
# Patch applies to only one file: set it explicitly as a target, no need for -p
if windows?
patch :source => "create-regex-at-runtime.patch", :target => "#{python_2_embedded}/Lib/site-packages/yaml/reader.py"
patch :source => "jpype_0_7.patch", :target => "#{python_2_embedded}/Lib/site-packages/jaydebeapi/__init__.py"
else
patch :source => "create-regex-at-runtime.patch", :target => "#{install_dir}/embedded/lib/python2.7/site-packages/yaml/reader.py"
patch :source => "jpype_0_7.patch", :target => "#{install_dir}/embedded/lib/python2.7/site-packages/jaydebeapi/__init__.py"
end

end
Expand Down
8 changes: 8 additions & 0 deletions omnibus/config/software/datadog-agent-integrations-py3.rb
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,14 @@
command "#{pip} install --no-deps .", :env => nix_build_env, :cwd => "#{project_dir}/#{check}"
end
end

# Patch applies to only one file: set it explicitly as a target, no need for -p
if windows?
patch :source => "jpype_0_7.patch", :target => "#{python_3_embedded}/Lib/site-packages/jaydebeapi/__init__.py"
else
patch :source => "jpype_0_7.patch", :target => "#{install_dir}/embedded/lib/python3.7/site-packages/jaydebeapi/__init__.py"
end

end

# Run pip check to make sure the agent's python environment is clean, all the dependencies are compatible
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
fixes:
- |
Carry a custom patch for jaydebeapi to support latest jpype.

0 comments on commit 3a353a8

Please sign in to comment.