Skip to content

Commit 72cd031

Browse files
committed
WL#14813: Add support for Python 3.10
1 parent 13d7c21 commit 72cd031

File tree

10 files changed

+382
-12
lines changed

10 files changed

+382
-12
lines changed

CHANGES.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ v8.0.28
1212
=======
1313

1414
- WL#14814: Remove support for TLS 1.0 and 1.1
15+
- WL#14813: Add support for Python 3.10
1516
- WL#14720: Support for Multi Factor authentication (pure Python)
1617

1718
v8.0.27

cpydist/bdist_msi.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ class DistMSI(BaseCommand):
8585
_connc_lib = None
8686
_dist_path = {}
8787
_fix_txt_files = {}
88-
_supported_versions = ["3.6", "3.7", "3.8", "3.9"]
88+
_supported_versions = ["3.6", "3.7", "3.8", "3.9", "3.10"]
8989
_with_cext = False
9090
_wxs = None
9191

@@ -98,7 +98,7 @@ def initialize_options(self):
9898
self.dist_dir = None
9999
self.wix_install = wix.WIX_INSTALL_PATH
100100
self.wix_required_version = wix.WIX_REQUIRED_VERSION
101-
self.python_version = get_python_version()[:3]
101+
self.python_version = get_python_version()
102102
self.prepare_stage = False
103103
self.combine_stage = False
104104
self.edition = EDITION
@@ -114,16 +114,16 @@ def finalize_options(self):
114114
if not self.prefix:
115115
self.prefix = os.path.join(
116116
self.build_base, DIST_PATH_FORMAT.format(
117-
self.python_version[0], self.python_version[2]))
117+
self.python_version[0], self.python_version[2:]))
118118

119119
for py_ver in self._supported_versions:
120120
self._dist_path[py_ver] = os.path.join(
121121
self.build_base, DIST_PATH_FORMAT.format(*py_ver.split(".")))
122122

123123
if self.python_version not in self._supported_versions:
124124
raise DistutilsOptionError(
125-
"The --python-version should be a supported version, one "
126-
"of {}".format(",".join(self._supported_versions)))
125+
"The --python-version {} should be a supported version, one "
126+
"of {}".format(self.python_version, ",".join(self._supported_versions)))
127127

