Skip to content

Commit 6912036

Browse files
committed
Changes to setup.py to facilitate making distributions from MacOS
1 parent 5a04499 commit 6912036

File tree

4 files changed

+86
-6
lines changed

4 files changed

+86
-6
lines changed

bionetgen/assets/BNGVERSION

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
BioNetGen-2.9.1
1+
BioNetGen-2.9.1

bionetgen/assets/ghapi.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"url": "https://api.github.com/repos/RuleWorld/bionetgen/releases/113526748", "assets_url": "https://api.github.com/repos/RuleWorld/bionetgen/releases/113526748/assets", "upload_url": "https://uploads.github.com/repos/RuleWorld/bionetgen/releases/113526748/assets{?name,label}", "html_url": "https://github.com/RuleWorld/bionetgen/releases/tag/BioNetGen-2.9.0", "id": 113526748, "author": {"login": "mr2cents", "id": 86616300, "node_id": "MDQ6VXNlcjg2NjE2MzAw", "avatar_url": "https://avatars.githubusercontent.com/u/86616300?v=4", "gravatar_id": "", "url": "https://api.github.com/users/mr2cents", "html_url": "https://github.com/mr2cents", "followers_url": "https://api.github.com/users/mr2cents/followers", "following_url": "https://api.github.com/users/mr2cents/following{/other_user}", "gists_url": "https://api.github.com/users/mr2cents/gists{/gist_id}", "starred_url": "https://api.github.com/users/mr2cents/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/mr2cents/subscriptions", "organizations_url": "https://api.github.com/users/mr2cents/orgs", "repos_url": "https://api.github.com/users/mr2cents/repos", "events_url": "https://api.github.com/users/mr2cents/events{/privacy}", "received_events_url": "https://api.github.com/users/mr2cents/received_events", "type": "User", "site_admin": false}, "node_id": "RE_kwDOAe1CjM4GxEfc", "tag_name": "BioNetGen-2.9.0", "target_commitish": "master", "name": "BioNetGen-2.9.0", "draft": false, "prerelease": false, "created_at": "2023-07-25T16:44:50Z", "published_at": "2023-07-25T17:03:16Z", "assets": [{"url": "https://api.github.com/repos/RuleWorld/bionetgen/releases/assets/118587100", "id": 118587100, "node_id": "RA_kwDOAe1CjM4HEX7c", "name": "BioNetGen-2.9.0-linux.tar.gz", "label": null, "uploader": {"login": "mr2cents", "id": 86616300, "node_id": "MDQ6VXNlcjg2NjE2MzAw", "avatar_url": "https://avatars.githubusercontent.com/u/86616300?v=4", "gravatar_id": "", "url": "https://api.github.com/users/mr2cents", "html_url": "https://github.com/mr2cents", "followers_url": "https://api.github.com/users/mr2cents/followers", "following_url": "https://api.github.com/users/mr2cents/following{/other_user}", "gists_url": "https://api.github.com/users/mr2cents/gists{/gist_id}", "starred_url": "https://api.github.com/users/mr2cents/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/mr2cents/subscriptions", "organizations_url": "https://api.github.com/users/mr2cents/orgs", "repos_url": "https://api.github.com/users/mr2cents/repos", "events_url": "https://api.github.com/users/mr2cents/events{/privacy}", "received_events_url": "https://api.github.com/users/mr2cents/received_events", "type": "User", "site_admin": false}, "content_type": "application/x-gzip", "state": "uploaded", "size": 78233963, "download_count": 2, "created_at": "2023-07-25T17:01:54Z", "updated_at": "2023-07-25T17:02:00Z", "browser_download_url": "https://github.com/RuleWorld/bionetgen/releases/download/BioNetGen-2.9.0/BioNetGen-2.9.0-linux.tar.gz"}, {"url": "https://api.github.com/repos/RuleWorld/bionetgen/releases/assets/118582570", "id": 118582570, "node_id": "RA_kwDOAe1CjM4HEW0q", "name": "BioNetGen-2.9.0-mac.tar.gz", "label": null, "uploader": {"login": "mr2cents", "id": 86616300, "node_id": "MDQ6VXNlcjg2NjE2MzAw", "avatar_url": "https://avatars.githubusercontent.com/u/86616300?v=4", "gravatar_id": "", "url": "https://api.github.com/users/mr2cents", "html_url": "https://github.com/mr2cents", "followers_url": "https://api.github.com/users/mr2cents/followers", "following_url": "https://api.github.com/users/mr2cents/following{/other_user}", "gists_url": "https://api.github.com/users/mr2cents/gists{/gist_id}", "starred_url": "https://api.github.com/users/mr2cents/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/mr2cents/subscriptions", "organizations_url": "https://api.github.com/users/mr2cents/orgs", "repos_url": "https://api.github.com/users/mr2cents/repos", "events_url": "https://api.github.com/users/mr2cents/events{/privacy}", "received_events_url": "https://api.github.com/users/mr2cents/received_events", "type": "User", "site_admin": false}, "content_type": "application/x-gzip", "state": "uploaded", "size": 48595935, "download_count": 0, "created_at": "2023-07-25T16:39:00Z", "updated_at": "2023-07-25T16:39:05Z", "browser_download_url": "https://github.com/RuleWorld/bionetgen/releases/download/BioNetGen-2.9.0/BioNetGen-2.9.0-mac.tar.gz"}, {"url": "https://api.github.com/repos/RuleWorld/bionetgen/releases/assets/118582606", "id": 118582606, "node_id": "RA_kwDOAe1CjM4HEW1O", "name": "BioNetGen-2.9.0-win.tar.gz", "label": null, "uploader": {"login": "mr2cents", "id": 86616300, "node_id": "MDQ6VXNlcjg2NjE2MzAw", "avatar_url": "https://avatars.githubusercontent.com/u/86616300?v=4", "gravatar_id": "", "url": "https://api.github.com/users/mr2cents", "html_url": "https://github.com/mr2cents", "followers_url": "https://api.github.com/users/mr2cents/followers", "following_url": "https://api.github.com/users/mr2cents/following{/other_user}", "gists_url": "https://api.github.com/users/mr2cents/gists{/gist_id}", "starred_url": "https://api.github.com/users/mr2cents/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/mr2cents/subscriptions", "organizations_url": "https://api.github.com/users/mr2cents/orgs", "repos_url": "https://api.github.com/users/mr2cents/repos", "events_url": "https://api.github.com/users/mr2cents/events{/privacy}", "received_events_url": "https://api.github.com/users/mr2cents/received_events", "type": "User", "site_admin": false}, "content_type": "application/x-gzip", "state": "uploaded", "size": 42114907, "download_count": 1, "created_at": "2023-07-25T16:39:16Z", "updated_at": "2023-07-25T16:39:20Z", "browser_download_url": "https://github.com/RuleWorld/bionetgen/releases/download/BioNetGen-2.9.0/BioNetGen-2.9.0-win.tar.gz"}], "tarball_url": "https://api.github.com/repos/RuleWorld/bionetgen/tarball/BioNetGen-2.9.0", "zipball_url": "https://api.github.com/repos/RuleWorld/bionetgen/zipball/BioNetGen-2.9.0", "body": "### Major changes\r\n* Species are exported to a SBML initial assignments block. Constant expressions are also exported in initial assignments block as long as they weren't a part of the original species block. This will improve the functionality of the exported SBML output for downstream tools.\r\n\r\n### Minor changes\r\n* Referring to observables or functions within species will result in an error as it could lead to circular dependency."}
1+
{"url": "https://api.github.com/repos/RuleWorld/bionetgen/releases/143539756", "assets_url": "https://api.github.com/repos/RuleWorld/bionetgen/releases/143539756/assets", "upload_url": "https://uploads.github.com/repos/RuleWorld/bionetgen/releases/143539756/assets{?name,label}", "html_url": "https://github.com/RuleWorld/bionetgen/releases/tag/BioNetGen-2.9.1", "id": 143539756, "author": {"login": "jrfaeder", "id": 8277248, "node_id": "MDQ6VXNlcjgyNzcyNDg=", "avatar_url": "https://avatars.githubusercontent.com/u/8277248?v=4", "gravatar_id": "", "url": "https://api.github.com/users/jrfaeder", "html_url": "https://github.com/jrfaeder", "followers_url": "https://api.github.com/users/jrfaeder/followers", "following_url": "https://api.github.com/users/jrfaeder/following{/other_user}", "gists_url": "https://api.github.com/users/jrfaeder/gists{/gist_id}", "starred_url": "https://api.github.com/users/jrfaeder/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/jrfaeder/subscriptions", "organizations_url": "https://api.github.com/users/jrfaeder/orgs", "repos_url": "https://api.github.com/users/jrfaeder/repos", "events_url": "https://api.github.com/users/jrfaeder/events{/privacy}", "received_events_url": "https://api.github.com/users/jrfaeder/received_events", "type": "User", "site_admin": false}, "node_id": "RE_kwDOAe1CjM4Ijj4s", "tag_name": "BioNetGen-2.9.1", "target_commitish": "master", "name": "BioNetGen-2.9.1", "draft": false, "prerelease": false, "created_at": "2024-02-25T22:15:48Z", "published_at": "2024-02-26T15:19:58Z", "assets": [{"url": "https://api.github.com/repos/RuleWorld/bionetgen/releases/assets/153825093", "id": 153825093, "node_id": "RA_kwDOAe1CjM4JKy9F", "name": "BioNetGen-2.9.1-linux.tar.gz", "label": null, "uploader": {"login": "jrfaeder", "id": 8277248, "node_id": "MDQ6VXNlcjgyNzcyNDg=", "avatar_url": "https://avatars.githubusercontent.com/u/8277248?v=4", "gravatar_id": "", "url": "https://api.github.com/users/jrfaeder", "html_url": "https://github.com/jrfaeder", "followers_url": "https://api.github.com/users/jrfaeder/followers", "following_url": "https://api.github.com/users/jrfaeder/following{/other_user}", "gists_url": "https://api.github.com/users/jrfaeder/gists{/gist_id}", "starred_url": "https://api.github.com/users/jrfaeder/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/jrfaeder/subscriptions", "organizations_url": "https://api.github.com/users/jrfaeder/orgs", "repos_url": "https://api.github.com/users/jrfaeder/repos", "events_url": "https://api.github.com/users/jrfaeder/events{/privacy}", "received_events_url": "https://api.github.com/users/jrfaeder/received_events", "type": "User", "site_admin": false}, "content_type": "application/x-gzip", "state": "uploaded", "size": 10002325, "download_count": 0, "created_at": "2024-02-27T14:51:05Z", "updated_at": "2024-02-27T14:51:06Z", "browser_download_url": "https://github.com/RuleWorld/bionetgen/releases/download/BioNetGen-2.9.1/BioNetGen-2.9.1-linux.tar.gz"}, {"url": "https://api.github.com/repos/RuleWorld/bionetgen/releases/assets/153825089", "id": 153825089, "node_id": "RA_kwDOAe1CjM4JKy9B", "name": "BioNetGen-2.9.1-mac.tar.gz", "label": null, "uploader": {"login": "jrfaeder", "id": 8277248, "node_id": "MDQ6VXNlcjgyNzcyNDg=", "avatar_url": "https://avatars.githubusercontent.com/u/8277248?v=4", "gravatar_id": "", "url": "https://api.github.com/users/jrfaeder", "html_url": "https://github.com/jrfaeder", "followers_url": "https://api.github.com/users/jrfaeder/followers", "following_url": "https://api.github.com/users/jrfaeder/following{/other_user}", "gists_url": "https://api.github.com/users/jrfaeder/gists{/gist_id}", "starred_url": "https://api.github.com/users/jrfaeder/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/jrfaeder/subscriptions", "organizations_url": "https://api.github.com/users/jrfaeder/orgs", "repos_url": "https://api.github.com/users/jrfaeder/repos", "events_url": "https://api.github.com/users/jrfaeder/events{/privacy}", "received_events_url": "https://api.github.com/users/jrfaeder/received_events", "type": "User", "site_admin": false}, "content_type": "application/x-gzip", "state": "uploaded", "size": 9118082, "download_count": 0, "created_at": "2024-02-27T14:51:04Z", "updated_at": "2024-02-27T14:51:05Z", "browser_download_url": "https://github.com/RuleWorld/bionetgen/releases/download/BioNetGen-2.9.1/BioNetGen-2.9.1-mac.tar.gz"}, {"url": "https://api.github.com/repos/RuleWorld/bionetgen/releases/assets/153825082", "id": 153825082, "node_id": "RA_kwDOAe1CjM4JKy86", "name": "BioNetGen-2.9.1-win.tar.gz", "label": null, "uploader": {"login": "jrfaeder", "id": 8277248, "node_id": "MDQ6VXNlcjgyNzcyNDg=", "avatar_url": "https://avatars.githubusercontent.com/u/8277248?v=4", "gravatar_id": "", "url": "https://api.github.com/users/jrfaeder", "html_url": "https://github.com/jrfaeder", "followers_url": "https://api.github.com/users/jrfaeder/followers", "following_url": "https://api.github.com/users/jrfaeder/following{/other_user}", "gists_url": "https://api.github.com/users/jrfaeder/gists{/gist_id}", "starred_url": "https://api.github.com/users/jrfaeder/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/jrfaeder/subscriptions", "organizations_url": "https://api.github.com/users/jrfaeder/orgs", "repos_url": "https://api.github.com/users/jrfaeder/repos", "events_url": "https://api.github.com/users/jrfaeder/events{/privacy}", "received_events_url": "https://api.github.com/users/jrfaeder/received_events", "type": "User", "site_admin": false}, "content_type": "application/x-gzip", "state": "uploaded", "size": 22154721, "download_count": 0, "created_at": "2024-02-27T14:51:03Z", "updated_at": "2024-02-27T14:51:04Z", "browser_download_url": "https://github.com/RuleWorld/bionetgen/releases/download/BioNetGen-2.9.1/BioNetGen-2.9.1-win.tar.gz"}], "tarball_url": "https://api.github.com/repos/RuleWorld/bionetgen/tarball/BioNetGen-2.9.1", "zipball_url": "https://api.github.com/repos/RuleWorld/bionetgen/zipball/BioNetGen-2.9.1", "body": "Fixes a bug that led to invalid SBML files being produced when there were internal variables in a BNGL models. These are produced when anything other than a simple parameter name is used in a RateLaw associated with a rule.\r\n\r\n*NOTE:* These bundles do not include binaries for sbmlTranslator or library files for compiling and linking to the CVODE library. These files are included in previous release bundles if you need them. For import and atomization of SBML models we strongly suggest you use the Atomizer library and tools included in the latest release of PyBioNetGen. Its functionality and reliability is much greater than that of the old sbmlTranslator code.\r\n\r\n**Full Changelog**: https://github.com/RuleWorld/bionetgen/compare/BioNetGen-2.9.0...BioNetGen-2.9.1"}

