Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
2 changes: 2 additions & 0 deletions CONSTRUCT.md
Original file line number Diff line number Diff line change
Expand Up @@ -744,6 +744,7 @@ The output filename will be:
- `win`
- `win32`
- `win64`
- `win_arm64`
- `x86`
- `x86_64`

Expand All @@ -755,5 +756,6 @@ If provided, this argument must be formated as `<platform>-<architecture>`, e.g.
- `linux-ppc64le`
- `linux-s390x`
- `win-64`
- `win-arm64`
- `osx-64`
- `osx-arm64`
1 change: 1 addition & 0 deletions constructor/conda_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
"linux-ppc64le",
"linux-s390x",
"win-64",
"win-arm64",
"osx-64",
"osx-arm64",
]
Expand Down
1 change: 1 addition & 0 deletions constructor/construct.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ def ns_platform(platform):
win=p.startswith("win-"),
win32=bool(p == "win-32"),
win64=bool(p == "win-64"),
win_arm64=bool(p == "win-arm64"),
)


Expand Down
3 changes: 2 additions & 1 deletion constructor/nsis/main.nsi.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -657,8 +657,9 @@ Function .onInit
# Select the correct registry to look at, depending
# on whether it's a 32-bit or 64-bit installer
SetRegView {{ BITS }}
{%- if win64 %}
{%- if win64 or win_arm64 %}
# If we're a 64-bit installer, make sure it's 64-bit Windows
# Not verified yet on ARM64 Windows.
Comment thread
lrandersson marked this conversation as resolved.
Outdated
${IfNot} ${RunningX64}
MessageBox MB_OK|MB_ICONEXCLAMATION \
"This installer is for a 64-bit version for ${NAME}$\n\
Expand Down
27 changes: 11 additions & 16 deletions constructor/winexe.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,15 @@
logger = logging.getLogger(__name__)


def parse_arch(platform: str) -> tuple[str, int]:
"""Return a tuple (display string, bit width) for a Windows platform string."""
arch = platform.split("-")[1]
if arch == "arm64":
return "ARM64", 64
bits = int(arch)
return "%d-bit" % bits, bits


def read_nsi_tmpl(info) -> str:
path = abspath(info.get("nsis_template", join(NSIS_DIR, "main.nsi.tmpl")))
logger.info("Reading: %s", path)
Expand Down Expand Up @@ -155,7 +164,7 @@ def make_nsi(
dists += env_info["_dists"]
dists = list({dist: None for dist in dists}) # de-duplicate

arch = int(info["_platform"].split("-")[1])
display_arch, arch = parse_arch(info["_platform"])
info["pre_install_desc"] = info.get("pre_install_desc", "")
info["post_install_desc"] = info.get("post_install_desc", "")

Expand All @@ -164,7 +173,7 @@ def make_nsi(
"installer_version": info["version"],
"company": info.get("company", "Unknown, Inc."),
"installer_platform": info["_platform"],
"arch": "%d-bit" % arch,
"arch": display_arch,
"default_prefix": info.get("default_prefix", join("%USERPROFILE%", name.lower())),
"default_prefix_domain_user": info.get(
"default_prefix_domain_user", join("%LOCALAPPDATA%", name.lower())
Expand Down Expand Up @@ -413,17 +422,3 @@ def create(info, verbose=False):

if not info.get("_debug"):
shutil.rmtree(tmp_dir)


if __name__ == "__main__":
make_nsi(
{
"name": "Maxi",
"version": "1.2",
"_platform": "win-64",
"_outpath": "dummy.exe",
"_download_dir": "dummy",
"_dists": ["python-2.7.9-0.tar.bz2", "vs2008_runtime-1.0-1.tar.bz2"],
},
".",
)
2 changes: 2 additions & 0 deletions docs/source/construct-yaml.md
Original file line number Diff line number Diff line change
Expand Up @@ -744,6 +744,7 @@ The output filename will be:
- `win`
- `win32`
- `win64`
- `win_arm64`
- `x86`
- `x86_64`

Expand All @@ -755,5 +756,6 @@ If provided, this argument must be formated as `<platform>-<architecture>`, e.g.
- `linux-ppc64le`
- `linux-s390x`
- `win-64`
- `win-arm64`
- `osx-64`
- `osx-arm64`
28 changes: 27 additions & 1 deletion tests/test_construct.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@

import pytest

from constructor.conda_interface import cc_platform
from constructor.conda_interface import SUPPORTED_PLATFORMS, cc_platform
from constructor.construct import ns_platform
from constructor.construct import parse as construct_parse
from constructor.construct import render as construct_render

Expand Down Expand Up @@ -37,6 +38,10 @@
"""


def test_supported_platforms_includes_win_arm64():
assert "win-arm64" in SUPPORTED_PLATFORMS
Comment thread
lrandersson marked this conversation as resolved.
Outdated


@pytest.fixture
def construct_yaml_file(tmp_path: Path) -> str:
file_path = tmp_path / "construct.yaml"
Expand Down Expand Up @@ -110,3 +115,24 @@ def test_parse_error(tmp_path):
construct_parse(construct_yaml_file, cc_platform)
assert exc.value.code != 0
assert "Unable to parse" in str(exc.getrepr())


NS_PLATFORM_TRUE_FLAGS = {
"linux-64": {"linux", "linux64", "x86", "x86_64", "unix"},
"linux-aarch64": {"linux", "aarch64", "unix"},
"linux-ppc64le": {"linux", "ppc64le", "unix"},
"linux-s390x": {"linux", "s390x", "unix"},
"win-64": {"x86", "x86_64", "win", "win64"},
"win-arm64": {"win", "win_arm64"},
"osx-64": {"x86", "x86_64", "osx", "unix"},
"osx-arm64": {"arm64", "osx", "unix"},
}


@pytest.mark.parametrize("platform", SUPPORTED_PLATFORMS)
def test_ns_platform(platform):
result = ns_platform(platform)
assert result
true_flags = NS_PLATFORM_TRUE_FLAGS[platform]
for flag, value in result.items():
assert value is (flag in true_flags), f"{platform}: expected {flag}={flag in true_flags}"
15 changes: 15 additions & 0 deletions tests/test_winexe.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import pytest

from constructor.winexe import parse_arch


@pytest.mark.parametrize(
"platform,expected",
[
("win-32", ("32-bit", 32)),
("win-64", ("64-bit", 64)),
("win-arm64", ("ARM64", 64)),
],
)
def test_parse_arch(platform, expected):
assert parse_arch(platform) == expected
Loading