Skip to content
Merged
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
43 changes: 43 additions & 0 deletions ci/docker/python-wheel-windows-test-vs2017.dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

# NOTE: You must update PYTHON_WHEEL_WINDOWS_IMAGE_REVISION in .env
# when you update this file.

# based on mcr.microsoft.com/windows/servercore:ltsc2019
# contains choco and vs2017 preinstalled
FROM abrarov/msvc-2017:2.11.0

# Add unix tools to path
RUN setx path "%path%;C:\Program Files\Git\usr\bin"

# Remove previous installations of python from the base image
# NOTE: a more recent base image (tried with 2.12.1) comes with python 3.9.7
# and the msi installers are failing to remove pip and tcl/tk "products" making
# the subsequent choco python installation step failing for installing python
# version 3.9.* due to existing python version
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the record, are there other upstream images that we could use?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could create our own images with Visual C++ based from the official Microsoft ones FROM mcr.microsoft.com/windows/servercore:ltsc2019 example here: https://learn.microsoft.com/en-us/previous-versions/visualstudio/visual-studio-2017/install/build-tools-container?view=vs-2017 but I wanted to use the same one we have on the python-wheels for consistency: https://github.com/apache/arrow/blob/master/ci/docker/python-wheel-windows-vs2017.dockerfile#L23
There was someone working on updating the Visual C++ version to 2019, maybe I could try to create new Dockerfile images removing the abrarov/msvc-2017 base image and create new ones based on the Microsoft ones mcr.microsoft.com/windows/servercore?
I would prefer to do that as a different ticket if you are ok with that.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


There was someone working on updating the Visual C++ version to 2019

That was me, but it was precisely stalled because of the "uninstall then install Python" problem.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer to do that as a different ticket if you are ok with that.

That's fine with me!

RUN wmic product where "name like 'python%%'" call uninstall /nointeractive && \
rm -rf Python*

# Define the full version number otherwise choco falls back to patch number 0 (3.7 => 3.7.0)
ARG python=3.8
RUN (if "%python%"=="3.7" setx PYTHON_VERSION "3.7.9" && setx PATH "%PATH%;C:\Python37;C:\Python37\Scripts") & \
(if "%python%"=="3.8" setx PYTHON_VERSION "3.8.10" && setx PATH "%PATH%;C:\Python38;C:\Python38\Scripts") & \
(if "%python%"=="3.9" setx PYTHON_VERSION "3.9.7" && setx PATH "%PATH%;C:\Python39;C:\Python39\Scripts") & \
(if "%python%"=="3.10" setx PYTHON_VERSION "3.10.2" && setx PATH "%PATH%;C:\Python310;C:\Python310\Scripts")
RUN choco install -r -y --no-progress python --version=%PYTHON_VERSION%
RUN python -m pip install -U pip setuptools
2 changes: 1 addition & 1 deletion ci/scripts/python_wheel_windows_test.bat
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

@echo on

set PYARROW_TEST_CYTHON=OFF
set PYARROW_TEST_CYTHON=ON
set PYARROW_TEST_DATASET=ON
set PYARROW_TEST_FLIGHT=ON
set PYARROW_TEST_GANDIVA=OFF
Expand Down
9 changes: 7 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -981,10 +981,15 @@ services:
target: "C:/arrow"
command: arrow\\ci\\scripts\\python_wheel_windows_build.bat

# doesn't exit properly on fail
python-wheel-windows-test:
image: python:${PYTHON}-windowsservercore-1809
image: ${REPO}:python-${PYTHON}-wheel-windows-test-vs2017-${PYTHON_WHEEL_WINDOWS_IMAGE_REVISION}
build:
args:
python: ${PYTHON}
context: .
dockerfile: ci/docker/python-wheel-windows-test-vs2017.dockerfile
volumes:
- "${DOCKER_VOLUME_PREFIX}python-wheel-windows-clcache:C:/clcache"
- type: bind
source: .
target: "C:/arrow"
Expand Down
26 changes: 21 additions & 5 deletions python/pyarrow/tests/test_cython.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,21 +123,37 @@ def test_cython_api(tmpdir):
# pyarrow imported first.
code = """if 1:
import sys
import os

try:
# Add dll directory was added on python 3.8
# and is required in order to find extra DLLs
# only for win32
for dir in {library_dirs}:
os.add_dll_directory(dir)
except AttributeError:
pass

mod = __import__({mod_name!r})
arr = mod.make_null_array(5)
assert mod.get_array_length(arr) == 5
assert arr.null_count == 5
""".format(mod_name='pyarrow_cython_example')
""".format(mod_name='pyarrow_cython_example',
library_dirs=pa.get_library_dirs())

var = None
if sys.platform == 'win32':
delim, var = ';', 'PATH'
if not hasattr(os, 'add_dll_directory'):
# Python 3.8 onwards don't check extension module DLLs on path
# we have to use os.add_dll_directory instead.
delim, var = ';', 'PATH'
else:
delim, var = ':', 'LD_LIBRARY_PATH'

subprocess_env[var] = delim.join(
pa.get_library_dirs() + [subprocess_env.get(var, '')]
)
if var:
subprocess_env[var] = delim.join(
pa.get_library_dirs() + [subprocess_env.get(var, '')]
)
subprocess.check_call([sys.executable, '-c', code],
stdout=subprocess.PIPE,
env=subprocess_env)
Expand Down