From 3dca4f2a21066177e763c0e048ce7584139216ad Mon Sep 17 00:00:00 2001 From: Kay Date: Wed, 26 Jun 2024 02:53:07 +0800 Subject: [PATCH] bump: v0.19.1 + dynamically fetch latest whl file --- CHANGELOG.md | 7 +- bigtree/__init__.py | 2 +- docs/_static/playground_whl.py | 126 +++++---------------------------- docs/requirements.txt | 2 +- 4 files changed, 25 insertions(+), 112 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1ec650e8..9bdba6b1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,8 +5,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [Unreleased] + +## [0.19.1] - 2024-06-26 ### Changed: -- Docs: Add glossary section to documentation. +- Docs: Add playground and glossary section to documentation. ## [0.19.0] - 2024-06-15 ### Changed: @@ -599,7 +601,8 @@ ignore null attribute columns. - Utility Iterator: Tree traversal methods. - Workflow To Do App: Tree use case with to-do list implementation. -[Unreleased]: https://github.com/kayjan/bigtree/compare/0.19.0...HEAD +[Unreleased]: https://github.com/kayjan/bigtree/compare/0.19.1...HEAD +[0.19.1]: https://github.com/kayjan/bigtree/compare/0.19.0...0.19.1 [0.19.0]: https://github.com/kayjan/bigtree/compare/0.18.3...0.19.0 [0.18.3]: https://github.com/kayjan/bigtree/compare/0.18.2...0.18.3 [0.18.2]: https://github.com/kayjan/bigtree/compare/0.18.1...0.18.2 diff --git a/bigtree/__init__.py b/bigtree/__init__.py index e7c04a3d..97699214 100644 --- a/bigtree/__init__.py +++ b/bigtree/__init__.py @@ -1,4 +1,4 @@ -__version__ = "0.19.0" +__version__ = "0.19.1" from bigtree.binarytree.construct import list_to_binarytree from bigtree.dag.construct import dataframe_to_dag, dict_to_dag, list_to_dag diff --git a/docs/_static/playground_whl.py b/docs/_static/playground_whl.py index 33f47586..d930c97f 100644 --- a/docs/_static/playground_whl.py +++ b/docs/_static/playground_whl.py @@ -1,27 +1,14 @@ -import glob import os -import re -import shutil -import subprocess -import sys -import urllib.error -import urllib.request + +import requests # Output files -OUTPUT_WHL = "docs/wheels/" OUTPUT_JS = "docs/_static/" -# Build message output -# BUILD_WHL_MESSAGE = f"{OUTPUT_WHL}(.*whl)" -# BUILD_WHL_COMMAND = [sys.executable, "-m", "hatch", "build", OUTPUT_WHL] -BUILD_WHL_MESSAGE = r"Successfully built ([-_0-9.a-zA-Z]+?\.whl)" -BUILD_WHL_COMMAND = [sys.executable, "-m", "build", "--wheel", "-o", OUTPUT_WHL] - DEFAULT_COMMANDS = [""] PLAYGROUND_WHEELS = [ "https://files.pythonhosted.org/packages/97/9c/372fef8377a6e340b1704768d20daaded98bf13282b5327beb2e2fe2c7ef/pygments-2.17.2-py3-none-any.whl", - "https://files.pythonhosted.org/packages/d3/58/7d2dd906add6bd3481ee80beafb00af292866ed4ce3fa18cd168cb7bab74/bigtree-0.19.0-py3-none-any.whl", ] CONFIG = """\ @@ -33,102 +20,25 @@ """ -def build_package(): - """Build wheel""" - - if sys.platform.startswith("win"): - startupinfo = subprocess.STARTUPINFO() - startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW - process = subprocess.Popen( - BUILD_WHL_COMMAND, - stdout=subprocess.PIPE, - startupinfo=startupinfo, - shell=False, - env=os.environ.copy(), - ) - else: - process = subprocess.Popen( - BUILD_WHL_COMMAND, - stdout=subprocess.PIPE, - shell=False, - env=os.environ.copy(), - ) - out, _ = process.communicate() - build_message = out.decode("utf-8") - m = re.compile(BUILD_WHL_MESSAGE).search(build_message) - print(build_message) - - return process.returncode, m.group(1) if m else "" - - -def download_wheel(url, dest): - """Download wheel""" - - print("Downloading: {}".format(url)) - try: - response = urllib.request.urlopen(url) - status = response.status - if status == 200: - status = 0 - with open(dest, "wb") as f: - print("Writing: {}".format(dest)) - f.write(response.read()) - except urllib.error.HTTPError as e: - status = e.status - - if status: - print("Failed to download, received status code {}".format(status)) - - return status - - if __name__ == "__main__": - PLAYGROUND = {} - for url in PLAYGROUND_WHEELS: - PLAYGROUND[os.path.join(OUTPUT_WHL, url.split("/")[-1])] = url - - # Clean up all old wheels and js file - for file in glob.glob(OUTPUT_WHL + "*.whl"): - if file not in PLAYGROUND.keys(): - os.remove(file) - if os.path.exists(OUTPUT_JS + "playground-config.js"): os.remove(OUTPUT_JS + "playground-config.js") - # Clean up build directory - if os.path.exists("build"): - shutil.rmtree("build") - - if not os.path.exists("docs/wheels"): - os.mkdir("docs/wheels") - - # Build wheel - status = 0 - # status, package = build_package() - # if not status: - # for file, url in PLAYGROUND.items(): - # if os.path.exists(file): - # print("Skipping: {}".format(file)) - # continue - # status = download_wheel(url, file) - # if status: - # break - - if not status: - # Build up a list of wheels needed for playgrounds and notebooks - # playground = [ - # os.path.basename(file_path) for file_path in PLAYGROUND.keys() - # ] + [package] - - # Create the config that specifies which wheels need to be used - config = ( - CONFIG.format(str(PLAYGROUND_WHEELS), "\n".join(DEFAULT_COMMANDS)) - .replace("\r", "") - .encode("utf-8") + # Scrape whl file + response = requests.get("https://pypi.org/pypi/bigtree/json") + PACKAGE_WHEEL = [ + url["url"] for url in response.json()["urls"] if url["url"].endswith("whl") + ] + assert len(PACKAGE_WHEEL), "Cannot find package wheel" + + # Create the config that specifies which wheels need to be used + config = ( + CONFIG.format( + str(PLAYGROUND_WHEELS + PACKAGE_WHEEL), "\n".join(DEFAULT_COMMANDS) ) - with open(OUTPUT_JS + "playground-config.js", "wb") as f: - f.write(config) - - print("FAILED :(" if status else "SUCCESS :)") - sys.exit(status) + .replace("\r", "") + .encode("utf-8") + ) + with open(OUTPUT_JS + "playground-config.js", "wb") as f: + f.write(config) diff --git a/docs/requirements.txt b/docs/requirements.txt index 87abfe64..40d47fca 100644 --- a/docs/requirements.txt +++ b/docs/requirements.txt @@ -1,5 +1,4 @@ black>=24.1.0 -build IPython mdx_truly_sane_lists==1.3 mkdocs==1.5.3 @@ -9,4 +8,5 @@ mkdocstrings[python]==0.24.0 pandas Pillow pydot +requests termynal==0.11.1