Skip to content

Conversation

@jmarrec
Copy link
Contributor

@jmarrec jmarrec commented Aug 22, 2025

Pull request overview

Description of the purpose of this PR

Pull Request Author

  • Title of PR should be user-synopsis style (clearly understandable in a standalone changelog context)
  • Label the PR with at least one of: Defect, Refactoring, NewFeature, Performance, and/or DoNoPublish

Reviewer

  • Perform a Code Review on GitHub
  • If branch is behind develop, merge develop and build locally to check for side effects of the merge
  • If defect, verify by running develop branch and reproducing defect, then running PR and reproducing fix
  • If feature, test running new feature, try creative ways to break it
  • CI status: all green or justified
  • Check that performance is not impacted (CI Linux results include performance check)
  • Run Unit Test(s) locally
  • Check any new function arguments for performance impacts
  • Verify IDF naming conventions and styles, memos and notes and defaults
  • If new idf included, locally check the err file and other outputs

@jmarrec jmarrec self-assigned this Aug 22, 2025
@jmarrec jmarrec added Defect Includes code to repair a defect in EnergyPlus NotIDDChange Code does not impact IDD (can be merged after IO freeze) Developer Issue Related to cmake, packaging, installers, or developer tooling (CI, etc) labels Aug 22, 2025
Comment on lines -128 to -135
if msvc_version in ['16', '17', '18']:
if self.os == OS.Windows:
self.msvc_version = msvc_version
elif self.os == OS.Windows and self.os_version == '2022':
self.msvc_version = 17
elif self.os == OS.Windows:
self.msvc_version = 16
self.asset_pattern = this_config['asset_pattern']
self.bitness = this_config['bitness']
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here the GHA test step was passing --msvc 2022 for win64 for run_config_key. Given this code block, it was just ignored, and it was checking the CONFIGURATIONS, which listed "os_version" as "10" for "win64", so it'd pick Visual Studio 16 2019, which doesn't exist.

Comment on lines +56 to +95
from enum import IntEnum, StrEnum


class OS(StrEnum):
"""Operating Systems."""

Windows = "Windows"
Linux = "Linux"
Mac = "Mac"


class MSVC(IntEnum):
"""Microsoft Visual Studio versions."""

V16 = 16
V17 = 17
# V18 = 18 # Future version placeholder

def generator_name(self) -> str:
"""Get the CMake generator name for the MSVC version."""
return MSVC_GENERATOR_MAPPING[self]


# Alias mapping for common version names to MSVC enum, for argparse
MSVC_ALIAS_MAPPING = {
"2017": MSVC.V16,
"2022": MSVC.V17,
}

# Mapping from MSVC enum to CMake generator names
MSVC_GENERATOR_MAPPING = {
MSVC.V16: "Visual Studio 16 2019",
MSVC.V17: "Visual Studio 17 2022",
}


class Bitness(StrEnum):
X86 = "x86"
X64 = "x64"
ARM64 = "arm64"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello Enums.

Comment on lines +223 to +234
def handle_msvc_arg(arg: str) -> MSVC:
# Check for aliases first
if arg in MSVC_ALIAS_MAPPING:
return MSVC_ALIAS_MAPPING[arg]

try:
return MSVC(int(arg))
except ValueError:
possible_values = list(map(str, MSVC))
aliases = [f"{k} -> {v}" for k, v in MSVC_ALIAS_MAPPING.items()]
msg = f"Invalid MSVC version argument: '{arg}' (choose from {possible_values} or aliases {aliases})"
raise argparse.ArgumentTypeError(msg)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Turns the --msvc argument (str) into a MSVC enum instance.

I maintained the backward compat use of aliases, such as '2017' or '2022', but they map to one of MSVC.V16 or MSVC.V17

Comment on lines +251 to +252
if platform.system() == "Windows" and args.msvc is None:
parser.error("On Windows, the --msvc argument is required to specify the Visual Studio version.")
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm enforcing that the msvc argument is actually passed. Makes more sense instead of trying to default it for whatever reason.

