Giter Club home page Giter Club logo

pypi-token-client's Introduction

pypi-token-client

pipeline status docs pypi supported python versions

Library and CLI tool for creating and managing PyPI project tokens.

Purpose

PyPI allows the creation of per-project tokens but doesn't currently have an API to do so. While integration with CI providers is planned, apparently there is no plan for an API that would allow one to create tokens from a local development machine.

This tool seeks to provide a client exposing this functionality anyway by whatever means necessary.

Operating principle

Because there is no API and I'm also too lazy to try and figure out the exact sequence of HTTP requests one would have to make to simulate what happens when requesting tokens on the PyPI website, for now this tool just uses Playwright to automate performing the necessary steps in an actual browser.

This might be overkill and brittle but it works for now ๐Ÿคท

Installation

To install from PyPI:

pip3 install pypi-token-client

You'll also have to install the required Playwright browsers (currently just Chromium):

playwright install chromium

Command-line tool usage

To create a token yourtokenname for your PyPI project yourproject:

pypi-token-client create --project yourproject yourtokenname

There are more commands - please refer to the docs.

Usage as a library

Basic example script:

import asyncio
from os import getenv

from pypi_token_client import (
  async_pypi_token_client, SingleProject, PypiCredentials
)

credentials = PypiCredentials(getenv("PYPI_USER"), getenv("PYPI_PASS"))
assert credentials.username and credentials.password

async def main() -> str:
  async with async_pypi_token_client(credentials) as session:
      token = await session.create_token(
          "my token",
          SingleProject("my-project"),
      )
  return token

token = asyncio.run(main())

print(token)

More information

For more detailed usage information and the API reference, refer to the documentation.

License

MIT License, see LICENSE file.

pypi-token-client's People

Contributors

smheidrich avatar

Watchers

 avatar Kostas Georgiou avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.