Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix building the CLI on macOS #269

Merged
merged 53 commits into from
Apr 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
cdb2dae
Install LHAPDF on macOS
cschwan Mar 30, 2024
211e0cb
Disable Python
cschwan Mar 30, 2024
e60610a
Correctly disable Python
cschwan Mar 30, 2024
436f5bf
Fix `--disable-dynamic` with `--disable-shared`
cschwan Mar 30, 2024
838ede0
Do not run workflows in this branch
cschwan Mar 30, 2024
3d2cc9f
Use brew to install LHAPDF on macOS
cschwan Mar 30, 2024
8bd5c7b
Run Release workflow automatically in this branch
cschwan Mar 30, 2024
893ccd1
Create missing directory
cschwan Mar 30, 2024
f4785c1
Fix problems with workflow syntax
cschwan Mar 30, 2024
b979e64
Simplify matrix strategy a bit
cschwan Mar 30, 2024
8f92f10
Try to fix packaging the CLI
cschwan Mar 30, 2024
1798253
Add comment why we can't cross compile
cschwan Mar 30, 2024
55487a1
Simplify CLI installation on Linux
cschwan Mar 30, 2024
ff7d972
Add missing `--locked` switch to installation
cschwan Apr 1, 2024
b0ed230
Install and use APPLgrid on macOS
cschwan Apr 1, 2024
ca7d198
Download sources and export `APPL_IGRID_DIR` on macOS
cschwan Apr 1, 2024
71eb9e7
Add some diagnostics for homebrew
cschwan Apr 1, 2024
508cf26
Keep temporary directory when compiling with brew
cschwan Apr 1, 2024
294f966
Fix `APPL_IGRID_DIR` determination
cschwan Apr 1, 2024
32d3ede
Print more diagnostics
cschwan Apr 1, 2024
d8768da
Add missing include paths for `pineappl_applgrid`
cschwan Apr 1, 2024
64d9a8e
Add more tested versions of APPLgrid
cschwan Apr 1, 2024
1d9af8c
Set C++ standard in `pineappl_applgrid`
cschwan Apr 1, 2024
6ad166b
Reduce APPLgrid dependencies and install zlib
cschwan Apr 2, 2024
966d6af
Fix C++ warning
cschwan Apr 2, 2024
1bf9207
Force installation of zlib and list contents
cschwan Apr 2, 2024
382c160
Print zlib search path
cschwan Apr 2, 2024
2838f9d
Install `pkg-config` to find zlib from brew
cschwan Apr 2, 2024
204d977
Fix `pkg-config` call
cschwan Apr 2, 2024
3f42594
Add more diagnostic to pkg-config call
cschwan Apr 3, 2024
0d39e0e
Print more diagnostic strings
cschwan Apr 3, 2024
d2069cd
List contents of the ROOT installation
cschwan Apr 3, 2024
a196b1b
Compile APPLgrid without ROOT
cschwan Apr 3, 2024
47edd07
Add missing `--without-root`
cschwan Apr 3, 2024
2363abc
Manually install zlib
cschwan Apr 3, 2024
fee20cf
Print `applgrid-config` script to diagnose building failure
cschwan Apr 3, 2024
dc1e31b
Force-remove linking to `gfortran`
cschwan Apr 3, 2024
f66ad69
Rename existing `tmp` with `new`
cschwan Apr 3, 2024
fd7efcc
Remove diagnostics and simplify `sed` call
cschwan Apr 3, 2024
8a34da2
Revert last commit except the removal of diagnostics
cschwan Apr 3, 2024
e8741dd
Compile CLI on macOS against fastNLO
cschwan Apr 3, 2024
6439141
Update `cc` create to fix yet another problem on macOS
cschwan Apr 3, 2024
31573c5
Update `cxx` and related crates to hopefull fix missing compiler flag
cschwan Apr 3, 2024
ad0de9a
Explicitly set C++11 standard
cschwan Apr 3, 2024
b7aa304
Add LHAPDF include paths to fastNLO
cschwan Apr 3, 2024
98403f5
Install manpages on both Linux and macOS
cschwan Apr 4, 2024
41514a7
Debug version string when installing manpages
cschwan Apr 4, 2024
708f58d
Try to fix version string patching on GitHub
cschwan Apr 4, 2024
40d962a
Add zlib when linking statically
cschwan Apr 5, 2024
4f7a3cd
Merge branch 'master' into fix-macos-cli-generation
cschwan Apr 23, 2024
4379124
Revert "refactor: Use Rust version of convolute_with_one"
cschwan Apr 26, 2024
d1ed863
Remove `signature` macro that breaks Python 3.6 support
cschwan Apr 26, 2024
0e5127e
Try to fix problems on macOS
cschwan Apr 26, 2024
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 .github/workflows/capi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ name: CAPI

on:
push:
branches-ignore:
- fix-macos-cli-generation

jobs:
capi:
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/msrv.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ name: MSRV

on:
push:
branches-ignore:
- fix-macos-cli-generation

env:
CARGO_TERM_COLOR: always
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ name: Python

on:
push:
branches-ignore:
- fix-macos-cli-generation

jobs:
test:
Expand Down
51 changes: 39 additions & 12 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ on:
push:
tags:
- 'v[0-9]+*'
branches:
- fix-macos-cli-generation
workflow_dispatch:

env:
Expand Down Expand Up @@ -31,9 +33,9 @@ jobs:
- name: Compile library
run: |
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --target=${{ matrix.target }}
cargo install cargo-c
cargo install --locked cargo-c
cd pineappl_capi
cargo cinstall --verbose --destdir=prefix --library-type=cdylib --prefix=/ --target=${{ matrix.target }}
cargo cinstall --destdir=prefix --library-type=cdylib --locked --prefix=/ --target=${{ matrix.target }} --verbose
cd prefix
tar czf ../../pineappl_capi-${{ matrix.target }}.tar.gz .
- name: Upload artifact
Expand All @@ -46,20 +48,44 @@ jobs:
cli-macos:
strategy:
matrix:
os: [macos-latest, macos-14]
include:
- os: macos-latest
- os: macos-13
target: x86_64-apple-darwin
- os: macos-14
# we cannot cross-compile, because we need also all dependencies for the specified target
target: aarch64-apple-darwin
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Compile binary
run: |
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --target=${{ matrix.target }}
cargo build --release --features=evolve,fktable,static --bin pineappl --target=${{ matrix.target }}
cp target/release/pineappl prefix/bin/
brew tap davidchall/hep
# install LHAPDF
brew install lhapdf
# install APPLgrid's dependencies; disable ROOT because its static libraries are missing
brew install --only-dependencies --without-hoppet --without-lhapdf --without-root applgrid
# install zlib, which is a dependency of APPLgrid but somehow missing
brew install zlib
# APPLgrid wants to be linked against zlib, and we need to find its static library via pkg-config
export PKG_CONFIG_PATH=$(find $(brew --cellar) -name '*.pc' -exec dirname {} + | sort -u | tr '\n' ':')
# manually compile APPLgrid, because we need the file `appl_igrid.h` and the files it includes, which are possibly generated
export HOMEBREW_TEMP="$(pwd)"/tmp
mkdir -p ${HOMEBREW_TEMP}
brew install --build-from-source --keep-tmp --without-hoppet --without-lhapdf --without-root applgrid
export APPL_IGRID_DIR=$(find ${HOMEBREW_TEMP} -name appl_igrid.h -exec dirname {} +)
# do not link against `gfortran`
sed 's/-lgfortran//g' $(command -v applgrid-config) > applgrid-config.new
mv applgrid-config.new $(command -v applgrid-config)
chmod +x $(command -v applgrid-config)
# install fastNLO
brew install --without-fastjet fastnlo
# install Rust
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-host=${{ matrix.target }}
# build the CLI
cargo install --all-features --locked --path pineappl_cli --root=prefix --target=${{ matrix.target }}
# build manpages
mkdir -p prefix/share/man/man1
cargo xtask install-manpages prefix/share/man/man1
cd prefix
tar czf ../pineappl_cli-${{ matrix.target }}.tar.gz .
- name: Upload artifact
Expand All @@ -81,7 +107,7 @@ jobs:
- name: Compile library
run: |
cd pineappl_capi
cargo cinstall --verbose --destdir=prefix --library-type=cdylib --prefix=/ --target=${{ matrix.target }}
cargo cinstall --destdir=prefix --library-type=cdylib --locked --prefix=/ --target=${{ matrix.target }} --verbose
cd prefix
tar czf ../../pineappl_capi-${{ matrix.target }}.tar.gz .
# print the glibc version requirement
Expand All @@ -104,9 +130,10 @@ jobs:
- uses: actions/checkout@v3
- name: Compile binary
run: |
cargo build --release --all-features --bin pineappl
mkdir -p prefix/bin
cp target/release/pineappl prefix/bin/
cargo install --all-features --locked --path pineappl_cli --root=prefix --target=${{ matrix.target }}
# build manpages
mkdir -p prefix/share/man/man1
cargo xtask install-manpages prefix/share/man/man1
cd prefix
tar czf ../pineappl_cli-${{ matrix.target }}.tar.gz .
- name: Upload artifact
Expand Down Expand Up @@ -235,7 +262,7 @@ jobs:
path: dist

wheels-macos:
runs-on: macos-latest
runs-on: macos-13
strategy:
matrix:
target: [aarch64, x86_64]
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ name: Rust

on:
push:
branches-ignore:
- fix-macos-cli-generation

defaults:
run:
Expand Down
12 changes: 6 additions & 6 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

38 changes: 38 additions & 0 deletions pineappl_py/pineappl/fk_table.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import numpy as np

from .pineappl import PyFkTable, PyFkAssumptions
from .utils import PyWrapper

Expand Down Expand Up @@ -50,6 +52,42 @@ def optimize(self, assumptions = "Nf6Ind"):
assumptions = FkAssumptions(assumptions)
return self._raw.optimize(assumptions._raw)

def convolute_with_one(
self,
pdg_id,
xfx,
bin_indices=np.array([], dtype=np.uint64),
lumi_mask=np.array([], dtype=bool),
):
r"""Convolute FkTable with a pdf.

Parameters
----------
pdg_id : int
PDG Monte Carlo ID of the hadronic particle `xfx` is the PDF for
xfx : callable
lhapdf like callable with arguments `pid, x, Q2` returning x*pdf for :math:`x`-grid
bin_indices : sequence(int)
A list with the indices of the corresponding bins that should be calculated. An
empty list means that all orders should be calculated.
lumi_mask : sequence(bool)
Mask for selecting specific luminosity channels. The value `True` means the
corresponding channel is included. An empty list corresponds to all channels being
enabled.

Returns
-------
list(float) :
cross sections for all bins, for each scale-variation tuple (first all bins, then
the scale variation)
"""
return self.raw.convolute_with_one(
pdg_id,
xfx,
np.array(bin_indices),
np.array(lumi_mask),
)


class FkAssumptions(PyWrapper):
"""
Expand Down
1 change: 0 additions & 1 deletion pineappl_py/src/fk_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,6 @@ impl PyFkTable {
/// -------
/// numpy.ndarray(float) :
/// cross sections for all bins
#[pyo3(signature = (pdg_id, xfx, bin_indices = None, lumi_mask= None))]
pub fn convolute_with_one<'py>(
&self,
pdg_id: i32,
Expand Down
Loading