print(" ...Extraction Complete")
except CalledProcessError as e:
raise Exception("Extraction failed with this error: " + str(e))
raise Exception(f"Extraction failed with this error: {e}\nCommand: {extract_command}")
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My local VM had 7zip installed, by it wasn't on PATH. Wasn't clear what was happening.

Comment on lines +131 to +134
if self.os == OS.Windows:
self.msvc_version = msvc_version
elif self.os == OS.Windows and self.os_version == '2022':
self.msvc_version = 17
elif self.os == OS.Windows:
self.msvc_version = 16
self.asset_pattern = this_config['asset_pattern']
self.bitness = this_config['bitness']
if not isinstance(self.msvc_version, MSVC):
raise ValueError("On Windows, an MSVC (Enum) version must be provided.")
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Enforce having msvc_version as an Enum here.

Comment on lines +192 to +194
TestCAPIAccess(os=self.os, bitness=self.bitness, msvc_version=self.msvc_version).run(
install_path,
verbose,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The C API tests take their required params into their Ctor now. Instead of weirdly passing them via kwargs on the "run" method and assigning there

Comment on lines +200 to 201
if self.bitness == Bitness.X86:
print("Travis does not have a 32-bit Python package readily available, so not testing Python API")
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That shoudn't be there nowadays FYI

Comment on lines +255 to +263
def __init__(self, os: OS, bitness: Bitness, msvc_version: Optional[MSVC] = None):
super().__init__()
self.os = None
self.bitness = None
self.source_file_name = 'func.cpp'
self.target_name = 'TestCAPIAccess'
self.msvc_version = None
self.os = os
self.bitness = bitness
self.msvc_version = msvc_version
self.source_file_name = "func.cpp"
self.target_name = "TestCAPIAccess"
if self.os == OS.Windows and self.msvc_version is None:
raise Exception("Must pass msvc_version if os is Windows")
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Like I said, they assigned in Ctor. And will throw if windows and no msvc_version, since it's required

Comment on lines +148 to +163
def make_build_dir_and_build(cmake_build_dir: str, verbose: bool, bitness: Bitness, msvc_version: MSVC):

os.makedirs(cmake_build_dir)
my_env = os.environ.copy()
if platform.system() == "Darwin": # my local comp didn't have cmake in path except in interact shells
my_env["PATH"] = "/usr/local/bin:" + my_env["PATH"]
command_line = ["cmake", ".."]
is_windows = platform.system() == "Windows"
if is_windows:
command_line.extend(["-G", msvc_version.generator_name(), "-A", bitness.value])

try:
my_check_call(verbose, command_line, cwd=cmake_build_dir, env=my_env)
command_line = ['cmake', '--build', '.']
if platform.system() == 'Windows':
command_line.extend(['--config', 'Release'])
except Exception as e:
print("C API Wrapper Configuration Failed!")
raise e
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couple of things happening here:

  • One: I try / catch only the check_call. I don't want to swallow other exception. And I clarify the print to let you know it's the CONFIGURATION that failed here (the build later)
  • Two: The cmake Generator options are computed from the enums, less error prone.
  • Three: I removed Visual Studio 15. It would have forced me to do more complicated things since it doesn't accept a "-A" argument, and it's too old

Copy link
Member

@Myoldmopar Myoldmopar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is all fine. The ' to " changes make it a little difficult to see the functional changes, so I appreciate you calling the changes out. This has been needed for a while. The 2022 change is great, and the package testing code was written way way back, so it definitely needed some love.

@Myoldmopar
Copy link
Member

@jmarrec have you built a release from this branch? If not, I'll go ahead and kick one off to check out the release testing updates.

@jmarrec
Copy link
Contributor Author

jmarrec commented Aug 26, 2025

@Myoldmopar
Copy link
Member

Perfect, thank you! Let's get this merged now.

@Myoldmopar Myoldmopar merged commit 64a6fac into develop Aug 26, 2025
12 checks passed
@Myoldmopar Myoldmopar deleted the 11161_windows_release branch August 26, 2025 13:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Defect Includes code to repair a defect in EnergyPlus Developer Issue Related to cmake, packaging, installers, or developer tooling (CI, etc) NotIDDChange Code does not impact IDD (can be merged after IO freeze)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cannot build Windows Release due to removal of windows-2019 from GHA

4 participants