Skip to content

Commit

Permalink
[Test] work around Py 3.7 distutils bug Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
tttapa committed Aug 20, 2023
1 parent 798f979 commit 024d7e0
Showing 1 changed file with 22 additions and 10 deletions.
32 changes: 22 additions & 10 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,25 @@ def test_example_project(session: nox.Session, name: str, ext_suffix: str):
session.run("pytest")


def get_ext_suffix(name: str):
impl = sys.implementation
ext_suffix = sysconfig.get_config_var("EXT_SUFFIX")
if name == "nanobind-project" or name == "pybind11-project":
# https://github.com/pypa/setuptools/issues/3219
if ext_suffix == ".pyd" and impl.name == "cpython":
version = "".join(map(str, sys.version_info[:2]))
plat = get_platform().replace(".", "_").replace("-", "_")
ext_suffix = f".cp{version}-{plat}" + ext_suffix
if name == "nanobind-project":
if sys.version_info < (3, 8):
ext_suffix = None
elif impl.name == "cpython" and sys.version_info >= (3, 12):
ext_suffix = "." + ext_suffix.rsplit(".", 1)[-1]
if sys.platform != "win32":
ext_suffix = ".abi3" + ext_suffix
return ext_suffix


@nox.session
def example_projects(session: nox.Session):
session.install("-U", "pip", "build", "pytest")
Expand All @@ -81,16 +100,9 @@ def example_projects(session: nox.Session):
session.env["PIP_FIND_LINKS"] = os.path.abspath(dist_dir)
session.install(f"py-build-cmake=={version}")
for name in examples:
ext_suffix = sysconfig.get_config_var("EXT_SUFFIX")
impl = sys.implementation
if name == "nanobind-project":
if sys.version_info < (3, 8):
continue
elif impl.name == "cpython" and sys.version_info >= (3, 12):
ext_suffix = "." + ext_suffix.rsplit(".", 1)[-1]
if sys.platform != "win32":
ext_suffix = ".abi3" + ext_suffix
test_example_project(session, name, ext_suffix)
ext_suffix = get_ext_suffix(name)
if ext_suffix is not None:
test_example_project(session, name, ext_suffix)


@nox.session
Expand Down

0 comments on commit 024d7e0

Please sign in to comment.