Skip to content

Commit

Permalink
add casacore data again
Browse files Browse the repository at this point in the history
  • Loading branch information
d3v-null committed Jan 29, 2025
1 parent 4c0dd20 commit 27e7d3c
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 3 deletions.
29 changes: 27 additions & 2 deletions .github/workflows/bottle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,42 @@ jobs:

- run: brew test-bot --only-tap-syntax

# todo:
# - run: brew test-bot --only-formulae Formula/cfitsio_reentrant.rb Formula/casacore-data.rb
# Error: Unexpected bottle tarball: /Users/runner/work/homebrew-tap/homebrew-tap/cfitsio_reentrant--4.5.0_1.arm64_sonoma.bottle.1.tar.gz
# Error: Unexpected bottle JSON: /Users/runner/work/homebrew-tap/homebrew-tap/cfitsio_reentrant--4.5.0_1.arm64_sonoma.bottle.json
#
# - run: brew test-bot --only-formulae Formula/casacore.rb
# Error: Failed to load cask: Formula/casacore-data.rb
# Cask 'casacore-data' is unreadable: wrong constant name #<Class:0x00000001399f8c08>
# Error: Failed to load cask: Formula/casacore.rb
# Cask 'casacore' is unreadable: wrong constant name #<Class:0x0000000139ab83f0>
# Warning: Treating Formula/casacore.rb as a formula.
# Error: The `brew link` step did not complete successfully
# The formula built, but is not symlinked into /opt/homebrew
# Could not symlink include/fitsio.h
# Target /opt/homebrew/include/fitsio.h
# is a symlink belonging to cfitsio_reentrant. You can unlink it:
# brew unlink cfitsio_reentrant
# To force the link and overwrite all conflicting files:
# brew link --overwrite cfitsio
# To list all files that would be deleted:
# brew link --overwrite cfitsio --dry-run
# Possible conflicting files are:
# /opt/homebrew/include/fitsio.h -> /opt/homebrew/Cellar/cfitsio_reentrant/4.5.0_1/include/fitsio.h
# /opt/homebrew/include/fitsio2.h -> /opt/homebrew/Cellar/cfitsio_reentrant/4.5.0_1/include/fitsio2.h
# /opt/homebrew/include/longnam.h -> /opt/homebrew/Cellar/cfitsio_reentrant/4.5.0_1/include/longnam.h
- run: brew test-bot --only-formulae Formula/aoflagger.rb Formula/birli.rb

- name: Get version number from current date
run: echo "DATE=$(date +'v%Y.%m.%d.%H.%M')" | tee -a "$GITHUB_ENV"

- name: get archive names
id: archive_names
run: |
# build casacore source first
brew install --build-from-source Formula/casacore.rb
brew install --build-from-source Formula/cfitsio_reentrant.rb
brew install --build-from-source Formula/casacore-data.rb
brew install --build-from-source Formula/casacore.rb
for package in aoflagger birli; do
brew install --build-bottle Formula/$package.rb
brew bottle --json Formula/$package.rb
Expand Down
52 changes: 52 additions & 0 deletions Formula/casacore-data.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
class ZtarDownloadStrategy < CurlDownloadStrategy
def stage(&block)
UnpackStrategy::Tar.new(cached_location).extract(basename:, verbose: verbose?)
chdir(&block)
end
end

class CasacoreData < Formula
desc "Ephemerides and geodetic data for casacore measures (via Astron)"
homepage "https://github.com/casacore/casacore"
# curl ftp://[email protected]/outgoing/Measures/
url "ftp://[email protected]/outgoing/Measures/WSRT_Measures_20250128-160001.ztar", using: ZtarDownloadStrategy
# curl -s 'ftp://[email protected]/outgoing/Measures/WSRT_Measures_20250128-160001.ztar' | sha256 -
sha256 "5835e3f5458d8f88fd057044a891d26a5cbfdec9a865967b1189d4fd52140c80"
head "ftp://ftp.astron.nl/outgoing/Measures/WSRT_Measures.ztar", using: ZtarDownloadStrategy

option "with-casapy", "Use Mac CASA.App (aka casapy) data directory if found"

deprecated_option "use-casapy" => "with-casapy"

APP_DIR = (Pathname.new "/Applications").freeze
CASAPY_APP_NAME = "CASA.app".freeze
CASAPY_APP_DIR = (APP_DIR / CASAPY_APP_NAME).freeze
CASAPY_DATA = (CASAPY_APP_DIR / "Contents/data").freeze

def install
if build.with? "casapy"
if !Dir.exist? CASAPY_APP_DIR
odie "--with-casapy was specified, but #{CASAPY_APP_NAME} was not found in #{APP_DIR}"
elsif !Dir.exist? CASAPY_DATA
odie "--with-casapy was specified, but data directory not found at #{CASAPY_DATA}"
end
prefix.install_symlink CASAPY_DATA
else
(prefix / CASAPY_DATA.basename).install Dir["*"]
end
end

def caveats
data_dir = prefix / CASAPY_DATA.basename
if File.symlink? data_dir
"Linked to CASA data directory (#{CASAPY_DATA}) from #{data_dir}"
else
"Installed latest Astron WSRT_Measures tarball to #{data_dir}"
end
end

test do
Dir.exist? (prefix / CASAPY_DATA.basename / "ephemerides")
Dir.exist? (prefix / CASAPY_DATA.basename / "geodetic")
end
end
2 changes: 1 addition & 1 deletion Formula/casacore.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ class Casacore < Formula
option "without-python", "Build without Python bindings"

depends_on "cmake" => :build
depends_on "casacore/tap/casacore-data"
depends_on "cfitsio_reentrant"
depends_on "fftw"
depends_on "gcc" # for gfortran
depends_on "gsl"
depends_on "hdf5"
depends_on "mwatelescope/tap/casacore-data"
depends_on "ncurses"
depends_on "openblas"
depends_on "readline"
Expand Down

0 comments on commit 27e7d3c

Please sign in to comment.