Skip to content

Commit 79c20e9

Browse files
committed
[windows] Use Scoop package manager instead of Chocolatey
1 parent c59c193 commit 79c20e9

File tree

3 files changed

+73
-38
lines changed

3 files changed

+73
-38
lines changed

doc/use-cases/windows-pytables-wheel.sh

Lines changed: 37 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -12,53 +12,64 @@ set -e
1212

1313
# Install prerequisites.
1414

15-
# Microsoft Visual C++ Build Tools 2015 14.0.25420.1
16-
# https://community.chocolatey.org/packages/microsoft-visual-cpp-build-tools
17-
# Microsoft Build Tools 2015 (Install)
18-
# https://community.chocolatey.org/packages/microsoft-build-tools-2015
19-
#choco install --yes microsoft-visual-cpp-build-tools --install-arguments="'/InstallSelectableItems Win81SDK_CppBuildSKUV1;VisualCppBuildTools_ATLMFC_SDK'"
20-
choco install --yes microsoft-visual-cpp-build-tools --install-arguments="'/Full'"
21-
2215
# Miniconda - A minimal installer for Anaconda.
2316
# https://conda.io/miniconda.html
24-
# https://community.chocolatey.org/packages/miniconda3
25-
choco install --yes miniconda3 --package-parameters="'/AddToPath:1'"
17+
scoop bucket add extras
18+
scoop install miniconda3
19+
#export PATH="$PATH:/c/Users/ContainerAdministrator/scoop/apps/miniconda3/current/condabin"
20+
#alias conda=conda.bat
21+
#/c/Users/ContainerAdministrator/scoop/apps/miniconda3/current/condabin/conda.bat init bash
22+
source /c/Users/ContainerAdministrator/scoop/apps/miniconda3/current/Scripts/activate
23+
conda --version
24+
25+
# /c/Users/ContainerAdministrator/scoop/apps/miniconda3/4.12.0/Scripts/conda.exe
2626

2727
# TODO: `/AddToPath:1` seems to not work, so adjust `$PATH` manually.
28-
export PATH="$PATH:/c/Tools/miniconda3/condabin"
28+
#export PATH="$PATH:/c/Tools/miniconda3/condabin"
2929

3030
# TODO: At least within Bash, just addressing `conda` does not work.
31-
export conda="conda.bat"
31+
#export conda="conda.bat"
3232

33-
# cibuildwheel - Build Python wheels for all the platforms on CI with minimal configuration.
34-
# https://cibuildwheel.readthedocs.io/
35-
pip install --upgrade cibuildwheel
3633

3734
# Check prerequisites.
38-
echo $PATH
39-
$conda --version
35+
#echo $PATH
36+
#$conda --version
4037
# cibuildwheel --version
4138

42-
# Acquire sources.
43-
mkdir -p /c/src
44-
cd /c/src
45-
test ! -d PyTables && git clone https://github.com/PyTables/PyTables --recursive --depth=1
46-
cd PyTables
47-
4839
# Pretend to be on a build matrix.
4940
export MATRIX_ARCH=win_amd64 # win32
5041
export MATRIX_ARCH_SUBDIR=win-64 # win-32
5142

43+
# Activate and prepare Anaconda environment for building.
44+
conda create --yes --name=build
45+
conda activate build
46+
conda config --env --set subdir ${MATRIX_ARCH_SUBDIR}
47+
48+
# Install needed libraries.
49+
conda install --yes blosc bzip2 hdf5 lz4 lzo snappy zstd zlib
50+
51+
# Install cibuildwheel.
52+
# Build Python wheels for all the platforms on CI with minimal configuration.
53+
# https://cibuildwheel.readthedocs.io/
54+
pip install --upgrade cibuildwheel
55+
5256
# Configure cibuildwheel.
53-
export CIBW_BUILD="cp36-${MATRIX_ARCH} cp37-${MATRIX_ARCH} cp38-${MATRIX_ARCH} cp39-${MATRIX_ARCH} cp310-${MATRIX_ARCH}"
54-
export CIBW_BEFORE_ALL_WINDOWS="$conda create --yes --name=build && $conda activate build && $conda config --env --set subdir ${MATRIX_ARCH_SUBDIR} && $conda install --yes blosc bzip2 hdf5 lz4 lzo snappy zstd zlib"
55-
export CIBW_ENVIRONMENT_WINDOWS='CONDA_PREFIX="C:\\Miniconda\\envs\\build" PATH="$PATH;C:\\Miniconda\\envs\\build\\Library\\bin"'
57+
#export CIBW_BUILD="cp36-${MATRIX_ARCH} cp37-${MATRIX_ARCH} cp38-${MATRIX_ARCH} cp39-${MATRIX_ARCH} cp310-${MATRIX_ARCH}"
58+
export CIBW_BUILD="cp39-${MATRIX_ARCH}"
59+
#export CIBW_BEFORE_ALL_WINDOWS="conda create --yes --name=build && conda activate build && conda config --env --set subdir ${MATRIX_ARCH_SUBDIR} && conda install --yes blosc bzip2 hdf5 lz4 lzo snappy zstd zlib"
60+
#export CIBW_ENVIRONMENT_WINDOWS='CONDA_PREFIX="C:\\Miniconda\\envs\\build" PATH="$PATH;C:\\Miniconda\\envs\\build\\Library\\bin"'
5661
export CIBW_ENVIRONMENT="PYTABLES_NO_EMBEDDED_LIBS=true DISABLE_AVX2=true"
57-
export CIBW_BEFORE_BUILD="pip install -r requirements.txt cython>=0.29.21 delvewheel"
62+
export CIBW_BEFORE_BUILD="echo $PATH; pip install -r requirements.txt cython>=0.29.21 delvewheel"
5863
export CIBW_REPAIR_WHEEL_COMMAND_WINDOWS="delvewheel repair -w {dest_dir} {wheel}"
5964

