Skip to content

Commit 67e522e

Browse files
authored
Merge pull request #263 from kayjan/fix-playground
bump: v0.19.1 + dynamically fetch latest whl file
2 parents ee73aee + 3dca4f2 commit 67e522e

File tree

4 files changed

+25
-112
lines changed

4 files changed

+25
-112
lines changed

CHANGELOG.md

+5-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

77
## [Unreleased]
8+
9+
## [0.19.1] - 2024-06-26
810
### Changed:
9-
- Docs: Add glossary section to documentation.
11+
- Docs: Add playground and glossary section to documentation.
1012

1113
## [0.19.0] - 2024-06-15
1214
### Changed:
@@ -599,7 +601,8 @@ ignore null attribute columns.
599601
- Utility Iterator: Tree traversal methods.
600602
- Workflow To Do App: Tree use case with to-do list implementation.
601603

602-
[Unreleased]: https://github.com/kayjan/bigtree/compare/0.19.0...HEAD
604+
[Unreleased]: https://github.com/kayjan/bigtree/compare/0.19.1...HEAD
605+
[0.19.1]: https://github.com/kayjan/bigtree/compare/0.19.0...0.19.1
603606
[0.19.0]: https://github.com/kayjan/bigtree/compare/0.18.3...0.19.0
604607
[0.18.3]: https://github.com/kayjan/bigtree/compare/0.18.2...0.18.3
605608
[0.18.2]: https://github.com/kayjan/bigtree/compare/0.18.1...0.18.2

bigtree/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
__version__ = "0.19.0"
1+
__version__ = "0.19.1"
22

33
from bigtree.binarytree.construct import list_to_binarytree
44
from bigtree.dag.construct import dataframe_to_dag, dict_to_dag, list_to_dag

docs/_static/playground_whl.py

+18-108
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,14 @@
1-
import glob
21
import os
3-
import re
4-
import shutil
5-
import subprocess
6-
import sys
7-
import urllib.error
8-
import urllib.request
2+
3+
import requests
94

105
# Output files
11-
OUTPUT_WHL = "docs/wheels/"
126
OUTPUT_JS = "docs/_static/"
137

14-
# Build message output
15-
# BUILD_WHL_MESSAGE = f"{OUTPUT_WHL}(.*whl)"
16-
# BUILD_WHL_COMMAND = [sys.executable, "-m", "hatch", "build", OUTPUT_WHL]
17-
BUILD_WHL_MESSAGE = r"Successfully built ([-_0-9.a-zA-Z]+?\.whl)"
18-
BUILD_WHL_COMMAND = [sys.executable, "-m", "build", "--wheel", "-o", OUTPUT_WHL]
19-
208
DEFAULT_COMMANDS = [""]
219

2210
PLAYGROUND_WHEELS = [
2311
"https://files.pythonhosted.org/packages/97/9c/372fef8377a6e340b1704768d20daaded98bf13282b5327beb2e2fe2c7ef/pygments-2.17.2-py3-none-any.whl",
24-
"https://files.pythonhosted.org/packages/d3/58/7d2dd906add6bd3481ee80beafb00af292866ed4ce3fa18cd168cb7bab74/bigtree-0.19.0-py3-none-any.whl",
2512
]
2613

2714
CONFIG = """\
@@ -33,102 +20,25 @@
3320
"""
3421

3522

