From 54529bff6b75f847b96055d4d4e4983c2aa41e30 Mon Sep 17 00:00:00 2001 From: Carson Date: Wed, 18 Jan 2023 14:33:52 -0600 Subject: [PATCH 1/6] Run tests on Windows --- .github/workflows/pytest.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/pytest.yaml b/.github/workflows/pytest.yaml index d23cb97..f26a22d 100644 --- a/.github/workflows/pytest.yaml +++ b/.github/workflows/pytest.yaml @@ -10,10 +10,11 @@ on: jobs: build: - runs-on: ubuntu-latest + runs-on: ${{ matrix.os }} strategy: matrix: python-version: [3.7, 3.8, 3.9, "3.10", "3.11"] + os: [ubuntu-latest, windows-latest] fail-fast: false steps: From f36052f3dd9ba819c10da9d8816bacf49f231eee Mon Sep 17 00:00:00 2001 From: Carson Date: Wed, 18 Jan 2023 14:38:38 -0600 Subject: [PATCH 2/6] Change default shell to bash --- .github/workflows/pytest.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/pytest.yaml b/.github/workflows/pytest.yaml index f26a22d..e18d9d6 100644 --- a/.github/workflows/pytest.yaml +++ b/.github/workflows/pytest.yaml @@ -16,6 +16,9 @@ jobs: python-version: [3.7, 3.8, 3.9, "3.10", "3.11"] os: [ubuntu-latest, windows-latest] fail-fast: false + defaults: + run: + shell: bash steps: - uses: actions/checkout@v2 From 1cb1ae7803c906dc841426b1ef084d428eb8c054 Mon Sep 17 00:00:00 2001 From: Carson Date: Wed, 18 Jan 2023 14:41:48 -0600 Subject: [PATCH 3/6] Hard code forward slash --- htmltools/_core.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htmltools/_core.py b/htmltools/_core.py index 3182ba1..3fc4116 100644 --- a/htmltools/_core.py +++ b/htmltools/_core.py @@ -1091,7 +1091,7 @@ def source_path_map( href = self.name if include_version: href += "-" + str(self.version) - href = os.path.join(lib_prefix, href) if lib_prefix else href + href = lib_prefix + "/" + href if lib_prefix else href return {"source": source, "href": href} def as_html_tags( From 6f155c49b4e50228b1bb27c98d25a6ffab2bed5b Mon Sep 17 00:00:00 2001 From: Carson Date: Wed, 18 Jan 2023 14:44:19 -0600 Subject: [PATCH 4/6] Hard code forward slash --- htmltools/_core.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htmltools/_core.py b/htmltools/_core.py index 3fc4116..3b4ce1e 100644 --- a/htmltools/_core.py +++ b/htmltools/_core.py @@ -1122,7 +1122,7 @@ def as_dict( href = urllib.parse.quote(s["href"]) s.update( { - "href": os.path.join(paths["href"], href), + "href": paths["href"] + "/" + href, "rel": "stylesheet", } ) @@ -1130,7 +1130,7 @@ def as_dict( scripts = deepcopy(self.script) for s in scripts: src = urllib.parse.quote(s["src"]) - s.update({"src": os.path.join(paths["href"], src)}) + s.update({"src": paths["href"] + "/" + src}) head: Optional[str] if self.head is None: From 2c5476fd9994de5ccc1f5bb57ede5988aae3a6ed Mon Sep 17 00:00:00 2001 From: Carson Date: Wed, 18 Jan 2023 14:50:34 -0600 Subject: [PATCH 5/6] Run tests on MacOS --- .github/workflows/pytest.yaml | 2 +- htmltools/_core.py | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pytest.yaml b/.github/workflows/pytest.yaml index e18d9d6..ccb7e84 100644 --- a/.github/workflows/pytest.yaml +++ b/.github/workflows/pytest.yaml @@ -14,7 +14,7 @@ jobs: strategy: matrix: python-version: [3.7, 3.8, 3.9, "3.10", "3.11"] - os: [ubuntu-latest, windows-latest] + os: [ubuntu-latest, windows-latest, macOS-latest] fail-fast: false defaults: run: diff --git a/htmltools/_core.py b/htmltools/_core.py index 3b4ce1e..f9b3924 100644 --- a/htmltools/_core.py +++ b/htmltools/_core.py @@ -1091,7 +1091,8 @@ def source_path_map( href = self.name if include_version: href += "-" + str(self.version) - href = lib_prefix + "/" + href if lib_prefix else href + if lib_prefix: + href = lib_prefix + "/" + href return {"source": source, "href": href} def as_html_tags( From 54eb951213f4b6762bd85aa2013093859087a871 Mon Sep 17 00:00:00 2001 From: Carson Date: Thu, 19 Jan 2023 10:02:56 -0600 Subject: [PATCH 6/6] Use posixpath module --- htmltools/_core.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/htmltools/_core.py b/htmltools/_core.py index f9b3924..9f52165 100644 --- a/htmltools/_core.py +++ b/htmltools/_core.py @@ -1,5 +1,6 @@ # pyright: reportMissingTypeStubs=false import os +import posixpath import shutil import sys import tempfile @@ -1092,7 +1093,7 @@ def source_path_map( if include_version: href += "-" + str(self.version) if lib_prefix: - href = lib_prefix + "/" + href + href = posixpath.join(lib_prefix, href) return {"source": source, "href": href} def as_html_tags( @@ -1123,7 +1124,7 @@ def as_dict( href = urllib.parse.quote(s["href"]) s.update( { - "href": paths["href"] + "/" + href, + "href": posixpath.join(paths["href"], href), "rel": "stylesheet", } ) @@ -1131,7 +1132,7 @@ def as_dict( scripts = deepcopy(self.script) for s in scripts: src = urllib.parse.quote(s["src"]) - s.update({"src": paths["href"] + "/" + src}) + s.update({"src": posixpath.join(paths["href"], src)}) head: Optional[str] if self.head is None: