From 9c11255b1f9f4b89bb4d50448ddeb1935dc06f8f Mon Sep 17 00:00:00 2001 From: Oleg Broytman Date: Sat, 28 Sep 2024 19:53:08 +0300 Subject: [PATCH 1/5] Build(.gitignore): Ignore `*.pyo` --- .gitignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 45dca299..6026efae 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,4 @@ -*.pyc +*.py[co] __pycache__ py3k dist From 76287b467ce135c4aba4e08b05234e031430d839 Mon Sep 17 00:00:00 2001 From: Oleg Broytman Date: Sat, 28 Sep 2024 19:53:36 +0300 Subject: [PATCH 2/5] Build(setup.py): Update trove classifiers --- setup.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/setup.py b/setup.py index 41a50bbc..5e66b3b4 100644 --- a/setup.py +++ b/setup.py @@ -55,6 +55,8 @@ def run(self): 'Programming Language :: Python :: 2', 'Programming Language :: Python :: 3', 'Topic :: Database', + 'Topic :: Database :: Front-Ends', + 'Topic :: Software Development :: Libraries :: Python Modules', ] setup( From edecad4fcae7820836348d346996e9dcdda9838f Mon Sep 17 00:00:00 2001 From: Oleg Broytman Date: Sat, 28 Sep 2024 19:47:11 +0300 Subject: [PATCH 3/5] Split `__version__.py` Avoid importing `cymysql` in `setup.py`. --- cymysql/__init__.py | 5 ++--- cymysql/__version__.py | 2 ++ setup.py | 16 +++++++++++++++- 3 files changed, 19 insertions(+), 4 deletions(-) create mode 100644 cymysql/__version__.py diff --git a/cymysql/__init__.py b/cymysql/__init__.py index 8ec8574c..c03a7b1b 100644 --- a/cymysql/__init__.py +++ b/cymysql/__init__.py @@ -38,7 +38,8 @@ if sys.version_info[0] > 2: from cymysql import aio -VERSION = (1, 0, 2) +from .__version__ import VERSION, __version__ + threadsafety = 1 apilevel = "2.0" paramstyle = "format" @@ -91,8 +92,6 @@ def connect(*args, **kwargs): NULL = "NULL" -__version__ = '%s.%s.%s' % VERSION - __all__ = [ 'BINARY', 'Binary', 'Connection', 'DATE', 'Date', 'Time', 'Timestamp', 'DateFromTicks', 'TimeFromTicks', 'TimestampFromTicks', diff --git a/cymysql/__version__.py b/cymysql/__version__.py new file mode 100644 index 00000000..097abcfd --- /dev/null +++ b/cymysql/__version__.py @@ -0,0 +1,2 @@ +VERSION = (1, 0, 2) +__version__ = '%s.%s.%s' % VERSION diff --git a/setup.py b/setup.py index 5e66b3b4..d9658031 100644 --- a/setup.py +++ b/setup.py @@ -1,6 +1,20 @@ +from os.path import abspath, dirname, join import sys + from setuptools import setup, Command, Extension +versionpath = join(abspath(dirname(__file__)), 'cymysql', '__version__.py') +cymysql_version = {} + +if sys.version_info[:2] == (2, 7): + execfile(versionpath, cymysql_version) # noqa: F821 'execfile' Py3 + +elif sys.version_info >= (3, 5): + exec(open(versionpath, 'r').read(), cymysql_version) + +else: + raise ImportError("CyMySQL requires Python 2.7 or 3.5+") + try: from Cython.Build import cythonize ext_modules = cythonize([ @@ -40,7 +54,7 @@ def run(self): cmdclass = {'test': TestCommand} -version_tuple = __import__('cymysql').VERSION +version_tuple = cymysql_version['VERSION'] if version_tuple[2] is not None: version = "%d.%d.%s" % version_tuple From 28b7c4792b9f2b1e5e1ee834d0634d4eb35ee2d0 Mon Sep 17 00:00:00 2001 From: Oleg Broytman Date: Sat, 28 Sep 2024 19:48:09 +0300 Subject: [PATCH 4/5] Build: Add `pyproject.toml` Force installation of Cython. Fixes: #39. --- pyproject.toml | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 pyproject.toml diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 00000000..c07b1d35 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["setuptools", "Cython"] +build-backend = "setuptools.build_meta" From 2c678c0b914ea766e64141712f24e014452c48e6 Mon Sep 17 00:00:00 2001 From: Oleg Broytman Date: Sat, 28 Sep 2024 19:49:03 +0300 Subject: [PATCH 5/5] Docs: Update `README.rst` --- README.rst | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/README.rst b/README.rst index 488df960..dba9f73b 100644 --- a/README.rst +++ b/README.rst @@ -9,8 +9,7 @@ This package contains a python MySQL client library. It is a fork project from PyMySQL https://pymysql.readthedocs.io/en/latest/. -CyMySQL accerarates by Cython, and support not only python 2 but also python 3. -It still can work without Cython as a pure python driver. +CyMySQL is accerarated by Cython and supports Python versions 2 and 3. Documentation on the MySQL client/server protocol can be found here: http://dev.mysql.com/doc/internals/en/client-server-protocol.html @@ -18,23 +17,32 @@ http://dev.mysql.com/doc/internals/en/client-server-protocol.html Requirements ------------- -- Python 2.7, 3.8+ -- MySQL 5.7 or higher - +- Python 2.7, 3.5+ +- MySQL 5.7 or higher, MariaDB + Installation -------------- -Install cython (optional) -++++++++++++++++++++++++++++++ +Install Cython (optional) ++++++++++++++++++++++++++ -:: +Installation of Cython is optional. +CyMySQL will run faster if installed, but will also run without it. - # pip install cython +Since the bottleneck is often in MySQL queries, installing Cython may not be effective in many cases. -Installation of cython is optional. -CyMySQL will run faster if installed, but will also run without it. +For most versions of pip and setuptools installation of Cython is not +required as it's listed in pyproject.tompl as a required build-time +dependency and will be installed automatically in the isolated build +environemnt. This means it's not possible to install CyMySQL in +pure-Python mode without cythonized extensions. + +For older versions of pip and setuptools that don't obey pyproject.tompl +install Cython yourself: -Since the bottleneck is often in MySQL queries, installing cython may not be effective in many cases. +:: + + # pip install cython Install cymysql ++++++++++++++++++++++++++++++