Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@ repos:
src/snowflake/connector/nanoarrow_cpp/ArrowIterator/flatcc/.*\.h|
)$
- id: check-yaml
exclude: .github/repo_meta.yaml
exclude: >
(?x)^(
.github/repo_meta.yaml|
ci/anaconda/recipe/meta.yaml|
)$
- id: debug-statements
- id: check-ast
- repo: https://github.com/asottile/yesqa
Expand Down
1 change: 0 additions & 1 deletion ci/anaconda/bld.bat

This file was deleted.

1 change: 0 additions & 1 deletion ci/anaconda/build.sh

This file was deleted.

9 changes: 9 additions & 0 deletions ci/anaconda/conda_build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Check https://snow-external.slack.com/archives/C02D68R4D0D/p1678899446863299 for context about using --numpy
conda install conda-build
conda install conda-verify
conda install diffutils
conda build ci/anaconda/recipe/ --python 3.9
conda build ci/anaconda/recipe/ --python 3.10
conda build ci/anaconda/recipe/ --python 3.11
conda build ci/anaconda/recipe/ --python 3.12
conda build ci/anaconda/recipe/ --python 3.13
29 changes: 0 additions & 29 deletions ci/anaconda/meta.yaml

This file was deleted.

17 changes: 17 additions & 0 deletions ci/anaconda/package_builder.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash

export SNOWFLAKE_CONNECTOR_PYTHON_DIR=/repo/snowflake-connector-python
export CONDA_BLD_PATH=/repo/conda-bld

mkdir -p $CONDA_BLD_PATH
cd "$SNOWFLAKE_CONNECTOR_PYTHON_DIR"
# Build with .tar.bz2 (pkg_format = 1) and .conda (pkg_format = 2).
conda config --set conda_build.pkg_format 1
bash ./ci/anaconda/conda_build.sh
conda config --set conda_build.pkg_format 2
bash ./ci/anaconda/conda_build.sh
conda config --remove-key conda_build.pkg_format
conda build purge
cd $CONDA_BLD_PATH
conda index .
chmod -R o+w,g+w $CONDA_BLD_PATH
81 changes: 81 additions & 0 deletions ci/anaconda/recipe/meta.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
{% set name = "snowflake-connector-python" %}
{% set version = os.environ.get('SNOWFLAKE_CONNECTOR_PYTHON_VERSION', 0) %}
{% set build_number = os.environ.get('PUBLIC_CONNECTOR_BUILD_NUMBER', 0) %}

package:
name: {{ name|lower }}
version: {{ version }}

source:
path: ../../..

build:
number: {{ build_number }}
string: "py{{ py }}_{{ build_number }}"
script:
- export SF_NO_COPY_ARROW_LIB=1 # [unix]
- export SF_ARROW_LIBDIR="${PREFIX}/lib" # [unix]
- export ENABLE_EXT_MODULES=true # [unix]
- {{ PYTHON }} -m pip install . --no-use-pep517 --no-deps -vvv
entry_points:
- snowflake-dump-ocsp-response = snowflake.connector.tool.dump_ocsp_response:main
- snowflake-dump-ocsp-response-cache = snowflake.connector.tool.dump_ocsp_response_cache:main
- snowflake-dump-certs = snowflake.connector.tool.dump_certs:main

requirements:
build:
- {{ compiler("c") }}
- {{ compiler("cxx") }}
- libgcc-ng
- libstdcxx-ng
- patch # [not win]
host:
- setuptools >=40.6.0
- wheel
- cython
- python {{ python }}
run:
{% if py == 39 %}
- python >=3.9,<3.10.0a0
{% elif py == 310 %}
- python >=3.10,<3.11.0a0
{% elif py == 311 %}
- python >=3.11,<3.12.0a0
{% elif py == 312 %}
- python >=3.12,<3.13.0a0
{% elif py == 313 %}
- python >=3.13,<3.14.0a0
{% else %}
- python
{% endif %}
- asn1crypto >0.24.0,<2.0.0
- cryptography >=44.0.1
- pyOpenSSL >=24.0.0,<26.0.0
- pyjwt >=2.10.1,<3.0.0
- pytz
- requests >=2.32.4,<3.0.0
- packaging
- charset-normalizer >=2,<4
- idna >=3.7,<4
- urllib3 >=1.26.5,<2.0.0 # [py<310]
- certifi >=2024.7.4
- typing_extensions >=4.3,<5
- filelock >=3.5,<4
- sortedcontainers >=2.4.0
- platformdirs >=2.6.0,<5.0.0
- tomlkit
- boto3 >=1.24
- botocore >=1.24
test:
requires:
- pip
imports:
- snowflake
- snowflake.connector
- snowflake.connector.nanoarrow_arrow_iterator # [unix]
commands:
- pip check

