Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

请教一下如何patch mysqlclient? #18

Open
sylvoslee opened this issue Aug 21, 2020 · 5 comments
Open

请教一下如何patch mysqlclient? #18

sylvoslee opened this issue Aug 21, 2020 · 5 comments

Comments

@sylvoslee
Copy link

No description provided.

@thehackercat
Copy link

@sylvoslee 你好, 以 debian 下 mysqlclient==1.3.15 为例:

下列代码可以实现 patch mysqlclient

root@1a9a408a4e04:/# python
Python 2.7.18 (default, Apr 20 2020, 19:34:11)
[GCC 8.3.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from MySQLdb import _mysql
>>> _mysql_so = _mysql.__file__
>>> import greenify
>>> if greenify.patch_lib(_mysql_so):
...     print("Successfully patch mysql.so")
...
Successfully patch mysql.so

@sylvoslee
Copy link
Author

我的是Ubuntu 16,按你提供的执行,greenify.patch_lib(_mysql_so)返回False,什么原因

@thehackercat
Copy link

可以提供下具体的环境吗,如

  • mysql 版本
  • ubuntu 版本(执行 uname -a)
  • python 版本
  • mysql driver 路径

@houzhiqiang
Copy link

我执行也返回False,我是在python:3.8的docker容器里面
mysql 版本: mysql8
Debian(uname -a): Linux 03ed33a24640 4.19.0-12-amd64 #1 SMP Debian 4.19.152-1 (2020-10-18) x86_64 GNU/Linux
cat /etc/debian_version: 10.6
python 版本: 3.8.6
mysql driver 路径: /usr/local/lib/python3.8/site-packages/MySQLdb/_mysql.cpython-38-x86_64-linux-gnu.so
mysqlclient 版本: 2.0.3

@everpcpc
Copy link
Contributor

greenify 是将网络操作都 patch 掉,但是现在版本的 libmysqlclient-python 网络操作都在 libmysqlclient.so.18 里了,所以会 patch 失败。如果要正常 patch 的话,mysqlclient-python 需要静态链接:
将这里 https://github.com/PyMySQL/mysqlclient/blob/master/site.cfg#L3static = False 改成 True 再重新安装

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants