Skip to content

Commit 1e4a979

Browse files
authored
Merge pull request #137 from pycompression/fixwin
Try to fix windows CI
2 parents 61eb682 + 1369747 commit 1e4a979

File tree

4 files changed

+12
-25
lines changed

4 files changed

+12
-25
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,8 @@ jobs:
6969
include:
7070
- os: "macos-latest"
7171
python-version: 3.7
72-
# - os: "windows-latest"
73-
# python-version: 3.7
72+
- os: "windows-latest"
73+
python-version: 3.7
7474
steps:
7575
- uses: actions/[email protected]
7676
with:

CHANGELOG.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ Changelog
99
1010
version 1.2.0-dev
1111
-----------------
12+
+ Simplify build setup. ISA-L release flags are now used and not
13+
overwritten with python release flags when building the included static
14+
library.
1215
+ Fix bug where zdict's could not be set for ``isal_zlib.decompressobj`` and
1316
``igzip_lib.IgzipDecompressor``.
1417
+ Escape GIL when calling inflate, deflate, crc32 and adler32 functions to

setup.py

Lines changed: 5 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
# This file is part of python-isal which is distributed under the
77
# PYTHON SOFTWARE FOUNDATION LICENSE VERSION 2.
88

9-
import copy
109
import functools
1110
import os
1211
import shutil
@@ -72,19 +71,7 @@ def build_extension(self, ext):
7271
raise NotImplementedError(
7372
f"Unsupported platform: {sys.platform}")
7473
else:
75-
if self.compiler.compiler_type == "msvc":
76-
compiler = copy.deepcopy(self.compiler)
77-
if not compiler.initialized:
78-
compiler.initialize()
79-
compiler_command = f'"{compiler.cc}"'
80-
compiler_args = compiler.compile_options
81-
elif self.compiler.compiler_type == "unix":
82-
compiler_command = self.compiler.compiler[0]
83-
compiler_args = self.compiler.compiler[1:]
84-
else:
85-
raise NotImplementedError("Unknown compiler")
86-
isa_l_prefix_dir = build_isa_l(compiler_command,
87-
" ".join(compiler_args))
74+
isa_l_prefix_dir = build_isa_l()
8875
if SYSTEM_IS_UNIX:
8976
ext.extra_objects = [
9077
os.path.join(isa_l_prefix_dir, "lib", "libisal.a")]
@@ -106,7 +93,7 @@ def build_extension(self, ext):
10693
# 'cache' is only available from python 3.9 onwards.
10794
# see: https://docs.python.org/3/library/functools.html#functools.cache
10895
@functools.lru_cache(maxsize=None)
109-
def build_isa_l(compiler_command: str, compiler_options: str):
96+
def build_isa_l():
11097
# Check for cache
11198
if BUILD_CACHE:
11299
if BUILD_CACHE_FILE.exists():
@@ -122,14 +109,8 @@ def build_isa_l(compiler_command: str, compiler_options: str):
122109
# Build environment is a copy of OS environment to allow user to influence
123110
# it.
124111
build_env = os.environ.copy()
125-
# Add -fPIC flag to allow static compilation
126-
build_env["CC"] = compiler_command
127112
if SYSTEM_IS_UNIX:
128-
build_env["CFLAGS"] = compiler_options + " -fPIC"
129-
elif SYSTEM_IS_WINDOWS:
130-
# The nmake file has CLFAGS_REL for all the compiler options.
131-
# This is added to CFLAGS with all the necessary include options.
132-
build_env["CFLAGS_REL"] = compiler_options
113+
build_env["CFLAGS"] = build_env.get("CFLAGS", "") + " -O2 -fPIC"
133114
if hasattr(os, "sched_getaffinity"):
134115
cpu_count = len(os.sched_getaffinity(0))
135116
else: # sched_getaffinity not available on all platforms
@@ -142,7 +123,8 @@ def build_isa_l(compiler_command: str, compiler_options: str):
142123
subprocess.run(["make", "-j", str(cpu_count)], **run_args)
143124
subprocess.run(["make", "-j", str(cpu_count), "install"], **run_args)
144125
elif SYSTEM_IS_WINDOWS:
145-
subprocess.run(["nmake", "/E", "/f", "Makefile.nmake"], **run_args)
126+
print(build_env, file=sys.stderr)
127+
subprocess.run(["nmake", "/f", "Makefile.nmake"], **run_args)
146128
Path(temp_prefix, "include").mkdir()
147129
print(temp_prefix, file=sys.stderr)
148130
shutil.copytree(os.path.join(build_dir, "include"),

tox.ini

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,10 @@ isolated_build=True
88
[testenv]
99
deps=pytest
1010
coverage
11+
# Pass windows env variable for includes
1112
passenv=
1213
PYTHON_ISAL_LINK_DYNAMIC
14+
INCLUDE
1315
commands =
1416
# Create HTML coverage report for humans and xml coverage report for external services.
1517
coverage run --branch --source=isal -m pytest tests

0 commit comments

Comments
 (0)