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
50 changes: 19 additions & 31 deletions .github/actions/windows_actions/action.yml
Original file line number Diff line number Diff line change
@@ -1,39 +1,27 @@
name: Windows Specific steps
description: "Builds libiconv and zlib with MSVC for Windows"
description: "Builds libiconv and zlib for Windows with vcpkg (see vcpkg.json)"

runs:
using: "composite"
steps:
- name: Checkout libiconv
uses: actions/checkout@v6
- name: Cache vcpkg packages
uses: actions/cache@v6
with:
repository: kiyolee/libiconv-win-build
ref: dff1030d222ba934e0f4a9cdab9c34134f072f68 # v1.18
path: libiconv-win-build
persist-credentials: false
path: vcpkg_installed
key: vcpkg-${{ runner.arch }}-${{ hashFiles('vcpkg.json') }}

- name: Checkout zlib
uses: actions/checkout@v6
with:
repository: kiyolee/zlib-win-build
ref: 30623e05e64fe4b97f2073ddaf8d3ba0e99d7249
path: zlib-win-build
persist-credentials: false

- name: Add msbuild to PATH
uses: microsoft/setup-msbuild@v3

- name: Build libiconv
run: |
msbuild.exe libiconv-win-build/build-VS2022-MT/libiconv.sln /property:Configuration=Release;Platform=X64
copy libiconv-win-build\\include\\iconv.h win_libs\\64bit
copy libiconv-win-build\\build-VS2022-MT\\x64\\Release\\libiconv-static.lib win_libs\\64bit
shell: cmd

- name: Build zlib
- name: Install Windows libraries (vcpkg)
shell: pwsh
run: |
msbuild.exe zlib-win-build/build-VS2022-MT/zlib.sln /property:Configuration=Release;Platform=X64
copy zlib-win-build\\zlib.h win_libs\\64bit
copy zlib-win-build\\zconf.h win_libs\\64bit
copy zlib-win-build\\build-VS2022-MT\\x64\\Release\\libz-static.lib win_libs\\64bit
shell: cmd
# The runner's vcpkg clone may predate the builtin-baseline in
# vcpkg.json. vcpkg reads the port version database from the
# working tree, so fetching alone is not enough: check out the
# baseline and bootstrap the matching vcpkg tool.
$ErrorActionPreference = 'Stop'
$PSNativeCommandUseErrorActionPreference = $true
$baseline = (Get-Content vcpkg.json -Raw | ConvertFrom-Json).'builtin-baseline'
git -C "$env:VCPKG_INSTALLATION_ROOT" fetch --quiet origin $baseline
git -C "$env:VCPKG_INSTALLATION_ROOT" checkout --quiet --force $baseline
& "$env:VCPKG_INSTALLATION_ROOT\bootstrap-vcpkg.bat" -disableMetrics
$triplet = if ($env:RUNNER_ARCH -eq 'ARM64') { 'arm64-windows-static-md' } else { 'x64-windows-static-md' }
& "$env:VCPKG_INSTALLATION_ROOT\vcpkg.exe" install --triplet $triplet
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@
dist/
test_data/write/
.vscode
vcpkg_installed/
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ recursive-include pyreadstat *.pyx
include *.pxd
recursive-include pyreadstat *.pxd
recursive-include pyreadstat py.typed
include vcpkg.json
20 changes: 12 additions & 8 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,16 +76,20 @@ def is_conda():
include_dirs = [source_dir_root] + source_dirs + ["pyreadstat", "."]
library_dirs = []
# Windows
# On Windows we have two possible setups: the user has included the static libraries in win_libs/64bit
# Or the user is going to use the Conda forge versions of those. See the windows compilation document
# On Windows we have two possible setups: libiconv and zlib were installed with vcpkg (see vcpkg.json),
# or the user is going to use the Conda forge versions of those. See the windows compilation document
# for more details
if os.name == 'nt':
is64bit = sys.maxsize > 2 ** 32
# The user included the compiled static libraries
if os.path.isfile("win_libs/64bit/libiconv-static.lib") and os.path.isfile("win_libs/64bit/libz-static.lib"):
libraries.extend(["libiconv-static", "libz-static"])
include_dirs.append("win_libs/64bit")
library_dirs.append("win_libs/64bit")
import platform
# vcpkg manifest mode installs into ./vcpkg_installed/<triplet> by default.
# The *-static-md triplets give static libraries linked against the dynamic CRT, as Python itself is.
_default_triplet = "arm64-windows-static-md" if platform.machine().upper() == "ARM64" else "x64-windows-static-md"
vcpkg_triplet = os.environ.get("VCPKG_TARGET_TRIPLET", _default_triplet)
vcpkg_dir = os.path.join(os.environ.get("VCPKG_INSTALLED_DIR", os.path.join(dir_path, "vcpkg_installed")), vcpkg_triplet)
if os.path.isdir(vcpkg_dir):
libraries.extend(["iconv", "charset", "libzs"])
include_dirs.append(os.path.join(vcpkg_dir, "include"))
library_dirs.append(os.path.join(vcpkg_dir, "lib"))
# conda forge libraries
else:
libraries.extend(["iconv", "zlib"])
Expand Down
10 changes: 10 additions & 0 deletions vcpkg.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"$schema": "https://raw.githubusercontent.com/microsoft/vcpkg-tool/main/docs/vcpkg.schema.json",
"name": "pyreadstat",
"description": "Native dependencies for building pyreadstat on Windows",
"dependencies": [
"libiconv",
"zlib"
],
"builtin-baseline": "2ebb714221ad4e482e596d64c129f63fbbfb3fd5"
}
Empty file removed win_libs/64bit/.gitkeep
Empty file.
254 changes: 0 additions & 254 deletions win_libs/samples_64bit/iconv.h

This file was deleted.

Binary file removed win_libs/samples_64bit/libiconv-static.lib
Binary file not shown.
Binary file removed win_libs/samples_64bit/libz-static.lib
Binary file not shown.
Loading
Loading