Skip to content

Commit

Permalink
try downloading wx
Browse files Browse the repository at this point in the history
  • Loading branch information
dguittet committed May 20, 2024
1 parent d60c696 commit 7e10a3f
Show file tree
Hide file tree
Showing 2 changed files with 81 additions and 13 deletions.
33 changes: 20 additions & 13 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,27 @@ jobs:
libgtk2.0-dev \
mesa-common-dev \
unzip
- name: Get Python version
run: |
which python
python --version
- name: Install wxWidgets
- name: Checkout
uses: actions/checkout@v2
with:
path: wex
- name: Download wxWidgets
run: |
sudo apt-get install -y libwxgtk*-dev
sudo ln -s $(which wx-config) /usr/local/bin/wx-config-3
python .github/workflows/download_wx.py
dir
dir wx-3.2.3
echo "WXMSW3=$GITHUB_WORKSPACE/wx-3.2.3" >>$GITHUB_ENV
chmod +x wx-3.2.3/bin/wx-config
chmod +x wx-3.2.3/lib/wx/config/osx_cocoa-unicode-static-3.2
sudo ln -s $GITHUB_WORKSPACE/wx-3.2.3/bin/wx-config /usr/local/bin/wx-config-3
wx-config-3 --cflags | grep I
echo ${GITHUB_WORKSPACE}/wx-3.2.3/bin >> $GITHUB_PATH
# - name: Install wxWidgets
# run: |
# sudo apt-get install -y libwxgtk*-dev
# sudo ln -s $(which wx-config) /usr/local/bin/wx-config-3
# wx-config-3 --cflags | grep I

- name: Get git ref of sibling dependency LK
run: |
Expand All @@ -60,7 +71,7 @@ jobs:
run: |
cd $GITHUB_WORKSPACE/lk
cmake -Bbuild_linux -DCMAKE_BUILD_TYPE=Debug
cmake --build build_linux -- -j
cmake --build build_linux -j4
- name: Set LKDIR
run: |
echo "LKDIR=$GITHUB_WORKSPACE/lk" >>$GITHUB_ENV
Expand Down Expand Up @@ -88,10 +99,6 @@ jobs:
path: ssc
repository: NREL/ssc

- name: Checkout
uses: actions/checkout@v2
with:
path: wex
- name: Build WEX
run: |
cd $GITHUB_WORKSPACE/wex
Expand Down
61 changes: 61 additions & 0 deletions .github/workflows/download_wx.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import os
import requests
import platform
import re
from pathlib import Path
import zipfile
import sys

if len(sys.argv) == 1:
raise RuntimeError(f"Script require argument of directory name for wxWidgets folder")
wx_dir_name = sys.argv[1]

cwd = Path(os.getcwd())

github_token = os.environ.get("GITHUB_TOKEN")
headers = {
'Accept': 'application/vnd.github+json',
'Authorization': f'Bearer {github_token}',
'X-GitHub-Api-Version': '2022-11-28',
}

os_name = platform.system()

if os_name == "Windows":
wx_name = "wxWidgets-windows"
elif os_name == "Linux":
wx_name = "wxWidgets-linux"
elif os_name == "Darwin":
os_name = platform.platform()
if 'arm' in os_name:
wx_name = 'wxWidgets-macos-latest'
else:
wx_name = 'wxWidgets-macos-[0-9][0-9]-large'
else:
raise Exception(f"{os_name} operating system not implemented")

response = requests.get('https://api.github.com/repos/NREL/lk/actions/artifacts', headers=headers)
r = response.json()
artifacts = r['artifacts']

matching_artifacts = [art for art in artifacts if re.search(wx_name, art['name'])]
artifact = matching_artifacts[0]

headers = {
'Accept': 'application/vnd.github+json',
'Authorization': f'Bearer {github_token}',
'X-GitHub-Api-Version': '2022-11-28',
}

response = requests.get(
artifact['archive_download_url'],
headers=headers,
)

with open(cwd / 'wx.zip', 'wb') as f:
f.write(response.content)

with zipfile.ZipFile('wx.zip', "r") as zip_ref:
zip_ref.extractall(cwd / f"{wx_dir_name}")

print(f"Extracted to {str(cwd / f"{wx_dir_name}")}")

0 comments on commit 7e10a3f

Please sign in to comment.