36-
def build_package():
37-
"""Build wheel"""
38-
39-
if sys.platform.startswith("win"):
40-
startupinfo = subprocess.STARTUPINFO()
41-
startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
42-
process = subprocess.Popen(
43-
BUILD_WHL_COMMAND,
44-
stdout=subprocess.PIPE,
45-
startupinfo=startupinfo,
46-
shell=False,
47-
env=os.environ.copy(),
48-
)
49-
else:
50-
process = subprocess.Popen(
51-
BUILD_WHL_COMMAND,
52-
stdout=subprocess.PIPE,
53-
shell=False,
54-
env=os.environ.copy(),
55-
)
56-
out, _ = process.communicate()
57-
build_message = out.decode("utf-8")
58-
m = re.compile(BUILD_WHL_MESSAGE).search(build_message)
59-
print(build_message)
60-
61-
return process.returncode, m.group(1) if m else ""
62-
63-
64-
def download_wheel(url, dest):
65-
"""Download wheel"""
66-
67-
print("Downloading: {}".format(url))
68-
try:
69-
response = urllib.request.urlopen(url)
70-
status = response.status
71-
if status == 200:
72-
status = 0
73-
with open(dest, "wb") as f:
74-
print("Writing: {}".format(dest))
75-
f.write(response.read())
76-
except urllib.error.HTTPError as e:
77-
status = e.status
78-
79-
if status:
80-
print("Failed to download, received status code {}".format(status))
81-
82-
return status
83-
84-
8523
if __name__ == "__main__":
8624

87-
PLAYGROUND = {}
88-
for url in PLAYGROUND_WHEELS:
89-
PLAYGROUND[os.path.join(OUTPUT_WHL, url.split("/")[-1])] = url
90-
91-
# Clean up all old wheels and js file
92-
for file in glob.glob(OUTPUT_WHL + "*.whl"):
93-
if file not in PLAYGROUND.keys():
94-
os.remove(file)
95-
9625
if os.path.exists(OUTPUT_JS + "playground-config.js"):
9726
os.remove(OUTPUT_JS + "playground-config.js")
9827

99-
# Clean up build directory
100-
if os.path.exists("build"):
101-
shutil.rmtree("build")
102-
103-
if not os.path.exists("docs/wheels"):
104-
os.mkdir("docs/wheels")
105-
106-
# Build wheel
107-
status = 0
108-
# status, package = build_package()
109-
# if not status:
110-
# for file, url in PLAYGROUND.items():
111-
# if os.path.exists(file):
112-
# print("Skipping: {}".format(file))
113-
# continue
114-
# status = download_wheel(url, file)
115-
# if status:
116-
# break
117-
118-
if not status:
119-
# Build up a list of wheels needed for playgrounds and notebooks
120-
# playground = [
121-
# os.path.basename(file_path) for file_path in PLAYGROUND.keys()
122-
# ] + [package]
123-
124-
# Create the config that specifies which wheels need to be used
125-
config = (
126-
CONFIG.format(str(PLAYGROUND_WHEELS), "\n".join(DEFAULT_COMMANDS))
127-
.replace("\r", "")
128-
.encode("utf-8")
28+
# Scrape whl file
29+
response = requests.get("https://pypi.org/pypi/bigtree/json")
30+
PACKAGE_WHEEL = [
31+
url["url"] for url in response.json()["urls"] if url["url"].endswith("whl")
32+
]
33+
assert len(PACKAGE_WHEEL), "Cannot find package wheel"
34+
35+
# Create the config that specifies which wheels need to be used
36+
config = (
37+
CONFIG.format(
38+
str(PLAYGROUND_WHEELS + PACKAGE_WHEEL), "\n".join(DEFAULT_COMMANDS)
12939
)
130-
with open(OUTPUT_JS + "playground-config.js", "wb") as f:
131-
f.write(config)
132-
133-
print("FAILED :(" if status else "SUCCESS :)")
134-
sys.exit(status)
40+
.replace("\r", "")
41+
.encode("utf-8")
42+
)
43+
with open(OUTPUT_JS + "playground-config.js", "wb") as f:
44+
f.write(config)

docs/requirements.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
black>=24.1.0
2-
build
32
IPython
43
mdx_truly_sane_lists==1.3
54
mkdocs==1.5.3
@@ -9,4 +8,5 @@ mkdocstrings[python]==0.24.0
98
pandas
109
Pillow
1110
pydot
11+
requests
1212
termynal==0.11.1

0 commit comments

Comments
 (0)