Skip to content

Commit 6ec9dd4

Browse files
Snow-2043523: windows support for Python 3.13 (#2275)
(cherry picked from commit ba6e0f5)
1 parent 888e479 commit 6ec9dd4

File tree

6 files changed

+25
-33
lines changed

6 files changed

+25
-33
lines changed

.github/workflows/build_test.yml

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -129,15 +129,7 @@ jobs:
129129
download_name: win_amd64
130130
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
131131
cloud-provider: [aws, azure, gcp]
132-
# TODO: When there are prebuilt wheels accessible for our dependencies (i.e. numpy)
133-
# for Python 3.13 windows runs can be re-enabled. Currently, according to numpy:
134-
# "Numpy built with MINGW-W64 on Windows 64 bits is experimental, and only available for
135-
# testing. You are advised not to use it for production."
136-
exclude:
137-
- os:
138-
image_name: windows-latest
139-
download_name: win_amd64
140-
python-version: "3.13"
132+
141133
steps:
142134
- uses: actions/checkout@v4
143135
- name: Set up Python
@@ -175,12 +167,17 @@ jobs:
175167
- name: Install tox
176168
run: python -m pip install tox>=4
177169
- name: Run tests
170+
# To run a single test on GHA use the below command:
171+
# run: python -m tox run -e `echo py${PYTHON_VERSION/\./}-single-ci | sed 's/ /,/g'`
178172
run: python -m tox run -e `echo py${PYTHON_VERSION/\./}-{extras,unit,integ,pandas,sso}-ci | sed 's/ /,/g'`
173+
179174
env:
180175
PYTHON_VERSION: ${{ matrix.python-version }}
181176
cloud_provider: ${{ matrix.cloud-provider }}
182177
PYTEST_ADDOPTS: --color=yes --tb=short
183178
TOX_PARALLEL_NO_SPINNER: 1
179+
# To specify the test name (in single test mode) pass this env variable:
180+
# SINGLE_TEST_NAME: test/file/path::test_name
184181
shell: bash
185182
- name: Combine coverages
186183
run: python -m tox run -e coverage --skip-missing-interpreters false

ci/docker/connector_test/Dockerfile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@ FROM $BASE_IMAGE
33

44
RUN yum install -y java-11-openjdk
55

6-
# TODO: When there are prebuilt wheels accessible for our dependencies (i.e. numpy)
7-
# for Python 3.13 this rust cargo install command can be removed.
6+
# Our dependencies rely on the Rust toolchain being available in the build-time environment (https://github.com/pyca/cryptography/issues/5771)
87
RUN yum -y install rust cargo
98

109
# This is to solve permission issue, read https://denibertovic.com/posts/handling-permissions-with-docker-volumes/

ci/docker/connector_test_lambda/Dockerfile313

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,13 @@ FROM public.ecr.aws/lambda/python:3.13-x86_64
22

33
WORKDIR /home/user/snowflake-connector-python
44

5-
# TODO: When there are prebuilt wheels accessible for our dependencies (i.e. numpy)
6-
# for Python 3.13 all dnf ... commands installing building kits can be removed.
7-
8-
# Install necessary packages and compilers - we need to build numpy for newer version
9-
# Update dnf and install development tools
105
RUN dnf -y update && \
11-
dnf -y install \
12-
gcc \
13-
gcc-c++ \
14-
make \
15-
python3-devel \
16-
openblas-devel \
17-
lapack-devel && \
186
dnf clean all
7+
8+
# Our dependencies rely on the Rust toolchain being available in the build-time environment (https://github.com/pyca/cryptography/issues/5771)
199
RUN dnf -y install rust cargo
2010
RUN dnf -y upgrade
2111

22-
2312
RUN chmod 777 /home/user/snowflake-connector-python
2413
ENV PATH="${PATH}:/opt/python/cp313-cp313/bin/"
2514
ENV PYTHONPATH="${PYTHONPATH}:/home/user/snowflake-connector-python/ci/docker/connector_test_lambda/"

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ development =
8181
Cython
8282
coverage
8383
more-itertools
84-
numpy<2.1.0
84+
numpy<=2.2.4
8585
pendulum!=2.1.1
8686
pexpect
8787
pytest<7.5.0

src/snowflake/connector/file_transfer_agent.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
from typing import IO, TYPE_CHECKING, Any, Callable, TypeVar
2121

2222
from .azure_storage_client import SnowflakeAzureRestClient
23-
from .compat import GET_CWD, IS_WINDOWS
23+
from .compat import IS_WINDOWS
2424
from .constants import (
2525
AZURE_CHUNK_SIZE,
2626
AZURE_FS,
@@ -826,17 +826,17 @@ def _expand_filenames(self, locations: list[str]) -> list[str]:
826826
for file_name in locations:
827827
if self._command_type == CMD_TYPE_UPLOAD:
828828
file_name = os.path.expanduser(file_name)
829-
if not os.path.isabs(file_name):
830-
file_name = os.path.join(GET_CWD(), file_name)
831829
if (
832830
IS_WINDOWS
833831
and len(file_name) > 2
834832
and file_name[0] == "/"
835833
and file_name[2] == ":"
836834
):
837-
# Windows path: /C:/data/file1.txt where it starts with slash
838-
# followed by a drive letter and colon.
835+
# Since python 3.13 os.path.isabs returns different values for URI or paths starting with a '/' etc. on Windows (https://github.com/python/cpython/issues/125283)
836+
# Windows path: /C:/data/file1.txt is not treated as absolute - could be prefixed with another Windows driver's letter and colon.
839837
file_name = file_name[1:]
838+
if not os.path.isabs(file_name):
839+
file_name = os.path.abspath(file_name)
840840
files = glob.glob(file_name)
841841
canonical_locations += files
842842
else:

tox.ini

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ source = src/snowflake/connector
1818
[tox]
1919
minversion = 4
2020
envlist = fix_lint,
21-
py{39,310,311,312,313}-{extras,unit-parallel,integ,pandas,sso},
21+
py{39,310,311,312,313}-{extras,unit-parallel,integ,pandas,sso,single},
2222
coverage
2323
skip_missing_interpreters = true
2424

@@ -36,8 +36,10 @@ setenv =
3636
# aio is only supported on python >= 3.10
3737
unit-integ: SNOWFLAKE_TEST_TYPE = (unit or integ)
3838
!unit-!integ: SNOWFLAKE_TEST_TYPE = (unit or integ)
39+
auth: SNOWFLAKE_TEST_TYPE = auth and not aio
3940
unit: SNOWFLAKE_TEST_TYPE = unit and not aio
4041
integ: SNOWFLAKE_TEST_TYPE = integ and not aio
42+
single: SNOWFLAKE_TEST_TYPE = single
4143
parallel: SNOWFLAKE_PYTEST_OPTS = {env:SNOWFLAKE_PYTEST_OPTS:} -n auto
4244
# Add common parts into pytest command
4345
SNOWFLAKE_PYTEST_COV_LOCATION = {env:JUNIT_REPORT_DIR:{toxworkdir}}/junit.{envname}-{env:cloud_provider:dev}.xml
@@ -54,6 +56,7 @@ passenv =
5456
# Github Actions provided environmental variables
5557
GITHUB_ACTIONS
5658
JENKINS_HOME
59+
SINGLE_TEST_NAME
5760
# This is required on windows. Otherwise pwd module won't be imported successfully,
5861
# see https://github.com/tox-dev/tox/issues/1455
5962
USERNAME
@@ -62,11 +65,12 @@ passenv =
6265
commands =
6366
# Test environments
6467
# Note: make sure to have a default env and all the other special ones
65-
!pandas-!sso-!lambda-!extras: {env:SNOWFLAKE_PYTEST_CMD_IGNORE_AIO} -m "{env:SNOWFLAKE_TEST_TYPE} and not sso and not pandas and not lambda and not aio" {posargs:} test
68+
!pandas-!sso-!lambda-!extras-!single: {env:SNOWFLAKE_PYTEST_CMD_IGNORE_AIO} -m "{env:SNOWFLAKE_TEST_TYPE} and not sso and not pandas and not lambda and not aio" {posargs:} test
6669
pandas: {env:SNOWFLAKE_PYTEST_CMD_IGNORE_AIO} -m "{env:SNOWFLAKE_TEST_TYPE} and pandas and not aio" {posargs:} test
6770
sso: {env:SNOWFLAKE_PYTEST_CMD_IGNORE_AIO} -m "{env:SNOWFLAKE_TEST_TYPE} and sso and not aio" {posargs:} test
6871
lambda: {env:SNOWFLAKE_PYTEST_CMD_IGNORE_AIO} -m "{env:SNOWFLAKE_TEST_TYPE} and lambda and not aio" {posargs:} test
6972
extras: python -m test.extras.run {posargs:}
73+
single: {env:SNOWFLAKE_PYTEST_CMD} -s "{env:SINGLE_TEST_NAME}" {posargs:}
7074

7175
[testenv:olddriver]
7276
basepython = python3.9
@@ -90,7 +94,9 @@ skip_install = True
9094
setenv = {[testenv]setenv}
9195
passenv = {[testenv]passenv}
9296
commands =
93-
{env:SNOWFLAKE_PYTEST_CMD_IGNORE_AIO} -m "not skipolddriver" -vvv {posargs:} test
97+
# Unit and pandas tests are already skipped for the old driver (see test/conftest.py). Avoid walking those
98+
# directories entirely to avoid loading any potentially incompatible subdirectories' own conftest.py files.
99+
{env:SNOWFLAKE_PYTEST_CMD_IGNORE_AIO} --ignore=test/unit --ignore=test/pandas -m "not skipolddriver" -vvv {posargs:} test
94100

95101
[testenv:noarrowextension]
96102
basepython = python3.9
@@ -188,6 +194,7 @@ markers =
188194
# Test type markers
189195
integ: integration tests
190196
unit: unit tests
197+
auth: tests for authentication
191198
skipolddriver: skip for old driver tests
192199
# Other markers
193200
timeout: tests that need a timeout time

0 commit comments

Comments
 (0)