Skip to content

Commit

Permalink
Merge pull request NREL#10406 from NREL/build_python_wheel
Browse files Browse the repository at this point in the history
Build python wheel - Quick Fixes
  • Loading branch information
Myoldmopar authored Feb 20, 2024
2 parents 0a32a9e + 726da7c commit 3d4abc3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/build_wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ on:
jobs:
build_wheel:

runs-on: ${{ matrix.os }}

strategy:
fail-fast: false
matrix:
python-version: ["3.9"]
os: [ubuntu-22.04, macos-13, windows-2019]

runs-on: ${{ matrix.os }}

steps:
- name: Checkout EnergyPlus
uses: actions/checkout@v3
Expand All @@ -43,5 +43,5 @@ jobs:
- uses: actions/upload-artifact@v3
with:
name: dist
name: energyplus-wheel-${{ matrix.os }}
path: ./dist
14 changes: 9 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@

from setuptools import setup, Extension
from setuptools.command.build_ext import build_ext
from setuptools.errors import CompileError
from shutil import rmtree, copy
from platform import machine, system
from os import cpu_count
Expand Down Expand Up @@ -145,9 +144,10 @@ def cmake_configure_command() -> list[str]:
@staticmethod
def cmake_build_command() -> list[str]:
cmake_build_cmd = ["cmake", "--build", "."]
if system() == "Windows":
if system() == "Windows": # VS builds require specifying the build config
cmake_build_cmd.extend(["--config", "Release"])
cmake_build_cmd.extend(['--', '-j', f"{cpu_count() - 1}"])
else: # MSBuild doesn't like the -j passed in, so only do this on Non-Windows
cmake_build_cmd.extend(['--', '-j', f"{cpu_count() - 1}"])
return cmake_build_cmd

@staticmethod
Expand All @@ -167,13 +167,17 @@ def run(self):
cmake_cmd = self.cmake_configure_command()
check_call(cmake_cmd, cwd=build_root_directory)
except CalledProcessError as cpe:
raise CompileError(f"CMake failed to configure EnergyPlus, check error logs, raw error message: {cpe}")
raise Exception(
f"CMake failed to configure EnergyPlus, check error logs, raw error message: {cpe}"
) from None

try:
cmake_build_cmd = self.cmake_build_command()
check_call(cmake_build_cmd, cwd=build_root_directory)
except CalledProcessError as cpe:
raise CompileError(f"CMake failed to build EnergyPlus, check error logs, raw error message: {cpe}")
raise Exception(
f"CMake failed to build EnergyPlus, check error logs, raw error message: {cpe}"
) from None

# while EnergyPlus is built in the repo/build-wheel folder, set up the path to the actual wheel build
# this will be in repo/build-wheel/build/energyplus to avoid conflicting with dev's normal repo/build folders
Expand Down

0 comments on commit 3d4abc3

Please sign in to comment.