Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add 32bit CI on Windows #249

Merged
merged 2 commits into from
May 26, 2021
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
9 changes: 8 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@
"win-py-3.7",
"win-py-3.6",
],
"arch": [
"x64",
"x86"
],
"include": [
{
"name": "win-py-3.9",
Expand Down Expand Up @@ -94,7 +98,10 @@
{
"name": "Install the right python",
"uses": "actions/setup-python@v2",
"with": { "python-version": "${{ matrix.pyenv }}" },
"with": {
"python-version": "${{ matrix.pyenv }}",
"architecture": "${{ matrix.arch }}"
},
},
{
"name": "Build and test gssapi",
Expand Down
9 changes: 8 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@
"win-wheel-3.7",
"win-wheel-3.6",
],
"arch": [
"x64",
"x86"
],
"include": [
{
"name": "win-wheel-3.9",
Expand Down Expand Up @@ -113,7 +117,10 @@
{
"name": "Install the right python",
"uses": "actions/setup-python@v2",
"with": { "python-version": "${{ matrix.pyenv }}" },
"with": {
"python-version": "${{ matrix.pyenv }}",
"architecture": "${{ matrix.arch }}"
},
},
{
"name": "Create and upload Windows wheel",
Expand Down
10 changes: 9 additions & 1 deletion ci/lib-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,19 @@ setup::macos::install() {
setup::windows::install() {
CHINST="choco install --no-progress --yes --ignore-detected-reboot --allow-downgrade"

# Install the 32bit version if Python is 32bit
if python -c "assert __import__('sys').maxsize <= 2**32"; then
CHINST="$CHINST --x86"
PF="Program Files (x86)"
else
PF="Program Files"
fi

# Install MIT Kerberos. choco will fail despite the installation working.
$CHINST mitkerberos --install-arguments "'ADDLOCAL=ALL'" || true

# Update path to include it
export PATH="/c/Program Files/MIT/Kerberos/bin:$PATH"
export PATH="/c/$PF/MIT/Kerberos/bin:$PATH"

python -m pip install --upgrade pip
}
Expand Down
6 changes: 5 additions & 1 deletion gssapi/_win_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import os
import shutil
import sys
import ctypes

#: Path to normal KfW installed bin folder
Expand All @@ -22,7 +23,10 @@
def kfw_available():
"""Return if the main GSSAPI DLL for KfW can be loaded"""
try: # to load the main GSSAPI DLL
ctypes.WinDLL('gssapi64.dll')
if sys.maxsize > 2**32:
ctypes.WinDLL('gssapi64.dll')
else:
ctypes.WinDLL('gssapi32.dll')
except OSError: # DLL is not in PATH
return False
else: # DLL is in PATH, everything should work
Expand Down
15 changes: 9 additions & 6 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ def get_output(*args, **kwargs):
# get the compile and link args
kc = "krb5-config"
posix = os.name != 'nt'

# Per https://docs.python.org/3/library/platform.html#platform.architecture
# this is the preferred way of determining "64-bitness".
is64bit = sys.maxsize > 2**32

link_args, compile_args = [
shlex.split(os.environ[e], posix=posix) if e in os.environ else None
for e in ['GSSAPI_LINKER_ARGS', 'GSSAPI_COMPILER_ARGS']
Expand Down Expand Up @@ -97,7 +102,7 @@ def get_output(*args, **kwargs):
link_args = ['-framework', 'GSS']
elif winkrb_path:
_libs = os.path.join(
winkrb_path, 'lib', 'amd64' if sys.maxsize > 2 ** 32 else 'i386'
winkrb_path, 'lib', 'amd64' if is64bit else 'i386'
)
link_args = (
['-L%s' % _libs]
Expand All @@ -114,8 +119,9 @@ def get_output(*args, **kwargs):
elif winkrb_path:
compile_args = [
'-I%s' % os.path.join(winkrb_path, 'include'),
'-DMS_WIN64'
]
if is64bit:
compile_args.append('-DMS_WIN64')
elif os.environ.get('MINGW_PREFIX'):
compile_args = ['-fPIC']
else:
Expand Down Expand Up @@ -174,10 +180,7 @@ def get_output(*args, **kwargs):
main_lib = os.environ.get('MINGW_PREFIX')+'/bin/libgss-3.dll'
elif sys.platform == 'msys':
# Plain msys, not running in MINGW_PREFIX. Try to get the lib from one
_main_lib = (
'/mingw%d/bin/libgss-3.dll'
% (64 if sys.maxsize > 2 ** 32 else 32)
)
_main_lib = f'/mingw{64 if is64bit else 32}/bin/libgss-3.dll'
if os.path.exists(_main_lib):
main_lib = _main_lib
os.environ['PATH'] += os.pathsep + os.path.dirname(main_lib)
Expand Down