npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@adhd/apigen-python-env

v0.2.4

Published

apigen python host provisioning: resolves the interpreter for py-* plugins by bootstrapping a managed venv from apigen-python's own pyproject.toml extras

Readme

@adhd/apigen-python-env

Python host provisioning for apigen's py-* plugins.

The problem it solves

py-grpc / py-flask spawn a Python process (apigen_python.grpc_server / flask_server). Those servers need grpcio + grpcio-reflection — deps that are declared in packages/apigen/python/pyproject.toml (the grpc extra), but that used to be expected on whatever python3 happened to be on PATH. On any machine without them, apigen run/serve --type py-grpc died on import.

This package makes the Python packaging the single source of truth: it provisions a managed venv by pip install-ing apigen-python (with the requested extras) from its own pyproject.toml, and hands back that venv's interpreter.

API

import { ensurePythonEnv, resolvePythonPkgDir } from '@adhd/apigen-python-env'

const { python, venvDir, pythonPkgDir } = ensurePythonEnv({ extras: ['grpc'] })
// spawn(python, ['-m', 'apigen_python.grpc_server', ...], { env: { PYTHONPATH: pythonPkgDir } })
  • ensurePythonEnv({ extras }) — returns the interpreter to spawn. Resolution order:
    1. APIGEN_PYTHON env var (explicit override — CI images, power users).
    2. Managed venv at ~/.adhd/apigen/pyvenv — created on first use, refreshed automatically when pyproject.toml (or the requested extras) change (content-hash stamp file). Creation is cross-process locked, so concurrent serve children don't double-provision.
  • resolvePythonPkgDir() — locates the apigen_python sources (shared by both py plugins; also exported for tools like the conformance gate).

Environment knobs:

| Var | Effect | | --- | ------ | | APIGEN_PYTHON | Skip the managed venv; use this interpreter as-is. | | APIGEN_PYENV_HOME | Relocate the managed-venv root (tests point it at tmp/). |

Failure mode

Loud, never silent: if no Python ≥ 3.11 is on PATH or pip install fails, the error says exactly what to install. The plugins no longer fall back to a bare python3 that may be missing its deps.

Consumers

  • @adhd/apigen-plugin-py-grpcensurePythonEnv({ extras: ['grpc'] })
  • @adhd/apigen-plugin-py-flaskensurePythonEnv() (stdlib HTTP fallback needs no extras)
  • apigen serve — pre-provisions before spawning Python hosts so child ready timeouts don't absorb a first-time venv build, and pins children via APIGEN_PYTHON.