128128
if self.python_version[0] != get_python_version()[0]:
129129
raise DistutilsError(

cpydist/data/msi/PY310.wxs

Lines changed: 269 additions & 0 deletions
Large diffs are not rendered by default.

cpydist/data/msi/product.wxs

Lines changed: 91 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
<Property Id="PREVIOUSVERSIONSINSTALLED37" Secure="yes" />
1818
<Property Id="PREVIOUSVERSIONSINSTALLED38" Secure="yes" />
1919
<Property Id="PREVIOUSVERSIONSINSTALLED39" Secure="yes" />
20+
<Property Id="PREVIOUSVERSIONSINSTALLED310" Secure="yes" />
2021

2122
<Upgrade Id="c4142c28-7de9-11e7-b269-5ce0c50b9cbc">
2223
<UpgradeVersion OnlyDetect="no" IncludeMinimum="yes" IncludeMaximum="yes"
@@ -42,6 +43,12 @@
4243
Maximum="$(var.Major_Version).$(var.Minor_Version).$(var.Patch_Version)"
4344
Property="PREVIOUSVERSIONSINSTALLED39"/>
4445
</Upgrade>
46+
<Upgrade Id="a0b2ca29-5516-4cb1-a076-178068896350">
47+
<UpgradeVersion OnlyDetect="no" IncludeMinimum="yes" IncludeMaximum="yes"
48+
Minimum="1.0.0"
49+
Maximum="$(var.Major_Version).$(var.Minor_Version).$(var.Patch_Version)"
50+
Property="PREVIOUSVERSIONSINSTALLED310"/>
51+
</Upgrade>
4552

4653
<!-- Obtain location of the Python interpreters installed on the system-->
4754

@@ -133,8 +140,30 @@
133140
<?endif?>
134141
</Property>
135142

143+
<!-- Python 3.10 -->
144+
<Property Id="PYTHON310INSTALLPATH_ALL">
145+
<?if "$(var.Platform)"="x64" ?>
146+
<RegistrySearch Id="Python310InstallPathAll64" Root="HKLM" Type="raw"
147+
Key="Software\Python\PythonCore\3.10\InstallPath" Win64="yes"/>
148+
<?else?>
149+
<!-- Starting from python 3.5, 32bit Python install has a '-32' in its InstallPath reg key path -->
150+
<RegistrySearch Id="Python310InstallPathAll32" Root="HKLM" Type="raw"
151+
Key="Software\Python\PythonCore\3.10-32\InstallPath" Win64="no"/>
152+
<?endif?>
153+
</Property>
154+
<Property Id="PYTHON310INSTALLPATH_CURRENT">
155+
<?if "$(var.Platform)"="x64" ?>
156+
<RegistrySearch Id="Python310InstallPathCurrent64" Root="HKCU" Type="raw"
157+
Key="Software\Python\PythonCore\3.10\InstallPath" Win64="yes"/>
158+
<?else?>
159+
<!-- Starting from python 3.5, 32bit Python install has a '-32' in its InstallPath reg key path -->
160+
<RegistrySearch Id="Python310InstallPathCurrent32" Root="HKCU" Type="raw"
161+
Key="Software\Python\PythonCore\3.10-32\InstallPath" Win64="no"/>
162+
<?endif?>
163+
</Property>
164+
136165
<Condition Message="We are unable to locate any supported Python version like Python v$(var.PythonVersion) $(var.Platform) edition. We only support Python installed using the Microsoft Windows Installer (MSI or EXE) downloaded from http://www.python.org/download/. Please check the Connector/Python manual on http://dev.mysql.com/doc/ for more information.">
137-
Installed OR PYTHON36INSTALLPATH_ALL OR PYTHON36INSTALLPATH_CURRENT OR PYTHON37INSTALLPATH_ALL OR PYTHON37INSTALLPATH_CURRENT OR PYTHON38INSTALLPATH_ALL OR PYTHON38INSTALLPATH_CURRENT OR PYTHON39INSTALLPATH_ALL OR PYTHON39INSTALLPATH_CURRENT
166+
Installed OR PYTHON36INSTALLPATH_ALL OR PYTHON36INSTALLPATH_CURRENT OR PYTHON37INSTALLPATH_ALL OR PYTHON37INSTALLPATH_CURRENT OR PYTHON38INSTALLPATH_ALL OR PYTHON38INSTALLPATH_CURRENT OR PYTHON39INSTALLPATH_ALL OR PYTHON39INSTALLPATH_CURRENT OR PYTHON310INSTALLPATH_ALL OR PYTHON310INSTALLPATH_CURRENT
138167
</Condition>
139168

140169
<Media Id="1" Cabinet="ConnectorPython_Python.cab" EmbedCab="yes"/>
@@ -242,6 +271,31 @@
242271
</Directory>
243272
</Directory>
244273

274+
<Directory Id="INSTALLDIRP310" Name="Python310">
275+
<Directory Id="PythonLibDir310" Name="Lib">
276+
<Directory Id="SitePackagesDir310" Name="site-packages">
277+
<Directory Id="EggInfoDir310" Name="mysql_connector_python-$(var.FullVersion)-py3.10.egg-info"/>
278+
<Directory Id="MySQLXPackageDir310" Name="mysqlx">
279+
<Directory Id="MySQLXPB2Dir310" Name="protobuf"/>
280+
<Directory Id="MySQLXLocalesDir310" Name="locales">
281+
<Directory Id="MySQLXLocalesEngDir310" Name="eng"/>
282+
</Directory>
283+
</Directory>
284+
<Directory Id="MySQLPackageDir310" Name="mysql">
285+
<Directory Id="VendorDir310" Name="vendor">
286+
<Directory Id="VendorPluginDir310" Name="plugin"/>
287+
</Directory>
288+
<Directory Id="ConnectorPackageDir310" Name="connector">
289+
<Directory Id="DjangoDir310" Name="django"/>
290+
<Directory Id="ConnectorLocalesDir310" Name="locales">
291+
<Directory Id="LocalesEngDir310" Name="eng"/>
292+
</Directory>
293+
</Directory>
294+
</Directory>
295+
</Directory>
296+
</Directory>
297+
</Directory>
298+
245299
<!-- Common files-->
246300
<Directory Id="$(var.Directory_Id)">
247301
<Directory Id="CompanyDir" Name="MySQL">
@@ -410,6 +464,31 @@
410464
<?endif?>
411465
</Feature>
412466
<?endif?>
467+
468+
<!-- Python 3.10 -->
469+
<?if $(var.BDist310) != "" ?>
470+
<Feature Id="Python310" Title="C/py for Python 3.10" Level="1"
471+
ConfigurableDirectory ="INSTALLDIRP310" Absent="allow">
472+
<Condition Level='0'>Not PYTHON310INSTALLPATH_ALL AND Not PYTHON310INSTALLPATH_CURRENT AND Not Installed</Condition>
473+
<ComponentRef Id="EggInfo310"/>
474+
<ComponentRef Id="MySQLPackage310"/>
475+
<?if $(var.HaveCExt310) = 1 ?>
476+
<ComponentRef Id="Vendor310"/>
477+
<ComponentRef Id="VendorPlugin310"/>
478+
<?endif?>
479+
<ComponentRef Id="ConnectorPackage310"/>
480+
<ComponentRef Id="ConnectorLocales310"/>
481+
<ComponentRef Id="LocalesEng310"/>
482+
<ComponentRef Id="DjangoBackend310"/>
483+
<ComponentRef Id="MySQLXPackage310"/>
484+
<ComponentRef Id="MySQLXPackagePB2310"/>
485+
<ComponentRef Id="MySQLXLocales310"/>
486+
<ComponentRef Id="MySQLXLocalesEng310"/>
487+
<?if $(var.HaveCExt310) = 1 ?>
488+
<ComponentRef Id="CExtension310"/>
489+
<?endif?>
490+
</Feature>
491+
<?endif?>
413492
</Feature>
414493

415494
<!-- Python 3.6 -->
@@ -432,6 +511,11 @@
432511
<CustomAction Id="SetInstallDirAllP39" Property="INSTALLDIRP39" Value="[PYTHON39INSTALLPATH_ALL]"/>
433512
<CustomAction Id="ErrDebug39" Error="Installdir: [INSTALLDIRP39]"/>
434513

514+
<!-- Python 3.10 -->
515+
<CustomAction Id="SetInstallDirCurrentP310" Property="INSTALLDIRP310" Value="[PYTHON310INSTALLPATH_CURRENT]"/>
516+
<CustomAction Id="SetInstallDirAllP310" Property="INSTALLDIRP310" Value="[PYTHON310INSTALLPATH_ALL]"/>
517+
<CustomAction Id="ErrDebug310" Error="Installdir: [INSTALLDIRP310]"/>
518+
435519
<UIRef Id="WixUI_CPY"/>
436520
<Property Id="WIXUI_INSTALLDIR" Value="INSTALLDIR"/>
437521
<UIRef Id="WixUI_ErrorProgressText" />
@@ -454,6 +538,9 @@
454538
<!-- Python 3.9 -->
455539
<Custom Action="SetInstallDirCurrentP39" After="AppSearch">NOT Installed AND PYTHON39INSTALLPATH_CURRENT</Custom>
456540
<Custom Action="SetInstallDirAllP39" After="AppSearch">NOT Installed AND PYTHON39INSTALLPATH_ALL</Custom>
541+
<!-- Python 3.10 -->
542+
<Custom Action="SetInstallDirCurrentP310" After="AppSearch">NOT Installed AND PYTHON310INSTALLPATH_CURRENT</Custom>
543+
<Custom Action="SetInstallDirAllP310" After="AppSearch">NOT Installed AND PYTHON310INSTALLPATH_ALL</Custom>
457544
</InstallExecuteSequence>
458545

459546
<InstallUISequence>
@@ -470,6 +557,9 @@
470557
<!-- Python 3.9 -->
471558
<Custom Action="SetInstallDirCurrentP39" After="AppSearch">NOT Installed AND PYTHON39INSTALLPATH_CURRENT</Custom>
472559
<Custom Action="SetInstallDirAllP39" After="AppSearch">NOT Installed AND PYTHON39INSTALLPATH_ALL</Custom>
560+
<!-- Python 3.10 -->
561+
<Custom Action="SetInstallDirCurrentP310" After="AppSearch">NOT Installed AND PYTHON310INSTALLPATH_CURRENT</Custom>
562+
<Custom Action="SetInstallDirAllP310" After="AppSearch">NOT Installed AND PYTHON310INSTALLPATH_ALL</Custom>
473563
</InstallUISequence>
474564
</Product>
475565
</Wix>

cpydist/data/msi/upgrade_codes.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@
5050
"3.6": "c4142c28-7de9-11e7-b269-5ce0c50b9cbc",
5151
"3.7": "212eea22-7fa3-11e8-81b7-37e66f6c3ce1",
5252
"3.8": "17977a6e-9384-4ec8-84e6-37524546e7f7",
53-
"3.9": "180e8431-7c58-4b72-b206-c6d7bd5487d6"
53+
"3.9": "180e8431-7c58-4b72-b206-c6d7bd5487d6",
54+
"3.10": "250f2e4a-1b15-46f8-adb7-7880ac35d616"
5455
}
5556
}
5657

