Skip to content

Commit d524a08

Browse files
authored
Update PyPI workflows (#149)
1 parent 4049d48 commit d524a08

File tree

9 files changed

+221
-1
lines changed

9 files changed

+221
-1
lines changed

.github/workflows/build_publish_hiv.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,38 @@ jobs:
2727
uses: actions/setup-python@v5
2828
with:
2929
python-version: "3.x"
30+
- name: Download executable
31+
uses: actions/download-artifact@v5
32+
with:
33+
name: Eradication
34+
path: pypi_hiv/src/eradication_dir
35+
- name: Download schema
36+
uses: actions/download-artifact@v5
37+
with:
38+
name: schema.json
39+
path: pypi_hiv/src/schema_dir
40+
- name: Download version
41+
uses: actions/download-artifact@v5
42+
with:
43+
name: version
44+
path: pypi_hiv/src/version_dir
45+
- name: Prep files
46+
run: |
47+
cd pypi_hiv
48+
cd src
49+
mv version_dir/version version
50+
zip -j emod_hiv/Eradication.zip eradication_dir/Eradication
51+
zip -j emod_hiv/schema.zip schema_dir/schema.json
52+
rm -r version_dir
53+
rm -r eradication_dir
54+
rm -r schema_dir
55+
- name: Build PyPI distribution
56+
run: |
57+
python3 -m pip install build
58+
cd pypi_hiv
59+
python3 -m build
60+
- name: Upload files to PyPI
61+
uses: pypa/gh-action-pypi-publish@release/v1
62+
with:
63+
verbose: true
64+
packages-dir: pypi_hiv/dist

.github/workflows/build_publish_malaria.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,38 @@ jobs:
2727
uses: actions/setup-python@v5
2828
with:
2929
python-version: "3.x"
30+
- name: Download executable
31+
uses: actions/download-artifact@v5
32+
with:
33+
name: Eradication
34+
path: pypi_malaria/src/eradication_dir
35+
- name: Download schema
36+
uses: actions/download-artifact@v5
37+
with:
38+
name: schema.json
39+
path: pypi_malaria/src/schema_dir
40+
- name: Download version
41+
uses: actions/download-artifact@v5
42+
with:
43+
name: version
44+
path: pypi_malaria/src/version_dir
45+
- name: Prep files
46+
run: |
47+
cd pypi_malaria
48+
cd src
49+
mv version_dir/version version
50+
zip -j emod_malaria/Eradication.zip eradication_dir/Eradication
51+
zip -j emod_malaria/schema.zip schema_dir/schema.json
52+
rm -r version_dir
53+
rm -r eradication_dir
54+
rm -r schema_dir
55+
- name: Build PyPI distribution
56+
run: |
57+
python3 -m pip install build
58+
cd pypi_malaria
59+
python3 -m build
60+
- name: Upload files to PyPI
61+
uses: pypa/gh-action-pypi-publish@release/v1
62+
with:
63+
verbose: true
64+
packages-dir: pypi_malaria/dist

pypi_common/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ build-backend = "setuptools.build_meta"
55
[project]
66
name = "emod-common"
77
dynamic = ["version"]
8-
description = "PyPI distribution of EMOD files for testing common to all sim types"
8+
description = "PyPI distribution of EMOD for testing features common to all sim types"
99
license = "MIT"
1010
authors = [
1111
]

pypi_hiv/pyproject.toml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
[build-system]
2+
requires = ["setuptools"]
3+
build-backend = "setuptools.build_meta"
4+
5+
[project]
6+
name = "emod-hiv"
7+
dynamic = ["version"]
8+
description = "PyPI distribution of EMOD for the HIV sim type"
9+
license = "MIT"
10+
authors = [
11+
]
12+
readme = "README.md"
13+
requires-python = ">=3.9"
14+
dependencies = [
15+
]
16+
classifiers = [
17+
"Operating System :: POSIX :: Linux",
18+
"Programming Language :: C++",
19+
"Topic :: Scientific/Engineering :: Bio-Informatics",
20+
]
21+
22+
[project.optional-dependencies]
23+
docs = [
24+
]
25+
tests = [
26+
]
27+
28+
[project.urls]
29+
Documentation = "https://docs.idmod.org/projects/emod/en/latest/"
30+
Repository = "https://github.com/EMOD-Hub/EMOD"
31+
Issues = "https://github.com/EMOD-Hub/EMOD/issues"
32+
33+
[tool.setuptools.package-data]
34+
"*" = ["*.zip"]
35+
36+
[tool.setuptools.dynamic]
37+
version = {file = ["src/version"]}

pypi_hiv/src/emod_hiv/__init__.py

Whitespace-only changes.

pypi_hiv/src/emod_hiv/bootstrap.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import os
2+
import sys
3+
import shutil
4+
import zipfile
5+
from glob import glob
6+
7+
8+
def extract(package_name, local_dir):
9+
os.makedirs(local_dir, exist_ok=True)
10+
os.chdir(local_dir)
11+
12+
pkgdir = sys.modules[package_name].__path__[0]
13+
# extract all *.zip files in the package, preserve relative file paths
14+
for fullpath in glob(os.path.join(pkgdir, "**/*.zip"), recursive=True):
15+
# determine zip relative filepath
16+
rel_filepath = os.path.relpath(fullpath, pkgdir)
17+
rel_dir = os.path.dirname(rel_filepath)
18+
if rel_dir and len(rel_dir) > 0:
19+
os.makedirs(rel_dir, exist_ok=True)
20+
# copy archive under current dir
21+
temp_zip_path = os.path.join(os.getcwd(), rel_filepath)
22+
shutil.copy(fullpath, temp_zip_path)
23+
with zipfile.ZipFile(rel_filepath, 'r') as zip_ref:
24+
zip_ref.extractall(rel_dir)
25+
os.unlink(temp_zip_path)
26+
27+
os.chdir("..")
28+
29+
30+
def setup(local_dir="stash"):
31+
"""
32+
Extract binary and schema into a local directory.
33+
"""
34+
extract('emod_hiv', local_dir)
35+
36+
37+
if __name__ == "__main__":
38+
setup()

pypi_malaria/pyproject.toml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
[build-system]
2+
requires = ["setuptools"]
3+
build-backend = "setuptools.build_meta"
4+
5+
[project]
6+
name = "emod-malaria"
7+
dynamic = ["version"]
8+
description = "PyPI distribution of EMOD for the Malaria sim type"
9+
license = "MIT"
10+
authors = [
11+
]
12+
readme = "README.md"
13+
requires-python = ">=3.9"
14+
dependencies = [
15+
]
16+
classifiers = [
17+
"Operating System :: POSIX :: Linux",
18+
"Programming Language :: C++",
19+
"Topic :: Scientific/Engineering :: Bio-Informatics",
20+
]
21+
22+
[project.optional-dependencies]
23+
docs = [
24+
]
25+
tests = [
26+
]
27+
28+
[project.urls]
29+
Documentation = "https://docs.idmod.org/projects/emod/en/latest/"
30+
Repository = "https://github.com/EMOD-Hub/EMOD"
31+
Issues = "https://github.com/EMOD-Hub/EMOD/issues"
32+
33+
[tool.setuptools.package-data]
34+
"*" = ["*.zip"]
35+
36+
[tool.setuptools.dynamic]
37+
version = {file = ["src/version"]}

pypi_malaria/src/emod_malaria/__init__.py

Whitespace-only changes.
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import os
2+
import sys
3+
import shutil
4+
import zipfile
5+
from glob import glob
6+
7+
8+
def extract(package_name, local_dir):
9+
os.makedirs(local_dir, exist_ok=True)
10+
os.chdir(local_dir)
11+
12+
pkgdir = sys.modules[package_name].__path__[0]
13+
# extract all *.zip files in the package, preserve relative file paths
14+
for fullpath in glob(os.path.join(pkgdir, "**/*.zip"), recursive=True):
15+
# determine zip relative filepath
16+
rel_filepath = os.path.relpath(fullpath, pkgdir)
17+
rel_dir = os.path.dirname(rel_filepath)
18+
if rel_dir and len(rel_dir) > 0:
19+
os.makedirs(rel_dir, exist_ok=True)
20+
# copy archive under current dir
21+
temp_zip_path = os.path.join(os.getcwd(), rel_filepath)
22+
shutil.copy(fullpath, temp_zip_path)
23+
with zipfile.ZipFile(rel_filepath, 'r') as zip_ref:
24+
zip_ref.extractall(rel_dir)
25+
os.unlink(temp_zip_path)
26+
27+
os.chdir("..")
28+
29+
30+
def setup(local_dir="stash"):
31+
"""
32+
Extract binary and schema into a local directory.
33+
"""
34+
extract('emod_malaria', local_dir)
35+
36+
37+
if __name__ == "__main__":
38+
setup()

0 commit comments

Comments
 (0)