Metadata-Version: 2.5
Name: yp
Version: 0.0.17
Summary: A mapping view to pypi projects
Project-URL: Homepage, https://github.com/thorwhalen/yp
Author: Thor Whalen
License-Expression: Apache-2.0
License-File: LICENSE
Requires-Python: >=3.10
Requires-Dist: bs4
Requires-Dist: config2py
Requires-Dist: dol
Requires-Dist: lxml
Requires-Dist: packaging
Requires-Dist: pipdeptree
Requires-Dist: requests
Provides-Extra: dev
Requires-Dist: pytest-cov>=4.0; extra == 'dev'
Requires-Dist: pytest>=7.0; extra == 'dev'
Requires-Dist: ruff>=0.1.0; extra == 'dev'
Provides-Extra: docs
Requires-Dist: sphinx-rtd-theme>=1.0; extra == 'docs'
Requires-Dist: sphinx>=6.0; extra == 'docs'
Description-Content-Type: text/markdown

# yp

A mapping view to PyPI projects: look up any project's info by name with `p['numpy']`, list all project names, and narrow the collection to a user's projects or your own set. For more PyPI interaction tools, see also `pipoke`.

```bash
pip install yp
```

## Example usage

Get a mapping of all of `pypi` projects. The keys are the project names (there are lots!), and the values are each project's info:

```python
>>> from yp import Pypi
>>> p = Pypi()
>>> len(p)  # doctest: +SKIP
405120
>>> 'numpy' in p and 'dol' in p
True
>>> 'no_way_this_is_a_package' in p
False
>>> info = p['numpy']  # doctest: +SKIP
>>> list(info)  # doctest: +SKIP
['info', 'last_serial', 'releases', 'urls', 'vulnerabilities']

```

The project info is obtained live, making requests to the `https://pypi.python.org/pypi/{pkg_name}/json` API, but the list of all project names is taken from a local file. You should update that file regularly (but not TOO regularly!) to be in sync with pypi.org:

```python
>>> Pypi.refresh_cached_package_names()  # doctest: +SKIP

```

If you don't want all projects of PyPI to be the collection you're working with, you can specify what `user` they should belong to, or explicitly give `Pypi` a collection of project names:

```python
>>> p = Pypi(user='thorwhalen1')  # doctest: +SKIP
>>> len(p)  # doctest: +SKIP
131
>>> p = Pypi(proj_names={'numpy', 'pandas', 'dol'})
>>> len(p)
3

```

You can do a lot more by simply using the tools of `dol` to change the mapping you want to work with in all kinds of ways!

# Extras

`yp` ships a cached list of every PyPI project name (`yp/data/pkg_list.tsv.gz`), so name lookups are instant and offline. The cache is loaded lazily -- the first lookup pays for it, `import yp` does not.

`yp.refresh_saved_pkg_name_stub()` fetches the current list and saves it to your app folder, which then takes precedence over the copy shipped with the package. (It writes there rather than into the installed package, which is read-only in many installs.) Pass `save_to=` to write elsewhere.

I also refresh the shipped copy from time to time and push the results. You can find the list (as a text file with one name per line) here: https://raw.githubusercontent.com/thorwhalen/yp/refs/heads/master/yp/data/pkg_list.txt


# Skills

`yp` ships [AI agent skills](https://docs.claude.com/en/docs/agents-and-tools/agent-skills/overview) (SKILL.md files) that teach an agent how to drive its tools. They live in `yp/data/skills/` (so they install with the package) and are mirrored into `.claude/skills/` for Claude Code.

| Skill | What it helps you do |
|---|---|
| `yp-name-availability` | Find an **available** PyPI name for a new package: brainstorm → fast cached pre-filter → authoritative live check → present the free options. |
| `yp-name-cache` | Operate the cached PyPI name index: refresh it, check names fast/offline, understand freshness & normalization caveats. |
| `yp-package-info` | Fetch live PyPI info: full project JSON, a tidy digest, latest version(s), last-upload time, a user's projects, bulk download. |
| `yp-dependencies` | Inspect an installed package's dependency tree (direct/transitive, required vs installed, version conflicts). |

Install one into an agent host with [`gh skill`](https://github.com/github/gh-skill):

```bash
gh skill install thorwhalen/yp yp-name-availability
```
