Skip to main content

No project description provided

Project description

keyring-subprocess

A minimal dependency keyring backend for lean virtual environments.

This is achieved by locating a virtual environment which has keyring-subprocess[landmark] installed whose keyring-subprocess can be found on the PATH. keyring-subprocess is effectively a renamed keyring executable and serves as a more unique landmark file.

The virtual environment that is found this way should have the actual keyring backend(s) you need installed into it.

Pros

  • Minimal dependencies for a clean pip list command and to always be compatible with the rest of your dependencies. Which makes it more suitable to be added to PYTHONPATH after installing with Pip's --target flag.
  • Has keyring and the minimal required dependencies vendored to make the chainer and null backends work.
    • It uses the ModuleSpec apis provided by PEP451 to make the vendored keyring importable.
  • Provices an extra named landmark that will provide the keyring-subprocess executable.
  • Provides a virtualenv Seeder named keyring-subprocess.
    • Set VIRTUALENV_SEEDER to keyring-subprocess or set seeder in the config file to the same value.
  • Provides a sitecustomize entry point for the sitecustomize-entrypoints package. This can be useful if you install it somewhere that is not a so-called site directory by using Pip's --target flag.
    • You can install both keyring-subprocess and sitecustomize-entrypoints in one go by executing pip install keyring-subprocess[sitecustomize].
      • sitecustomize-entrypoints is required if you if keyring-subprocess is installed into a PYTHONPATH location.

Cons

  • It does require keyring-subprocess[landmark] to be installed into a virtual environment whose keyring-subprocess can be found on the PATH.
  • Adds, or replaces, points of failures. Depending on how you look at it.
  • Being able to import keyring, importlib_metadata and zipp but pip list not listing them might be confusing and not very helpful during debugging.

Example on Windows

This is a Powershell script which installs Pipx into C:\Users\Public\.local\pipx.

  • First it sets some environment variables, including VIRTUALENV_SEEDER.
  • Then it installs keyring via Pipx and injects artifacts-keyring and keyring-subprocess[landmark] into the virtual environment of keyring.
  • Lastly it installs keyring-subprocess and sitecustomize-entrypoints into Pipx's shared virtualenv which Pipx makes sure is available to all virtual environments it manages.

When using your new Pipx installation to install Poetry or Pipenv the virtual environment created by virtualenv will contain keyring-subprocess. This should cause installing the project dependencies from your private repository to succeed!

Assuming of couse that your private repository requires artifacts-keyring to authenticate, and is therefor a Azure DevOps Artifact Feed. If this is not the case this should be easily fixed by replacing artifacts-keyring by the package that provides the keyring backend that you actually need.