about:
home: https://github.com/snowflakedb/snowflake-connector-python
summary: Snowflake Connector for Python
106 changes: 106 additions & 0 deletions ci/anaconda/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@

# Before manual running, do something similar to the following in command line.
# export WORKSPACE=/home/jdoe/my_workspace;
# export PUBLIC_CONNECTOR_BUILD_NUMBER=321;
# export aarch64_base_image=<location_of_centos8_aarch64_base_image>;
# export x86_base_image=<location_of_centos8_x86_base_image>;

# Here miniconda-install.sh is just a installer that I downloaded from Anaconda official site,
# https://repo.anaconda.com/miniconda/


if [[ -z $WORKSPACE ]]; then
# Development on dev machine
WORKSPACE=$HOME
fi

# ===== Build docker image =====
cd $WORKSPACE

# Validate dependency sync before building
python3 -m venv tmp_validate_env
source tmp_validate_env/bin/activate
pip install pyyaml
python3 $WORKSPACE/snowflake-connector-python/ci/anaconda/validate_deps_sync.py
if [[ $? -ne 0 ]]; then
echo "[FAILURE] setup.cfg and meta.yaml dependencies are not in sync"
deactivate
rm -rf tmp_validate_env
exit 1
fi
deactivate
rm -rf tmp_validate_env

docker build \
--build-arg ARCH=$(uname -m) \
--build-arg AARCH64_BASE_IMAGE="${aarch64_base_image}" \
--build-arg X86_BASE_IMAGE="${x86_base_image}" \
-t snowflake_connector_python_image \
-f - . <<'DOCKERFILE'
# Use different base images based on target platform

ARG ARCH
ARG AARCH64_BASE_IMAGE=artifactory.int.snowflakecomputing.com/development-docker-virtual/arm64v8/centos:8
ARG X86_BASE_IMAGE=artifactory.int.snowflakecomputing.com/development-docker-virtual/centos:8

FROM ${AARCH64_BASE_IMAGE} AS base-aarch64

FROM ${X86_BASE_IMAGE} AS base-x86_64



# Select the appropriate base image based on target architecture

FROM base-${ARCH} AS base

COPY miniconda-install.sh .



RUN chmod 0755 miniconda-install.sh



RUN mkdir -p /etc/miniconda && bash miniconda-install.sh -b -u -p /etc/miniconda/



RUN ln -s /etc/miniconda/bin/conda /usr/bin/conda && rm miniconda-install.sh
DOCKERFILE

# Go back to the original directory
cd $WORKSPACE


# Check to make sure repos exist to build conda packages
if [[ -d $WORKSPACE/snowflake-connector-python ]]; then
echo "Check snowflake-connector-python repo exists - PASSED"
else
echo "[FAILURE] Please clone snowflake-connector-python repo at $WORKSPACE/snowflake-connector-python"
fi

# Extract connector version if not provided
if [[ -z "$SNOWFLAKE_CONNECTOR_PYTHON_VERSION" ]]; then
VERSION_FILE="$WORKSPACE/snowflake-connector-python/src/snowflake/connector/version.py"
if [[ -f "$VERSION_FILE" ]]; then
SNOWFLAKE_CONNECTOR_PYTHON_VERSION=$( \
grep -Eo 'VERSION\s*=\s*\([^)]*\)' "$VERSION_FILE" \
| grep -Eo '[0-9]+' \
| paste -sd '.' - \
)
export SNOWFLAKE_CONNECTOR_PYTHON_VERSION
fi
fi

# Run packager in docker image
docker run \
-v $WORKSPACE/snowflake-connector-python/:/repo/snowflake-connector-python \
-v $WORKSPACE/conda-bld:/repo/conda-bld \
-e SNOWFLAKE_CONNECTOR_PYTHON_VERSION=${SNOWFLAKE_CONNECTOR_PYTHON_VERSION} \
-e PUBLIC_CONNECTOR_BUILD_NUMBER=${PUBLIC_CONNECTOR_BUILD_NUMBER} \
snowflake_connector_python_image \
/repo/snowflake-connector-python/ci/anaconda/package_builder.sh

# Cleanup image for disk space
docker container prune -f
docker rmi snowflake_connector_python_image
Loading
Loading