6065
# Debugging.
6166
# env
6267

68+
# Acquire sources.
69+
mkdir -p /c/src
70+
cd /c/src
71+
test ! -d PyTables && git clone https://github.com/PyTables/PyTables --recursive --depth=1
72+
cd PyTables
73+
6374
# Build wheel.
6475
cibuildwheel --platform=windows --output-dir=wheelhouse

doc/winrunner.rst

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,18 @@ About
88
*****
99

1010
Launch an interactive command prompt (cmd, PowerShell, or Bash) within a
11-
Windows environment (2016, 2019, or 2022) or invoke programs
11+
Windows environment (2016, 2019, or 2022), or invoke programs
1212
non-interactively.
1313

1414
Features
1515
========
1616

1717
- The subsystem is heavily based on the excellent `Windows Docker Machine`_.
18-
- The package manager `Chocolatey`_ is pre-installed on the container images
19-
where PowerShell is available.
18+
- The `Scoop`_ package manager is pre-installed on the container images
19+
where PowerShell is available. The `Chocolatey`_ package manager can be
20+
installed on demand.
2021
- Programs like ``busybox``, ``curl``, ``git``, ``nano``, and ``wget`` are
21-
pre-installed on the container images where `Chocolatey`_ is available.
22+
pre-installed on the container images where `Scoop`_ is available.
2223
- The `Windows container version compatibility`_ problem is conveniently
2324
solved by automatically selecting the right machine matching the requested
2425
container image.
@@ -190,7 +191,7 @@ Install and run `Winfetch`_::
190191

191192
racker --verbose run --rm \
192193
--platform=windows/amd64 mcr.microsoft.com/windows/servercore:ltsc2022 -- \
193-
cmd /C 'choco install --yes --force winfetch & refreshenv & winfetch'
194+
cmd /C 'scoop install winfetch & winfetch'
194195

195196
.. figure:: https://user-images.githubusercontent.com/453543/173195228-b75c8727-7187-4c38-ae28-f74098dfb450.png
196197
:width: 800
@@ -463,6 +464,7 @@ The whole software catalog can be inquired at `Chocolatey community packages`_.
463464
.. _Midnight Commander: https://en.wikipedia.org/wiki/Midnight_Commander
464465
.. _Overview of System Center release options: https://docs.microsoft.com/en-us/system-center/ltsc-and-sac-overview
465466
.. _Python: https://www.python.org/
467+
.. _Scoop: https://scoop.sh/
466468
.. _Using Racker and Postroj for CrateDB CI: https://github.com/cicerops/racker/blob/main/doc/cratedb.rst
467469
.. _Vagrant: https://www.vagrantup.com/
468470
.. _VirtualBox: https://www.virtualbox.org/

postroj/winrunner.Dockerfile

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,44 @@
33
#
44
# Provision a Windows operating system image.
55
#
6-
# - Install the FOSS version of the Chocolatey package manager.
7-
# - Install additional software using Chocolatey.
6+
# - Install the Scoop package manager.
7+
# - Install additional software using Scoop.
8+
# - https://scoop.sh/
89
#
910

1011
ARG BASE_IMAGE
1112

1213
FROM ${BASE_IMAGE}
1314

14-
# Install the Chocolatey package manager.
15-
RUN powershell -Command Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))
15+
# Restore the default Windows shell for correct batch processing.
16+
SHELL ["cmd", "/S", "/C"]
17+
18+
# Install the Scoop package manager.
19+
# https://github.com/ScoopInstaller/Install#for-admin
20+
RUN powershell -Command irm get.scoop.sh -outfile 'scoop-install.ps1'; .\scoop-install.ps1 -RunAsAdmin
21+
22+
# Install/update Aria2 and Git first, to speed up downloads and have it up-to-date.
23+
RUN scoop install aria2 git
1624

1725
# Install essential and convenience programs.
18-
RUN choco install --yes busybox curl nano wget
19-
RUN choco install --yes git --package-parameters="'/GitAndUnixToolsOnPath /Editor:Nano'"
26+
RUN scoop install msys2 zip unzip
27+
28+
# Make MSYS2 programs available on the program search path.
29+
# Note: It is not fully installed. In order to complete it, run `msys2` once.
30+
RUN powershell $msys_path = $(scoop prefix msys2); [Environment]::SetEnvironmentVariable('Path', $env:Path + ';' + $msys_path + '\usr\bin', 'Machine')
2031

21-
# Rename Windows-native programs in favor of Chocolatey-installed/FOSS/GNU ones.
32+
# Display the program search path.
33+
#RUN powershell echo (Get-ItemProperty 'HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Environment' -Name Path).Path
34+
35+
# Rename Windows-native programs in favor of Scoop-installed/FOSS/GNU ones.
2236
# An alternative would be to manipulate `$PATH`, but that is more tedious.
2337
RUN sh -c 'test -f /c/Windows/system32/curl && mv /c/Windows/system32/curl /c/Windows/system32/curl-win'
2438
RUN sh -c 'test -f /c/Windows/system32/convert && mv /c/Windows/system32/convert /c/Windows/system32/convert-ntfs'
39+
40+
# TODO: With PowerShell 7, it is possible to remove the corresponding aliases.
41+
#Remove-Alias -Name ls
42+
#Remove-Alias -Name cat
43+
#Remove-Alias -Name mv
44+
#Remove-Alias -Name ps
45+
#Remove-Alias -Name pwd
46+
#Remove-Alias -Name rm

0 commit comments

Comments
 (0)