$EnvironmentVariableTarget = $(Read-Host "Target environment (User/Machine) [Machine]").Trim(); `
if ($EnvironmentVariableTarget -eq "") { `
  $EnvironmentVariableTarget = "Machine"; `
} `
if ($EnvironmentVariableTarget -inotin @("User", "Machine")) { `
  Write-Host "Invalid option."; `
} else { `
  try { `
    try { `
       [Environment]::SetEnvironmentVariable("PIPX_HOME", "C:\Users\Public\.local\pipx", $EnvironmentVariableTarget); `
       [Environment]::SetEnvironmentVariable("PIPX_BIN_DIR", "C:\Users\Public\.local\bin", $EnvironmentVariableTarget); `
       [Environment]::SetEnvironmentVariable("VIRTUALENV_SEEDER", "keyring-subprocess", $EnvironmentVariableTarget); `
       [Environment]::SetEnvironmentVariable("Path", "C:\Users\Public\.local\bin;" + [Environment]::GetEnvironmentVariable("Path", $EnvironmentVariableTarget), $EnvironmentVariableTarget); `
    } catch { `
      throw "Run as Administrator or choose `"User`" as the target environment" `
    }; `
    `
    $PATH = $env:PATH; `
    $PIP_NO_INPUT = $env:PIP_NO_INPUT; `
    $PIP_INDEX_URL = $env:PIP_INDEX_URL; `
    $ExecutionPolicy = Get-ExecutionPolicy; `
    $env:PIP_NO_INPUT = '1'; `
    $env:PIP_INDEX_URL = 'https://pypi.org/simple/'; `
    $env:PIPX_HOME = [Environment]::GetEnvironmentVariable("PIPX_HOME", $EnvironmentVariableTarget); `
    $env:PIPX_BIN_DIR = [Environment]::GetEnvironmentVariable("PIPX_BIN_DIR", $EnvironmentVariableTarget); `
    $env:PATH = $PATH = "C:\Users\Public\.local\bin;"+$env:PATH; `
    Set-Location (Get-Item $env:TEMP).FullName; `
    `
    <# Use the py executable if it can be found and default to the python executable #> 
    `
    $py = $(where.exe py python)[0]; `
    $env:PATH = $(& "$py" -c "import sys; import sysconfig; import os; from pathlib import Path; from itertools import chain; print(os.pathsep.join(chain(set([str(Path(sys.executable).parent), sysconfig.get_path(`"`"scripts`"`")]), [os.environ[`"`"PATH`"`"]])))"); `
    `
    & "$py" -m venv .venv; `
    `
    Set-ExecutionPolicy -ExecutionPolicy Bypass -Scope Process -Force; `
    . .\.venv\Scripts\Activate.ps1; `
    `
    & "$py" -m pip install -qqq --no-input --isolated pipx; `
    pipx install --pip-args="--no-input --isolated" pipx; `
    pipx install --pip-args="--no-input --isolated" keyring; `
    pipx inject --pip-args="--no-input --isolated" keyring artifacts-keyring; `
    pipx inject --pip-args="--no-input --isolated" --include-apps --include-deps keyring keyring-subprocess[landmark]; `
    pipx install --pip-args="--no-input --isolated" virtualenv; `
    `
    <# Minor hack since Pipx does not allow us to do this via the cli #> `
    & "$env:PIPX_HOME\shared\Scripts\pip.exe" install --no-input --isolated keyring-subprocess[sitecustomize]; `
    `
    deactivate; `
    Remove-Item -path .\.venv -Recurse -Force; `
    `
    <# Fill virtualenv's wheel cache with keyring-subprocess and up-to-date versions of the embeded wheels #> `
    <# I might take a stab at making keyring-subprocess a Quine at some point... #> `
    virtualenv --upgrade-embed-wheels; `
    virtualenv --seeder keyring-subprocess --download .venv; `
    Remove-Item -path .\.venv -Recurse -Force; `
    `
  } finally { `
    $env:PATH = $PATH; `
    $env:PIP_NO_INPUT = $PIP_NO_INPUT; `
    $env:PIP_INDEX_URL = $PIP_INDEX_URL; `
    if ($ExecutionPolicy) { `
      Set-ExecutionPolicy -ExecutionPolicy $ExecutionPolicy -Scope Process -Force; `
    } `
  } `
}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

keyring-subprocess-0.8.0.tar.gz (121.1 kB view details)

Uploaded Source

Built Distribution

keyring_subprocess-0.8.0-py3-none-any.whl (130.4 kB view details)

Uploaded Python 3

File details

Details for the file keyring-subprocess-0.8.0.tar.gz.

File metadata

  • Download URL: keyring-subprocess-0.8.0.tar.gz
  • Upload date:
  • Size: 121.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.10.5

File hashes

Hashes for keyring-subprocess-0.8.0.tar.gz
Algorithm Hash digest
SHA256 3fa19bc9c517d4771dd1136506d4ea5cb33b870cf9d9addce76818d920dc1210
MD5 f43fa3253b1dde51c8e586bdfe19a433
BLAKE2b-256 836a426a557b1602b9e71ff8e67425e07ebc70cc0024c7135ea9a24d77ba89ab

See more details on using hashes here.

File details

Details for the file keyring_subprocess-0.8.0-py3-none-any.whl.

File metadata

File hashes

Hashes for keyring_subprocess-0.8.0-py3-none-any.whl
Algorithm Hash digest
SHA256 840ae925f26e7997e65ee1a51654ae756c1ea8d54c63ef1db9d36a6e9226a1eb
MD5 30d70760ff077f51657c47410e56908f
BLAKE2b-256 39c6c69c85bc7235b757a319ff116721f13c89eb39a5f79b7cd721bad23b2bf1

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page