diff --git a/.authors.yml b/.authors.yml index 4131c840..e685bb9a 100644 --- a/.authors.yml +++ b/.authors.yml @@ -61,7 +61,7 @@ github: dbast - name: Conda Bot email: 18747875+conda-bot@users.noreply.github.com - num_commits: 32 + num_commits: 39 first_commit: 2022-01-17 20:22:29 github: conda-bot aliases: @@ -86,7 +86,7 @@ first_commit: 2022-02-17 10:23:53 - name: Daniel Holth email: dholth@anaconda.com - num_commits: 26 + num_commits: 31 first_commit: 2021-08-20 21:11:50 github: dholth - name: Vadim Zayakin @@ -102,7 +102,7 @@ first_commit: 2022-02-09 01:00:38 - name: Jannis Leidel email: jannis@leidel.info - num_commits: 9 + num_commits: 10 first_commit: 2021-09-17 21:51:27 github: jezdez - name: Tobias "Tobi" Koch @@ -122,7 +122,7 @@ - name: pre-commit-ci[bot] email: 66853113+pre-commit-ci[bot]@users.noreply.github.com github: pre-commit-ci[bot] - num_commits: 14 + num_commits: 17 first_commit: 2023-01-20 04:55:56 - name: Justin Wood (Callek) email: callek@gmail.com @@ -131,6 +131,6 @@ github: callek - name: jaimergp email: jaimergp@users.noreply.github.com - num_commits: 2 + num_commits: 4 first_commit: 2024-04-02 13:11:21 github: jaimergp diff --git a/CHANGELOG.md b/CHANGELOG.md index 3d61fbe3..59303180 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,33 @@ [//]: # (current developments) +## 2.4.0 (2024-10-08) + +### Enhancements + +* Expose API and CLI for which components will be listed as part of `cph list`. (#253) +* Allow `cph list` on remote `.conda` artifact URLs. (#252 via #254) + +### Bug fixes + +* Use force_zip64=True when directly creating .conda files. Allows >2GB + (compressed) size. (#248) +* Replace `.conda` or `.tar.bz2` extensions from end of string only instead of + `str.replace(...)` (#251) + +### Other + +* Improve type annotations on an internal function (#257) + +### Contributors + +* @conda-bot +* @dholth +* @jezdez +* @jaimergp +* @pre-commit-ci[bot] + + + ## 2.3.0 (2024-06-05) ### Enhancements diff --git a/conda.recipe/meta.yaml b/conda.recipe/meta.yaml index 7595fedf..81abf065 100644 --- a/conda.recipe/meta.yaml +++ b/conda.recipe/meta.yaml @@ -38,7 +38,6 @@ test: - pytest - pytest-cov - pytest-mock - - pytest-xprocess imports: - conda_package_handling - conda_package_handling.api diff --git a/news/248-use-zip64 b/news/248-use-zip64 deleted file mode 100644 index 66e63a2e..00000000 --- a/news/248-use-zip64 +++ /dev/null @@ -1,20 +0,0 @@ -### Enhancements - -* - -### Bug fixes - -* Use force_zip64=True when directly creating .conda files. Allows >2GB - (compressed) size. (#248) - -### Deprecations - -* - -### Docs - -* - -### Other - -* diff --git a/news/251-extension-str-replace b/news/251-extension-str-replace deleted file mode 100644 index 294e4eb7..00000000 --- a/news/251-extension-str-replace +++ /dev/null @@ -1,20 +0,0 @@ -### Enhancements - -* - -### Bug fixes - -* Replace `.conda` or `.tar.bz2` extensions from end of string only instead of - `str.replace(...)` (#251) - -### Deprecations - -* - -### Docs - -* - -### Other - -* diff --git a/news/253-components-list b/news/253-components-list deleted file mode 100644 index e1ea0fd4..00000000 --- a/news/253-components-list +++ /dev/null @@ -1,19 +0,0 @@ -### Enhancements - -* Expose API and CLI for which components will be listed as part of `cph list`. (#253) - -### Bug fixes - -* - -### Deprecations - -* - -### Docs - -* - -### Other - -* diff --git a/news/254-list-remote b/news/254-list-remote deleted file mode 100644 index 9bd69fb1..00000000 --- a/news/254-list-remote +++ /dev/null @@ -1,19 +0,0 @@ -### Enhancements - -* Allow `cph list` on remote `.conda` artifact URLs. (#252 via #254) - -### Bug fixes - -* - -### Deprecations - -* - -### Docs - -* - -### Other - -* diff --git a/news/improve-typing b/news/improve-typing deleted file mode 100644 index 0e177fed..00000000 --- a/news/improve-typing +++ /dev/null @@ -1,19 +0,0 @@ -### Enhancements - -* - -### Bug fixes - -* - -### Deprecations - -* - -### Docs - -* - -### Other - -* Improve type annotations on an internal function (#257) diff --git a/setup.py b/setup.py index 97c82f47..a9a71eeb 100644 --- a/setup.py +++ b/setup.py @@ -34,6 +34,12 @@ "myst-parser", "mdit-py-plugins>=0.3.0", ], - "test": ["mock", "pytest", "pytest-cov", "pytest-mock", "pytest-xprocess", "bottle"], + "test": [ + "mock", + "pytest", + "pytest-cov", + "pytest-mock", + "bottle", + ], }, ) diff --git a/src/conda_package_handling/__init__.py b/src/conda_package_handling/__init__.py index 55e47090..3d67cd6b 100644 --- a/src/conda_package_handling/__init__.py +++ b/src/conda_package_handling/__init__.py @@ -1 +1 @@ -__version__ = "2.3.0" +__version__ = "2.4.0" diff --git a/src/conda_package_handling/conda_fmt.py b/src/conda_package_handling/conda_fmt.py index 5342d622..c6c45cd3 100644 --- a/src/conda_package_handling/conda_fmt.py +++ b/src/conda_package_handling/conda_fmt.py @@ -113,9 +113,12 @@ def tell(self): pkg_metadata = {"conda_pkg_format_version": CONDA_PACKAGE_FORMAT_VERSION} conda_file.writestr("metadata.json", json.dumps(pkg_metadata)) - components_files = (f"pkg-{file_id}.tar.zst", pkg_files), ( - f"info-{file_id}.tar.zst", - info_files, + components_files = ( + (f"pkg-{file_id}.tar.zst", pkg_files), + ( + f"info-{file_id}.tar.zst", + info_files, + ), ) # put the info last, for parity with updated transmute. diff --git a/tests/conftest.py b/tests/conftest.py index a4f2baf7..5ba5f85e 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,11 +1,18 @@ +from __future__ import annotations + import os import shutil -import sys +import threading +import typing +import wsgiref.simple_server from pathlib import Path -from textwrap import dedent +from typing import Any +import bottle import pytest -from xprocess import ProcessStarter + +if typing.TYPE_CHECKING: + import wsgiref.types # added in 3.11 @pytest.fixture(scope="function") @@ -36,40 +43,45 @@ def return_to_saved_path(): return str(tmpdir) +datadir = Path(__file__).parent / "data" + + +@bottle.route("/", "GET") +def serve_file(filename): + mimetype = "auto" + # from https://repo.anaconda.com/ behavior: + if filename.endswith(".tar.bz2"): + mimetype = "application/x-tar" + elif filename.endswith(".conda"): + mimetype = "binary/octet-stream" + return bottle.static_file(filename, root=datadir.as_posix(), mimetype=mimetype) + + +class ServerThread(threading.Thread): + server: Any + app: Any + + +def get_server_thread(): + """ + Return test server thread with additional .server, .app properties. + + Call .start() to serve in the background. + """ + app: wsgiref.types.WSGIApplication = bottle.app() + server = wsgiref.simple_server.make_server("127.0.0.1", 0, app) + t = ServerThread(daemon=True, target=server.serve_forever) + t.app = app + t.server = server # server.application == app + return t + + @pytest.fixture(scope="session") -def localserver(xprocess): - port = 8000 - datadir = Path(__file__).parent / "data" - - class Starter(ProcessStarter): - pattern = "Hit Ctrl-C to quit." - terminate_on_interrupt = True - timeout = 10 - args = [ - sys.executable, - "-u", # unbuffered - "-c", - # Adapted from conda-package-streaming/tests/server.py - dedent( - f""" - from bottle import route, run, static_file - - @route("/", "GET") - def serve_file(filename): - mimetype = "auto" - # from https://repo.anaconda.com/ behavior: - if filename.endswith(".tar.bz2"): - mimetype = "application/x-tar" - elif filename.endswith(".conda"): - mimetype = "binary/octet-stream" - return static_file(filename, root="{datadir.as_posix()}", mimetype=mimetype) - - run(port={port}) - """ - ), - ] - - pid, logfile = xprocess.ensure("bottle.server", Starter) - print("Logfile at", str(logfile)) - yield f"http://localhost:{port}" - xprocess.getinfo("bottle.server").terminate() +def localserver(): + thread = get_server_thread() + thread.start() + yield f"http://{thread.server.server_address[0]}:{thread.server.server_address[1]}" + + +if __name__ == "__main__": + bottle.run(port=8080) diff --git a/tests/test_interface.py b/tests/test_interface.py index a872f571..24b8fef2 100644 --- a/tests/test_interface.py +++ b/tests/test_interface.py @@ -48,5 +48,9 @@ def test_extract_create(tmpdir): with pytest.raises(ValueError): CondaFormat_v2.create( - "", [], "", compressor=True, compression_tuple=("1", "2", "3") # type: ignore + "", + [], + "", + compressor=True, + compression_tuple=("1", "2", "3"), # type: ignore )