Skip to content

Commit

Permalink
docs: Make reusable to fetch pypi packages
Browse files Browse the repository at this point in the history
  • Loading branch information
kayjan authored Jun 26, 2024
1 parent 44194f7 commit eff654f
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions docs/_static/playground_whl.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@

import requests

# Output files
# Parameters
OUTPUT_JS = "docs/_static/"

DEFAULT_COMMANDS = [""]

PLAYGROUND_WHEELS = [
"https://files.pythonhosted.org/packages/97/9c/372fef8377a6e340b1704768d20daaded98bf13282b5327beb2e2fe2c7ef/pygments-2.17.2-py3-none-any.whl",
]
PACKAGES = ["bigtree"]

DEFAULT_COMMANDS = [""]
CONFIG = """\
var colorNotebook = {{
"playgroundWheels": {},
Expand All @@ -26,16 +25,19 @@
os.remove(OUTPUT_JS + "playground-config.js")

# 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")
]
print(PACKAGE_WHEEL)
PACKAGE_WHEELS = []
for package in PACKAGES:
response = requests.get(f"https://pypi.org/pypi/{package}/json")
package_wheel = [
url["url"] for url in response.json()["urls"] if url["url"].endswith("whl")
]
PACKAGE_WHEELS.extend(package_wheel)
print(PACKAGE_WHEELS)

# Create the config that specifies which wheels need to be used
config = (
CONFIG.format(
str(PLAYGROUND_WHEELS + PACKAGE_WHEEL), "\n".join(DEFAULT_COMMANDS)
str(PLAYGROUND_WHEELS + PACKAGE_WHEELS), "\n".join(DEFAULT_COMMANDS)
)
.replace("\r", "")
.encode("utf-8")
Expand Down

0 comments on commit eff654f

Please sign in to comment.