cpydist/utils.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2020, Oracle and/or its affiliates.
1+
# Copyright (c) 2020, 2021, Oracle and/or its affiliates.
22
#
33
# This program is free software; you can redistribute it and/or modify
44
# it under the terms of the GNU General Public License, version 2.0, as
@@ -581,6 +581,7 @@ def add_arch_dep_elems(xml_path, result_path, for32=False, add_vs_redist=True):
581581
result_path (str): Path to save the resulting xml.
582582
add_vs_redist (bool): Add the VS redistributable requirement.
583583
"""
584+
LOGGER.info("Adding arch_dep_elems xml to:%s", xml_path)
584585
dom_msi = parse(xml_path)
585586
if for32:
586587
LOGGER.info("No elements to add for 32bit msi")

cpydist/wix.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,7 @@ def compile(self, wxs=None, out=None, parameters=None):
189189
r"cpydist\data\msi\PY37.wxs",
190190
r"cpydist\data\msi\PY38.wxs",
191191
r"cpydist\data\msi\PY39.wxs",
192+
r"cpydist\data\msi\PY310.wxs",
192193
r"cpydist\data\msi\cpy_msi_gui.wxs",
193194
]
194195
if parameters:
@@ -231,6 +232,7 @@ def link(self, wixobj=None, base_path=None, data_path=None):
231232
r"{}\PY37.wixobj".format(data_path),
232233
r"{}\PY38.wixobj".format(data_path),
233234
r"{}\PY39.wixobj".format(data_path),
235+
r"{}\PY310.wixobj".format(data_path),
234236
]
235237

236238
self._run_tool("light.exe", cmdargs)

setup.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@
131131
"Programming Language :: Python :: 3.7",
132132
"Programming Language :: Python :: 3.8",
133133
"Programming Language :: Python :: 3.9",
134+
"Programming Language :: Python :: 3.10",
134135
"Topic :: Database",
135136
"Topic :: Software Development",
136137
"Topic :: Software Development :: Libraries :: Application Frameworks",

src/mysql_capi.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
2929
*/
3030

31+
#define PY_SSIZE_T_CLEAN 1
32+
3133
#include <stdio.h>
3234
#include <stdlib.h>
3335
#include <time.h>
@@ -2086,7 +2088,8 @@ MySQL_query(MySQL *self, PyObject *args, PyObject *kwds)
20862088
{
20872089
PyObject *buffered= NULL, *raw= NULL, *raw_as_string= NULL,
20882090
*query_attrs= NULL, *retval= NULL;
2089-
int res= 0, stmt_length;
2091+
int res= 0;
2092+
Py_ssize_t stmt_length;
20902093
char *stmt= NULL;
20912094
static char *kwlist[]=
20922095
{

src/mysqlxpb/mysqlxpb.cc

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2017, 2020, Oracle and/or its affiliates.
2+
* Copyright (c) 2017, 2021, Oracle and/or its affiliates.
33
*
44
* This program is free software; you can redistribute it and/or modify
55
* it under the terms of the GNU General Public License, version 2.0, as
@@ -28,6 +28,8 @@
2828
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
2929
*/
3030

31+
#define PY_SSIZE_T_CLEAN 1
32+
3133
#include "python_cast.h"
3234
#include "python.h"
3335
#include "mysqlx/mysqlx.pb.h"
@@ -791,7 +793,7 @@ static PyObject* ParseMessage(PyObject* self, PyObject* args) {
791793
PyObject* result = NULL;
792794
const char* type_name;
793795
const char* data;
794-
int data_size;
796+
Py_ssize_t data_size;
795797

796798
if (PyArg_ParseTuple(args, "ss#", &type_name, &data, &data_size))
797799
result = ParseMessageImpl(type_name, data, data_size);
@@ -849,7 +851,7 @@ static PyObject* ParseServerMessage(PyObject* self, PyObject* args) {
849851
PyObject* result = NULL;
850852
int type;
851853
const char* message_data;
852-
int message_data_size;
854+
Py_ssize_t message_data_size;
853855

854856
if (PyArg_ParseTuple(args, "is#", &type, &message_data, &message_data_size))
855857
{

0 commit comments

Comments
 (0)