Skip to main content

Check for package compatibility with PyScript.

Project description

PyScript Packages (pspkg) 📦

PyScript is a platform for Python in the browser.

This is a deliberately simple module and command line tool for discovering the compatibility of packages in PyPI with PyScript. It's a shim around the static API provided by the PyScript Packages website.

Why?

Running Python in the context of a browser means certain assumptions made by packages running in traditional Python environments do not apply. This tool provides details about packages compatible with PyScript so developers can make informed decisions about which packages to use.

Usage 💻

pip install pspkg

This will install the module and give you a command line tool called pspkg.

$ pspkg --help
usage: pspkg.py [-h] [--refresh] [--reset] [PACKAGES ...]

A simple client for the PyScript packages static API.

positional arguments:
  PACKAGES              Package names to check for support. Emits JSON output.

options:
  -h, --help            show this help message and exit
  --refresh             Refresh the local dump of supported packages from the API.
  --reset               Delete the local dump of supported packages.

For example:

$ pspkg numpy dogpt pyqt5 qwertyuiop123

Will emit JSON data about the support status of the four packages numpy, dogpt, pyqt5 and qwertyuiop123.

Use the module within Python code like this, to gather the same package information:

import pspkg

# A blocking call to get package support info. The cache will be automatically
# filled.
pkg_info = pspkg.match_packages(["numpy", "dogpt", "pyqt5", "qwertyuiop123", ])

# Reset the cache.
pspkg.reset()

# Refresh the cache from the Python projects API.
pspkg.refresh()

A local cache is stored in the location specified by the environment variable PYSCRIPT_PACKAGES_CACHE or, if not specified, a file called pspkg_cache.json adjacent to the location of the module on the local filesystem.

Output 📊

The output data contains an entry for each package specified. Each entry is referenced by a key that is the package name.

{
    "numpy": {
        "supported": True,
        "info": {
            ...
        }
    },
    "dogpt": {
        "supported": False,
        "is_pure_python": True,
        "info": {
            ...
        }
    },
    "pyqt5": {
        "supported": False,
        "is_pure_python": False,
        "info": {
            ...
        }
    },
    "qwertyuiop123": {
        "supported": False,
        "is_pure_python": False,
        "info": None,
    }
}

The associated values for each package depend on the status of the package. Given the example package list, the following states exist:

  • numpy - known to be supported by PyScript. The info dict will contain information conforming to the metadata specified by the PyScript packages API.
  • dogpt - unknown PyScript support. But metadata from PyPI indicates this is a pure Python package, so could work (pending user validation). The info dict will contain information describing the package from PyPI.
  • pyqt5 - unknown PyScript support. PyPI metadata suggests this is NOT a pure Python package and so will definitely NOT work with PyScript. The info dict will contain information describingthe package from PyPI.
  • qwertyuiop123 - unknown PyScript support. An unknown package on PyPI. Have you typed in the package name properly?

Contributing 💐

Create a virtual environment, clone the GitHub repository, and then install the local dependencies like this:

pip install -e .[dev]

We have a simple Makefile to automate common local development tasks. Please read it to learn more.

Many thanks for wanting to improve the project.

Contributions are welcome without prejudice from anyone irrespective of their background. If you're thinking, "but they don't mean me", then we especially mean YOU. Good quality code and engagement with respect, humour and intelligence wins every time.

We expect contributors to follow the spirit of our statement on the care of community (CARE_OF_COMMUNITY.md) file found within this repository.

Feedback may be given for contributions and, where necessary, changes will be politely requested and discussed with the originating author. Respectful yet robust argument is most welcome.

Contributions are subject to the following caveats: the contribution was created by the contributor who, by submitting the contribution, is confirming that they have the authority to submit the contribution and place it under the license as defined in the license (LICENSE.md) file found within this repository. If this is a significant contribution the contributor should add themselves to the AUTHORS.md file found in the root of this repository. Contributors agree, for the sake of convenience, that copyright passes exclusively to Anaconda Inc. on behalf of the project.

Acknowledgements ❤️

Huge thanks to Anaconda, who support the development of PyScript.

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

pspkg-0.1.0.tar.gz (6.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pspkg-0.1.0-py3-none-any.whl (6.9 kB view details)

Uploaded Python 3

File details

Details for the file pspkg-0.1.0.tar.gz.

File metadata

  • Download URL: pspkg-0.1.0.tar.gz
  • Upload date:
  • Size: 6.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0

File hashes

Hashes for pspkg-0.1.0.tar.gz
Algorithm Hash digest
SHA256 f0585a69db4545e18e8089461fc092135d167aa81d50704fb04f8377a2f86576
MD5 ea65e4e3fef011ad8a56f78cb2091f93
BLAKE2b-256 6cf44c4541fc2aca4339d91479d3be00aff31166fb1da5f4f24fba1791204b75

See more details on using hashes here.

File details

Details for the file pspkg-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: pspkg-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 6.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0

File hashes

Hashes for pspkg-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 aae9c3e8f3a839a2e980a180c0c0d7aa37c8c1bc76865a5573babc590f236512
MD5 25c27a9267addbb29c973a6b35c35450
BLAKE2b-256 f00fb19c8198d396e02870bfcb72f072f73d0465bc647e7620a275ac1fe94b1e

See more details on using hashes here.

Supported by

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