diff --git a/CHANGELOG.md b/CHANGELOG.md index cab7c544a..21667ece1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,13 @@ 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). +## [0.6.1.1] - 2023-12-22 + +### Bug fixes + +* Fixed #935: `shiny create` required the `requests` package, but it was not listed as a dependency. It now uses `urllib` instead, which is part of the Python standard library. (#940) + + ## [0.6.1] - 2023-12-18 ### New features diff --git a/shiny/_template_utils.py b/shiny/_template_utils.py index dd9d54072..e2fb4e9b4 100644 --- a/shiny/_template_utils.py +++ b/shiny/_template_utils.py @@ -1,14 +1,17 @@ +from __future__ import annotations + import os import shutil import sys import tempfile import zipfile from pathlib import Path -from typing import Dict, List, Optional +from typing import Optional, cast +from urllib.error import URLError from urllib.parse import urlparse +from urllib.request import urlopen import questionary -import requests from questionary import Choice from ._custom_component_template_questions import ( @@ -33,7 +36,7 @@ back_choice: Choice = Choice(title=[("class:secondary", "← Back")], value="back") -def choice_from_dict(choice_dict: Dict[str, str]) -> List[Choice]: +def choice_from_dict(choice_dict: dict[str, str]) -> list[Choice]: return [Choice(title=key, value=value) for key, value in choice_dict.items()] @@ -75,10 +78,16 @@ def template_query(question_state: Optional[str] = None, mode: Optional[str] = N def download_and_extract_zip(url: str, temp_dir: Path): - response = requests.get(url) - response.raise_for_status() + try: + response = urlopen(url) + data = cast(bytes, response.read()) + except URLError as e: + # Note that HTTPError is a subclass of URLError + e.msg += f" for url: {url}" # pyright: ignore + raise e + zip_file_path = temp_dir / "repo.zip" - zip_file_path.write_bytes(response.content) + zip_file_path.write_bytes(data) with zipfile.ZipFile(zip_file_path, "r") as zip_file: zip_file.extractall(temp_dir)