setup.py

+18-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
11
from setuptools import setup, find_packages
22
import sys, os, json, urllib, subprocess
3+
import shutil, tarfile, zipfile
4+
5+
# Utility function for Mac idiosyncracy
6+
def get_folder (arch):
7+
for fname in arch.getnames():
8+
if (fname.startswith('._')):
9+
continue
10+
else:
11+
break
12+
print(fname)
13+
return(fname)
314

415
subprocess.check_call([sys.executable, "-m", "pip", "install", "numpy"])
516
import urllib.request
@@ -22,7 +33,7 @@
2233
bng_version_tag = rls_json["tag_name"]
2334
with open("bionetgen/assets/BNGVERSION", "w") as f:
2435
f.write(bng_version_tag)
25-
# get assests
36+
# get assets
2637
assets = rls_json["assets"]
2738
for asset in assets:
2839
browser_url = asset["browser_download_url"]
@@ -36,7 +47,6 @@
3647
windows_url = browser_url
3748

3849
# next download and place the appropriate files
39-
import os, shutil, tarfile, zipfile
4050

4151
bng_downloaded = False
4252
for iurl, bng_url in enumerate([linux_url, mac_url, windows_url]):
@@ -72,13 +82,17 @@
7282
ext = bng_url.split(".")[-1]
7383
fname = "bng.{}".format(ext)
7484
# download bng distro
85+
print(bng_url, fname)
7586
urllib.request.urlretrieve(bng_url, fname)
7687
# file extension dependent actions, tar for
7788
# mac and linux, zip for windows
7889
if iurl < 2:
7990
# if "tgz" == ext or "gz" == etx:
8091
bng_arch = tarfile.open(fname)
81-
fold_name = bng_arch.getnames()[0]
92+
# Find containing folder of the archive.
93+
# On macs may need to skip first item because
94+
# filesystem makes shadow files with `._` prepended.
95+
fold_name = get_folder(bng_arch)
8296
bng_arch.extractall()
8397
# make sure bionetgen/bng exists
8498
if iurl == 0:
@@ -114,7 +128,7 @@
114128
# fold_name = bng_arch.namelist()[0]
115129
# bng_arch.extractall()
116130
bng_arch = tarfile.open(fname)
117-
fold_name = bng_arch.getnames()[0]
131+
fold_name = get_folder(bng_arch)
118132
bng_arch.extractall()
119133
# bng folder
120134
if iurl == 2:

