{"id":29941742,"url":"https://github.com/posit-dev/picopip","last_synced_at":"2026-06-17T07:31:37.463Z","repository":{"id":296479106,"uuid":"986376988","full_name":"posit-dev/picopip","owner":"posit-dev","description":"Embed-friendly Python env/package scanner with zero deps","archived":false,"fork":false,"pushed_at":"2026-06-01T13:55:29.000Z","size":50,"stargazers_count":2,"open_issues_count":4,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2026-06-01T15:26:39.620Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/posit-dev.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-05-19T14:13:19.000Z","updated_at":"2026-06-01T14:19:58.000Z","dependencies_parsed_at":"2025-05-31T11:39:53.121Z","dependency_job_id":"1b9bd982-139e-4018-a446-17b762198251","html_url":"https://github.com/posit-dev/picopip","commit_stats":null,"previous_names":["posit-dev/picopip"],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/posit-dev/picopip","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/posit-dev%2Fpicopip","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/posit-dev%2Fpicopip/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/posit-dev%2Fpicopip/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/posit-dev%2Fpicopip/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/posit-dev","download_url":"https://codeload.github.com/posit-dev/picopip/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/posit-dev%2Fpicopip/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34439294,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-17T02:00:05.408Z","response_time":127,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-08-03T01:27:43.824Z","updated_at":"2026-06-17T07:31:37.454Z","avatar_url":"https://github.com/posit-dev.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# picopip\n\nEmbed-friendly Python env/package scanner with zero deps.\n\nThis is primarily designed so that you can take `src/picopip.py`\nand copy it into your own project to use it without having\nto install dependencies.\n\n## Usage\n\n### Get list of installed packages\n\nYou can use `get_packages_from_env` to list all installed packages in a Python virtual environment. Here's how to do it using Python's built-in `venv` module:\n\n```python\n\u003e\u003e\u003e from picopip import get_packages_from_env\n\u003e\u003e\u003e\n\u003e\u003e\u003e pkgs = get_packages_from_env(venvdir)\n\u003e\u003e\u003e print(pkgs)\n[('certifi', '2025.4.26'), ('charset-normalizer', '3.4.2'), ('idna', '3.10'), \n ('pip', '21.2.4'), ('requests', '2.32.3'), ('setuptools', '58.0.4'), \n ('urllib3', '2.4.0')]\n```\n\n- `get_packages_from_env(\u003cvenv_path\u003e)` returns a list of `(name, version)` tuples for all installed packages in the given virtual environment.\n- You can use any venv path, and the function will find all packages, including those installed via pip.\n\n### Scan a target directory (`pip install --target`)\n\nBy default `get_packages_from_env` expects a full virtual environment layout\n(`lib/pythonX.Y/site-packages`, `.pth` expansion, system and `PYTHONPATH`\ndiscovery). If you instead installed packages into a flat directory with\n`pip install --target \u003cdir\u003e`, pass `path_as_target=True` to scan that directory\ndirectly.\n\n```sh\npip install --target ./vendor requests\n```\n\n```python\n\u003e\u003e\u003e from picopip import get_packages_from_env\n\u003e\u003e\u003e\n\u003e\u003e\u003e pkgs = get_packages_from_env(\"./vendor\", path_as_target=True)\n\u003e\u003e\u003e print(pkgs)\n[('certifi', '2025.4.26'), ('charset-normalizer', '3.4.2'), ('idna', '3.10'),\n ('requests', '2.32.3'), ('urllib3', '2.4.0')]\n```\n\nWith `path_as_target=True`:\n\n- `venv_path` is treated as the site-packages directory itself, so no\n  `lib/pythonX.Y/site-packages` structure is required.\n- `.pth` files are not expanded and `PYTHONPATH` is not read.\n- `ignore_system_packages` is ignored (system packages are never scanned).\n\n### Get version of a package\n\nIf you only need the version of a specific package, you can get it\nusing `get_package_version_from_env`\n\n```python\n\u003e\u003e\u003e from picopip import get_package_version_from_env\n\u003e\u003e\u003e\n\u003e\u003e\u003e version = get_package_version_from_env(venvdir, \"pip\")\n\u003e\u003e\u003e print(version)\n'21.2.4'\n```\n\n### Parse a version string\n\n`parse_version` normalizes a version into a tuple that follows the same ordering\nrules used by `pip`/`packaging`. The first element is the release components,\nthe second is an offset encoding pre/dev/post markers so you can compare the\ntuples with standard operators.\n\n```python\n\u003e\u003e\u003e from picopip import parse_version\n\u003e\u003e\u003e\n\u003e\u003e\u003e parse_version(\"1.13.5\")\n((1, 13, 5), 0)\n\u003e\u003e\u003e parse_version(\"1.13.5a1\") \u003c parse_version(\"1.13.5\")\nTrue\n\u003e\u003e\u003e parse_version(\"1.13.5.post2\") \u003e parse_version(\"1.13.5\")\nTrue\n```\n\n### Check a version against a constraint\n\n`parse_constraints` parses a requirement spec like `\"aiokafka \u003e= 0.8, \u003c 1.0\"`\ninto the package name and a list of `(comparator, parsed_version)` pairs.\nApply every pair to a parsed version to decide whether it satisfies the spec.\n\n```python\n\u003e\u003e\u003e from picopip import parse_constraints, parse_version\n\u003e\u003e\u003e\n\u003e\u003e\u003e name, constraints = parse_constraints(\"aiokafka \u003e= 0.8, \u003c 1.0\")\n\u003e\u003e\u003e name\n'aiokafka'\n\u003e\u003e\u003e v = parse_version(\"0.9.1\")\n\u003e\u003e\u003e all(op(v, cv) for op, cv in constraints)\nTrue\n\u003e\u003e\u003e v = parse_version(\"1.0.0\")\n\u003e\u003e\u003e all(op(v, cv) for op, cv in constraints)\nFalse\n```\n\nThe name is `None` for bare specs (`\"\u003e= 0.8, \u003c 1.0\"`).\n \n## Releasing\n\nReleases are cut by pushing a `N.N.N` git tag. The `Release` workflow runs\nlint and tests, then publishes a GitHub release with auto-generated notes.\n\n1. Bump the `Version:` line in `src/picopip.py` on `main` and merge.\n2. Tag the release commit with the matching version and push the tag:\n\n   ```sh\n   git tag 0.5.1\n   git push origin 0.5.1\n   ```\n\nThe workflow fails if the tag does not match `N.N.N` or does not match the\n`Version:` line in `src/picopip.py`, so both must be kept in sync.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fposit-dev%2Fpicopip","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fposit-dev%2Fpicopip","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fposit-dev%2Fpicopip/lists"}