diff --git a/.github/workflows/qret-ci.yml b/.github/workflows/release.yml similarity index 96% rename from .github/workflows/qret-ci.yml rename to .github/workflows/release.yml index e34c565..d095ec6 100644 --- a/.github/workflows/qret-ci.yml +++ b/.github/workflows/release.yml @@ -2,7 +2,13 @@ name: qret-ci on: push: + paths: + - .github/workflows/release.yml + - quration pull_request: + paths: + - .github/workflows/release.yml + - quration release: types: [published] diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..800738e --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,65 @@ +name: test + +on: + push: + paths: + - src/** + - tests/** + - pyproject.toml + - .github/workflows/test.yml + pull_request: + paths: + - src/** + - tests/** + - pyproject.toml + - .github/workflows/test.yml + +jobs: + pytest: + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: + - macos-latest + - macos-15-intel + - ubuntu-latest + - windows-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup Python + uses: actions/setup-python@v5 + with: + python-version: "3.11" + + - name: Install package and test deps + run: | + python -m pip install --upgrade pip + python -m pip install -e ".[test]" + + - name: Prepare qret stub for test (Unix) + if: runner.os != 'Windows' + run: | + mkdir -p .ci-bin + cat > .ci-bin/qret <<'EOF' + #!/usr/bin/env sh + echo "qret 0.0.0-ci" + EOF + chmod +x .ci-bin/qret + echo "$GITHUB_WORKSPACE/.ci-bin" >> "$GITHUB_PATH" + + - name: Prepare qret stub for test (Windows) + if: runner.os == 'Windows' + shell: pwsh + run: | + New-Item -ItemType Directory -Force -Path .ci-bin | Out-Null + @' + @echo off + echo qret 0.0.0-ci + '@ | Set-Content -Path .ci-bin/qret.cmd + "$env:GITHUB_WORKSPACE/.ci-bin" | Out-File -FilePath $env:GITHUB_PATH -Append + + - name: Run pytest + run: pytest -q tests/test_qret_cli_bundle.py diff --git a/README.md b/README.md index 7cfe27f..b714c67 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,7 @@ # qret-cli-bundle -This package downloads a platform-specific `qret` CLI archive from GitHub Releases and prepends its directory to `PATH` when imported. +This package downloads a platform-specific `qret` CLI archive from GitHub Releases and appends its directory to `PATH` when imported. ```python import qret_cli_bundle ``` - -Environment variables: - -- `QRET_BUNDLE_REPOSITORY` (default: `QunaSys/quration-cli-bundle`) -- `QRET_BUNDLE_TAG` (default: latest release) diff --git a/poetry.lock b/poetry.lock new file mode 100644 index 0000000..3fe4bfd --- /dev/null +++ b/poetry.lock @@ -0,0 +1,196 @@ +# This file is automatically @generated by Poetry 2.3.2 and should not be changed by hand. + +[[package]] +name = "colorama" +version = "0.4.6" +description = "Cross-platform colored terminal text." +optional = false +python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,!=3.6.*,>=2.7" +groups = ["main", "dev"] +files = [ + {file = "colorama-0.4.6-py2.py3-none-any.whl", hash = "sha256:4f1d9991f5acc0ca119f9d443620b77f9d6b33703e51011c16baf57afb285fc6"}, + {file = "colorama-0.4.6.tar.gz", hash = "sha256:08695f5cb7ed6e0531a20572697297273c47b8cae5a63ffc6d6ed5c201be6e44"}, +] +markers = {main = "extra == \"test\" and sys_platform == \"win32\"", dev = "sys_platform == \"win32\""} + +[[package]] +name = "exceptiongroup" +version = "1.3.1" +description = "Backport of PEP 654 (exception groups)" +optional = false +python-versions = ">=3.7" +groups = ["main", "dev"] +files = [ + {file = "exceptiongroup-1.3.1-py3-none-any.whl", hash = "sha256:a7a39a3bd276781e98394987d3a5701d0c4edffb633bb7a5144577f82c773598"}, + {file = "exceptiongroup-1.3.1.tar.gz", hash = "sha256:8b412432c6055b0b7d14c310000ae93352ed6754f70fa8f7c34141f91c4e3219"}, +] +markers = {main = "extra == \"test\" and python_version < \"3.11\"", dev = "python_version < \"3.11\""} + +[package.dependencies] +typing-extensions = {version = ">=4.6.0", markers = "python_version < \"3.13\""} + +[package.extras] +test = ["pytest (>=6)"] + +[[package]] +name = "iniconfig" +version = "2.1.0" +description = "brain-dead simple config-ini parsing" +optional = false +python-versions = ">=3.8" +groups = ["main", "dev"] +files = [ + {file = "iniconfig-2.1.0-py3-none-any.whl", hash = "sha256:9deba5723312380e77435581c6bf4935c94cbfab9b1ed33ef8d238ea168eb760"}, + {file = "iniconfig-2.1.0.tar.gz", hash = "sha256:3abbd2e30b36733fee78f9c7f7308f2d0050e88f0087fd25c2645f63c773e1c7"}, +] +markers = {main = "extra == \"test\""} + +[[package]] +name = "packaging" +version = "26.0" +description = "Core utilities for Python packages" +optional = false +python-versions = ">=3.8" +groups = ["main", "dev"] +files = [ + {file = "packaging-26.0-py3-none-any.whl", hash = "sha256:b36f1fef9334a5588b4166f8bcd26a14e521f2b55e6b9de3aaa80d3ff7a37529"}, + {file = "packaging-26.0.tar.gz", hash = "sha256:00243ae351a257117b6a241061796684b084ed1c516a08c48a3f7e147a9d80b4"}, +] +markers = {main = "extra == \"test\""} + +[[package]] +name = "pluggy" +version = "1.6.0" +description = "plugin and hook calling mechanisms for python" +optional = false +python-versions = ">=3.9" +groups = ["main", "dev"] +files = [ + {file = "pluggy-1.6.0-py3-none-any.whl", hash = "sha256:e920276dd6813095e9377c0bc5566d94c932c33b27a3e3945d8389c374dd4746"}, + {file = "pluggy-1.6.0.tar.gz", hash = "sha256:7dcc130b76258d33b90f61b658791dede3486c3e6bfb003ee5c9bfb396dd22f3"}, +] +markers = {main = "extra == \"test\""} + +[package.extras] +dev = ["pre-commit", "tox"] +testing = ["coverage", "pytest", "pytest-benchmark"] + +[[package]] +name = "pygments" +version = "2.19.2" +description = "Pygments is a syntax highlighting package written in Python." +optional = false +python-versions = ">=3.8" +groups = ["main", "dev"] +files = [ + {file = "pygments-2.19.2-py3-none-any.whl", hash = "sha256:86540386c03d588bb81d44bc3928634ff26449851e99741617ecb9037ee5ec0b"}, + {file = "pygments-2.19.2.tar.gz", hash = "sha256:636cb2477cec7f8952536970bc533bc43743542f70392ae026374600add5b887"}, +] +markers = {main = "extra == \"test\""} + +[package.extras] +windows-terminal = ["colorama (>=0.4.6)"] + +[[package]] +name = "pytest" +version = "8.4.2" +description = "pytest: simple powerful testing with Python" +optional = false +python-versions = ">=3.9" +groups = ["main", "dev"] +files = [ + {file = "pytest-8.4.2-py3-none-any.whl", hash = "sha256:872f880de3fc3a5bdc88a11b39c9710c3497a547cfa9320bc3c5e62fbf272e79"}, + {file = "pytest-8.4.2.tar.gz", hash = "sha256:86c0d0b93306b961d58d62a4db4879f27fe25513d4b969df351abdddb3c30e01"}, +] +markers = {main = "extra == \"test\""} + +[package.dependencies] +colorama = {version = ">=0.4", markers = "sys_platform == \"win32\""} +exceptiongroup = {version = ">=1", markers = "python_version < \"3.11\""} +iniconfig = ">=1" +packaging = ">=20" +pluggy = ">=1.5,<2" +pygments = ">=2.7.2" +tomli = {version = ">=1", markers = "python_version < \"3.11\""} + +[package.extras] +dev = ["argcomplete", "attrs (>=19.2)", "hypothesis (>=3.56)", "mock", "requests", "setuptools", "xmlschema"] + +[[package]] +name = "tomli" +version = "2.4.0" +description = "A lil' TOML parser" +optional = false +python-versions = ">=3.8" +groups = ["main", "dev"] +files = [ + {file = "tomli-2.4.0-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:b5ef256a3fd497d4973c11bf142e9ed78b150d36f5773f1ca6088c230ffc5867"}, + {file = "tomli-2.4.0-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:5572e41282d5268eb09a697c89a7bee84fae66511f87533a6f88bd2f7b652da9"}, + {file = "tomli-2.4.0-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:551e321c6ba03b55676970b47cb1b73f14a0a4dce6a3e1a9458fd6d921d72e95"}, + {file = "tomli-2.4.0-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:5e3f639a7a8f10069d0e15408c0b96a2a828cfdec6fca05296ebcdcc28ca7c76"}, + {file = "tomli-2.4.0-cp311-cp311-musllinux_1_2_aarch64.whl", hash = "sha256:1b168f2731796b045128c45982d3a4874057626da0e2ef1fdd722848b741361d"}, + {file = "tomli-2.4.0-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:133e93646ec4300d651839d382d63edff11d8978be23da4cc106f5a18b7d0576"}, + {file = "tomli-2.4.0-cp311-cp311-win32.whl", hash = "sha256:b6c78bdf37764092d369722d9946cb65b8767bfa4110f902a1b2542d8d173c8a"}, + {file = "tomli-2.4.0-cp311-cp311-win_amd64.whl", hash = "sha256:d3d1654e11d724760cdb37a3d7691f0be9db5fbdaef59c9f532aabf87006dbaa"}, + {file = "tomli-2.4.0-cp311-cp311-win_arm64.whl", hash = "sha256:cae9c19ed12d4e8f3ebf46d1a75090e4c0dc16271c5bce1c833ac168f08fb614"}, + {file = "tomli-2.4.0-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:920b1de295e72887bafa3ad9f7a792f811847d57ea6b1215154030cf131f16b1"}, + {file = "tomli-2.4.0-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:7d6d9a4aee98fac3eab4952ad1d73aee87359452d1c086b5ceb43ed02ddb16b8"}, + {file = "tomli-2.4.0-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:36b9d05b51e65b254ea6c2585b59d2c4cb91c8a3d91d0ed0f17591a29aaea54a"}, + {file = "tomli-2.4.0-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:1c8a885b370751837c029ef9bc014f27d80840e48bac415f3412e6593bbc18c1"}, + {file = "tomli-2.4.0-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:8768715ffc41f0008abe25d808c20c3d990f42b6e2e58305d5da280ae7d1fa3b"}, + {file = "tomli-2.4.0-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:7b438885858efd5be02a9a133caf5812b8776ee0c969fea02c45e8e3f296ba51"}, + {file = "tomli-2.4.0-cp312-cp312-win32.whl", hash = "sha256:0408e3de5ec77cc7f81960c362543cbbd91ef883e3138e81b729fc3eea5b9729"}, + {file = "tomli-2.4.0-cp312-cp312-win_amd64.whl", hash = "sha256:685306e2cc7da35be4ee914fd34ab801a6acacb061b6a7abca922aaf9ad368da"}, + {file = "tomli-2.4.0-cp312-cp312-win_arm64.whl", hash = "sha256:5aa48d7c2356055feef06a43611fc401a07337d5b006be13a30f6c58f869e3c3"}, + {file = "tomli-2.4.0-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:84d081fbc252d1b6a982e1870660e7330fb8f90f676f6e78b052ad4e64714bf0"}, + {file = "tomli-2.4.0-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:9a08144fa4cba33db5255f9b74f0b89888622109bd2776148f2597447f92a94e"}, + {file = "tomli-2.4.0-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:c73add4bb52a206fd0c0723432db123c0c75c280cbd67174dd9d2db228ebb1b4"}, + {file = "tomli-2.4.0-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:1fb2945cbe303b1419e2706e711b7113da57b7db31ee378d08712d678a34e51e"}, + {file = "tomli-2.4.0-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:bbb1b10aa643d973366dc2cb1ad94f99c1726a02343d43cbc011edbfac579e7c"}, + {file = "tomli-2.4.0-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:4cbcb367d44a1f0c2be408758b43e1ffb5308abe0ea222897d6bfc8e8281ef2f"}, + {file = "tomli-2.4.0-cp313-cp313-win32.whl", hash = "sha256:7d49c66a7d5e56ac959cb6fc583aff0651094ec071ba9ad43df785abc2320d86"}, + {file = "tomli-2.4.0-cp313-cp313-win_amd64.whl", hash = "sha256:3cf226acb51d8f1c394c1b310e0e0e61fecdd7adcb78d01e294ac297dd2e7f87"}, + {file = "tomli-2.4.0-cp313-cp313-win_arm64.whl", hash = "sha256:d20b797a5c1ad80c516e41bc1fb0443ddb5006e9aaa7bda2d71978346aeb9132"}, + {file = "tomli-2.4.0-cp314-cp314-macosx_10_15_x86_64.whl", hash = "sha256:26ab906a1eb794cd4e103691daa23d95c6919cc2fa9160000ac02370cc9dd3f6"}, + {file = "tomli-2.4.0-cp314-cp314-macosx_11_0_arm64.whl", hash = "sha256:20cedb4ee43278bc4f2fee6cb50daec836959aadaf948db5172e776dd3d993fc"}, + {file = "tomli-2.4.0-cp314-cp314-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:39b0b5d1b6dd03684b3fb276407ebed7090bbec989fa55838c98560c01113b66"}, + {file = "tomli-2.4.0-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:a26d7ff68dfdb9f87a016ecfd1e1c2bacbe3108f4e0f8bcd2228ef9a766c787d"}, + {file = "tomli-2.4.0-cp314-cp314-musllinux_1_2_aarch64.whl", hash = "sha256:20ffd184fb1df76a66e34bd1b36b4a4641bd2b82954befa32fe8163e79f1a702"}, + {file = "tomli-2.4.0-cp314-cp314-musllinux_1_2_x86_64.whl", hash = "sha256:75c2f8bbddf170e8effc98f5e9084a8751f8174ea6ccf4fca5398436e0320bc8"}, + {file = "tomli-2.4.0-cp314-cp314-win32.whl", hash = "sha256:31d556d079d72db7c584c0627ff3a24c5d3fb4f730221d3444f3efb1b2514776"}, + {file = "tomli-2.4.0-cp314-cp314-win_amd64.whl", hash = "sha256:43e685b9b2341681907759cf3a04e14d7104b3580f808cfde1dfdb60ada85475"}, + {file = "tomli-2.4.0-cp314-cp314-win_arm64.whl", hash = "sha256:3d895d56bd3f82ddd6faaff993c275efc2ff38e52322ea264122d72729dca2b2"}, + {file = "tomli-2.4.0-cp314-cp314t-macosx_10_15_x86_64.whl", hash = "sha256:5b5807f3999fb66776dbce568cc9a828544244a8eb84b84b9bafc080c99597b9"}, + {file = "tomli-2.4.0-cp314-cp314t-macosx_11_0_arm64.whl", hash = "sha256:c084ad935abe686bd9c898e62a02a19abfc9760b5a79bc29644463eaf2840cb0"}, + {file = "tomli-2.4.0-cp314-cp314t-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:0f2e3955efea4d1cfbcb87bc321e00dc08d2bcb737fd1d5e398af111d86db5df"}, + {file = "tomli-2.4.0-cp314-cp314t-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:0e0fe8a0b8312acf3a88077a0802565cb09ee34107813bba1c7cd591fa6cfc8d"}, + {file = "tomli-2.4.0-cp314-cp314t-musllinux_1_2_aarch64.whl", hash = "sha256:413540dce94673591859c4c6f794dfeaa845e98bf35d72ed59636f869ef9f86f"}, + {file = "tomli-2.4.0-cp314-cp314t-musllinux_1_2_x86_64.whl", hash = "sha256:0dc56fef0e2c1c470aeac5b6ca8cc7b640bb93e92d9803ddaf9ea03e198f5b0b"}, + {file = "tomli-2.4.0-cp314-cp314t-win32.whl", hash = "sha256:d878f2a6707cc9d53a1be1414bbb419e629c3d6e67f69230217bb663e76b5087"}, + {file = "tomli-2.4.0-cp314-cp314t-win_amd64.whl", hash = "sha256:2add28aacc7425117ff6364fe9e06a183bb0251b03f986df0e78e974047571fd"}, + {file = "tomli-2.4.0-cp314-cp314t-win_arm64.whl", hash = "sha256:2b1e3b80e1d5e52e40e9b924ec43d81570f0e7d09d11081b797bc4692765a3d4"}, + {file = "tomli-2.4.0-py3-none-any.whl", hash = "sha256:1f776e7d669ebceb01dee46484485f43a4048746235e683bcdffacdf1fb4785a"}, + {file = "tomli-2.4.0.tar.gz", hash = "sha256:aa89c3f6c277dd275d8e243ad24f3b5e701491a860d5121f2cdd399fbb31fc9c"}, +] +markers = {main = "extra == \"test\" and python_version < \"3.11\"", dev = "python_version < \"3.11\""} + +[[package]] +name = "typing-extensions" +version = "4.15.0" +description = "Backported and Experimental Type Hints for Python 3.9+" +optional = false +python-versions = ">=3.9" +groups = ["main", "dev"] +files = [ + {file = "typing_extensions-4.15.0-py3-none-any.whl", hash = "sha256:f0fa19c6845758ab08074a0cfa8b7aecb71c999ca73d62883bc25cc018c4e548"}, + {file = "typing_extensions-4.15.0.tar.gz", hash = "sha256:0cea48d173cc12fa28ecabc3b837ea3cf6f38c6d1136f85cbaaf598984861466"}, +] +markers = {main = "extra == \"test\" and python_version < \"3.11\"", dev = "python_version < \"3.11\""} + +[extras] +test = ["pytest"] + +[metadata] +lock-version = "2.1" +python-versions = ">=3.9" +content-hash = "13f32d5c13afe3ad4370b859cd6a7ee816b6e7f3351b9aeabcc2b97167cf891f" diff --git a/pyproject.toml b/pyproject.toml index 881a54f..1f7734f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -10,8 +10,11 @@ readme = "README.md" requires-python = ">=3.9" authors = [{ name = "QunaSys" }] +[project.optional-dependencies] +test = ["pytest>=8.0"] + [tool.setuptools] -package-dir = { "" = "src" } +package-dir = { "qret_cli_bundle" = "." } -[tool.setuptools.packages.find] -where = ["src"] +[tool.poetry.group.dev.dependencies] +pytest = "^8.0" diff --git a/src/qret_cli_bundle/__init__.py b/qret_cli_bundle/__init__.py similarity index 70% rename from src/qret_cli_bundle/__init__.py rename to qret_cli_bundle/__init__.py index 031d999..759529a 100644 --- a/src/qret_cli_bundle/__init__.py +++ b/qret_cli_bundle/__init__.py @@ -37,12 +37,8 @@ def _platform_asset_name() -> str: raise QretBundleError(f"Unsupported platform: {system} ({machine})") -def _release_json(repo: str, tag: str | None) -> dict: - if tag: - url = f"{API_BASE}/repos/{repo}/releases/tags/{tag}" - else: - url = f"{API_BASE}/repos/{repo}/releases/latest" - +def _release_json() -> dict: + url = f"{API_BASE}/repos/{DEFAULT_REPO}/releases/latest" req = urllib.request.Request(url, headers={"Accept": "application/vnd.github+json"}) with urllib.request.urlopen(req, timeout=60) as response: return json.load(response) @@ -79,21 +75,44 @@ def _find_qret_binary(root: Path) -> Path: raise QretBundleError(f"Could not find {exe_name} under {root}") +def _append_env_path(var_name: str, entry: str) -> None: + current = os.environ.get(var_name, "") + os.environ[var_name] = current + os.pathsep + entry if current else entry + + +def _find_existing_qret_in_path() -> Path | None: + exe_name = "qret.exe" if platform.system() == "Windows" else "qret" + qret_path = shutil.which(exe_name) + if qret_path: + candidate = Path(qret_path).resolve() + if candidate.is_file(): + return candidate + return None + + def ensure_qret_on_path() -> Path: """Ensure qret is downloaded and available in PATH, returning its full path.""" - repo = os.environ.get("QRET_BUNDLE_REPOSITORY", DEFAULT_REPO) - tag = os.environ.get("QRET_BUNDLE_TAG") + existing_qret = _find_existing_qret_in_path() + if existing_qret: + qret = existing_qret + bin_dir = qret.parent + lib_dir = qret.parent.parent / "lib" + if bin_dir.exists(): + _append_env_path("PATH", str(bin_dir)) + if platform.system() == "Linux" and lib_dir.exists(): + _append_env_path("LD_LIBRARY_PATH", str(lib_dir)) + return qret + asset_name = _platform_asset_name() temp_root = Path(tempfile.gettempdir()) / "qret-cli-bundle" - release_key = tag or "latest" - install_root = temp_root / repo.replace("/", "__") / release_key / asset_name + install_root = temp_root / DEFAULT_REPO.replace("/", "__") / "latest" / asset_name marker = install_root / ".ready" if marker.exists(): qret = _find_qret_binary(install_root) else: - release = _release_json(repo=repo, tag=tag) + release = _release_json() assets = {asset["name"]: asset["browser_download_url"] for asset in release.get("assets", [])} if asset_name not in assets: available = ", ".join(sorted(assets.keys())) @@ -113,15 +132,15 @@ def ensure_qret_on_path() -> Path: qret = _find_qret_binary(install_root) marker.write_text("ok", encoding="utf-8") - bin_dir = str(qret.parent) - current_path = os.environ.get("PATH", "") - parts = current_path.split(os.pathsep) if current_path else [] - if bin_dir not in parts: - os.environ["PATH"] = bin_dir + (os.pathsep + current_path if current_path else "") - os.environ["QRET_PATH"] = str(qret) + bin_dir = qret.parent + lib_dir = qret.parent.parent / "lib" + if bin_dir.exists(): + _append_env_path("PATH", str(bin_dir)) + if platform.system() == "Linux" and lib_dir.exists(): + _append_env_path("LD_LIBRARY_PATH", str(lib_dir)) return qret -QRET_PATH = ensure_qret_on_path() +ensure_qret_on_path() -__all__ = ["QRET_PATH", "QretBundleError", "ensure_qret_on_path"] +__all__ = ["QretBundleError", "ensure_qret_on_path"] diff --git a/tests/test_qret_cli_bundle.py b/tests/test_qret_cli_bundle.py new file mode 100644 index 0000000..cded652 --- /dev/null +++ b/tests/test_qret_cli_bundle.py @@ -0,0 +1,20 @@ +from __future__ import annotations + +import subprocess +import shutil + + +def test_import_and_qret_version() -> None: + import qret_cli_bundle # noqa: F401 + + qret_executable = shutil.which("qret") or shutil.which("qret.exe") or shutil.which("qret.cmd") + assert qret_executable is not None + + result = subprocess.run( + [qret_executable, "--version"], + capture_output=True, + text=True, + check=False, + ) + assert result.returncode == 0, result.stderr + assert result.stdout.strip() or result.stderr.strip()