test_tarfile.ipynb

+66
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "code",
5+
"execution_count": 1,
6+
"metadata": {},
7+
"outputs": [],
8+
"source": [
9+
"import tarfile"
10+
]
11+
},
12+
{
13+
"cell_type": "code",
14+
"execution_count": 8,
15+
"metadata": {},
16+
"outputs": [
17+
{
18+
"name": "stdout",
19+
"output_type": "stream",
20+
"text": [
21+
"BioNetGen-2.9.1\n"
22+
]
23+
}
24+
],
25+
"source": [
26+
"fname=\"bng.gz\"\n",
27+
"bng_arch = tarfile.open(fname)\n",
28+
"for i in range(2):\n",
29+
" fold_name = bng_arch.getnames()[i]\n",
30+
" if (fold_name.startswith('._')):\n",
31+
" continue\n",
32+
" else:\n",
33+
" break\n",
34+
"print(fold_name)"
35+
]
36+
},
37+
{
38+
"cell_type": "code",
39+
"execution_count": null,
40+
"metadata": {},
41+
"outputs": [],
42+
"source": []
43+
}
44+
],
45+
"metadata": {
46+
"kernelspec": {
47+
"display_name": "base",
48+
"language": "python",
49+
"name": "python3"
50+
},
51+
"language_info": {
52+
"codemirror_mode": {
53+
"name": "ipython",
54+
"version": 3
55+
},
56+
"file_extension": ".py",
57+
"mimetype": "text/x-python",
58+
"name": "python",
59+
"nbconvert_exporter": "python",
60+
"pygments_lexer": "ipython3",
61+
"version": "3.9.7"
62+
}
63+
},
64+
"nbformat": 4,
65+
"nbformat_minor": 2
66+
}

0 commit comments

Comments
 (0)