Skip to content
Open
Show file tree
Hide file tree
Changes from all 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: 1 addition & 1 deletion .github/workflows/sync-version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ on:

jobs:
sync-version:
runs-on: ubuntu-latest
runs-on: ubuntu-26.04

steps:
- name: generate GitHub App token
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/validate-formula.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ on:

jobs:
validate-formula:
runs-on: ubuntu-latest
runs-on: ubuntu-26.04

steps:
- name: Checkout repository
Expand Down
39 changes: 12 additions & 27 deletions Formula/power-grid-model.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,46 +5,31 @@
class PowerGridModel < Formula
desc "Python/C++ library for distribution power system analysis"
homepage "https://lfenergy.org/projects/power-grid-model/"
url "https://github.com/PowerGridModel/power-grid-model/archive/refs/tags/v1.13.196.tar.gz"
sha256 "d42f484091b54e23ec0fc7bf6373c4f8524be0c86bef368a3e5ed9f06aaefe36"
url "https://github.com/PowerGridModel/power-grid-model/archive/refs/tags/v1.13.197.tar.gz"
sha256 "2d677450c70d92014541877eb4339cb56266b0d82a11cca541e5af99dd4e8630"
license "MPL-2.0"
head "https://github.com/PowerGridModel/power-grid-model.git", branch: "main"

depends_on "boost" => :build
depends_on "cmake" => :build
depends_on "eigen" => :build
depends_on "gcc@14" => :build
depends_on "msgpack-cxx" => :build
depends_on "ninja" => :build
depends_on "nlohmann-json" => :build

on_linux do
depends_on "gcc@16" => :build
end

fails_with :gcc do
version "15"
cause "Use the same GCC version as in main PGM"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

In #18 idea was to allow the option of compiling with any gcc >14 of the target using the formula if possible. And for targets with <=14 we mandate gcc=14. So with this PR we keep it same as PGM all the time?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This PR aligns with PGM as of today, because gcc16 is what we use there. What happens here is that if the user's system provides gcc16 then that's used, if they have <16 then gcc16 bottled from homebrew is used to build from source, and it should be compatible even if they have older ubuntu versions, hence why they provide a bottle.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This doesn't mean that if we change PGM to gcc17 in the future, we would automatically change here. Here it's manually pinned too.

end
Comment on lines +20 to +27

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

is this not a problem? will it remain working on older linux versions? can't we simply bump default gcc version to 16?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is what it does. depends_on "gcc@16" pins to gcc-16. The fails_with is basically saying, if gcc<=15, we fail because we want to use the same version as main pgm, is mostly a message for us in case "they" break something in the future again, we can pinpoint back to this.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Now I've realized something, let me think.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

alright, i think it looks good then but let's double-check with @TonyXiang8787 because i remember having discussions about this while talking about #18

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

on_linux do
    depends_on "gcc@16" => :build
  end

This block installs homebrew's bottle of gcc16. This is guaranteed to be compatible with older distros. Let's call it hgcc for argument sake.

  fails_with :gcc do
    version "15"
    cause "Use the same GCC version as in main PGM"
  end

Checks the systems gcc and if its <=15 it makes it use the brewed hgcc.

This should guarantee it works correctly.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

reading the docs in https://docs.brew.sh/rubydoc/Formula.html#fails_with-class_method it looks like you only test for gcc == 15. it also does not seem to exclude any system compilers though?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

There is a slight difference in what it's used here and in the link you provide. The cookbook should clarify it https://docs.brew.sh/Formula-Cookbook#compiler-selection. In short

fails_with :gcc do
    version "15"
    cause "Use the same GCC version as in main PGM"
  end

Fails for <=15, whereas something like

fails_with :gcc "15" do
    version "15.1"
    cause "Use the same GCC version as in main PGM"
  end

would indeed fail for 15 and 15.1 only for example, not older versions.


def install
rm buildpath/"VERSION"
(buildpath/"VERSION").write(version.to_s)
begin
system_gcc_version = Utils.safe_popen_read("gcc", "-dumpversion").strip.to_i
rescue
system_gcc_version = 0
end

user_cxx = ENV["CXX"].to_s
user_cc = ENV["CC"].to_s
using_non_gcc = (!user_cxx.empty? && user_cxx.exclude?("g++")) ||
(!user_cc.empty? && user_cc.exclude?("gcc"))

# If the user has not requested a non-GCC compiler and the system GCC version is less than 14,
# use the GCC 14 compiler from Homebrew.
# This minimum was added because we use some features in PGM not available in older versions of GCC.
if !using_non_gcc && system_gcc_version < 14
gcc = Formula["gcc@14"]
system "cmake", "-GNinja", "-S", ".", "-B", "build",
"-DCMAKE_C_COMPILER=#{gcc.opt_bin}/gcc-14",
"-DCMAKE_CXX_COMPILER=#{gcc.opt_bin}/g++-14",
*std_cmake_args
else
system "cmake", "-GNinja", "-S", ".", "-B", "build",
*std_cmake_args
end
system "cmake", "-GNinja", "-S", ".", "-B", "build", *std_cmake_args
system "cmake", "--build", "build"
system "cmake", "--install", "build"
end
Expand Down
35 changes: 10 additions & 25 deletions formula_generation/power-grid-model.rb.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -13,38 +13,23 @@ class PowerGridModel < Formula
depends_on "boost" => :build
depends_on "cmake" => :build
depends_on "eigen" => :build
depends_on "gcc@14" => :build
depends_on "msgpack-cxx" => :build
depends_on "ninja" => :build
depends_on "nlohmann-json" => :build

on_linux do
depends_on "gcc@16" => :build
end

fails_with :gcc do
version "15"
cause "Use the same GCC version as in main PGM"
end

def install
rm buildpath/"VERSION"
(buildpath/"VERSION").write(version.to_s)
begin
system_gcc_version = Utils.safe_popen_read("gcc", "-dumpversion").strip.to_i
rescue
system_gcc_version = 0
end

user_cxx = ENV["CXX"].to_s
user_cc = ENV["CC"].to_s
using_non_gcc = (!user_cxx.empty? && user_cxx.exclude?("g++")) ||
(!user_cc.empty? && user_cc.exclude?("gcc"))

# If the user has not requested a non-GCC compiler and the system GCC version is less than 14,
# use the GCC 14 compiler from Homebrew.
# This minimum was added because we use some features in PGM not available in older versions of GCC.
if !using_non_gcc && system_gcc_version < 14
gcc = Formula["gcc@14"]
system "cmake", "-GNinja", "-S", ".", "-B", "build",
"-DCMAKE_C_COMPILER=#{gcc.opt_bin}/gcc-14",
"-DCMAKE_CXX_COMPILER=#{gcc.opt_bin}/g++-14",
*std_cmake_args
else
system "cmake", "-GNinja", "-S", ".", "-B", "build",
*std_cmake_args
end
system "cmake", "-GNinja", "-S", ".", "-B", "build", *std_cmake_args
system "cmake", "--build", "build"
system "cmake", "--install", "build"
end
Expand Down
Loading