pyscript


Namepyscript JSON
Version 0.3.3 PyPI version JSON
download
home_pagehttps://github.com/pyscript/pyscript-cli
SummaryCommand Line Interface for PyScript
upload_time2024-09-09 13:02:34
maintainerNone
docs_urlNone
authorMatt Kramer, Fabio Pliger, Nicholas Tollervey, Fabio Rosado, Madhur Tandon
requires_python>=3.9
licenseApache-2.0
keywords pyscript cli pyodide micropython pyscript-cli
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage
            # PyScript CLI

A command-line interface for [PyScript](https://pyscript.net).


[![Version](https://img.shields.io/pypi/v/pyscript.svg)](https://pypi.org/project/pyscript/)
[![Test](https://github.com/pyscript/pyscript-cli/actions/workflows/test.yml/badge.svg)](https://github.com/pyscript/pyscript-cli/actions/workflows/test.yml)
[![codecov](https://codecov.io/gh/pyscript/pyscript-cli/branch/main/graph/badge.svg?token=dCxt9oBQPL)](https://codecov.io/gh/pyscript/pyscript-cli)
[![pre-commit.ci status](https://results.pre-commit.ci/badge/github/pyscript/pyscript-cli/main.svg)](https://results.pre-commit.ci/latest/github/pyscript/pyscript-cli/main)
[![Checked with mypy](http://www.mypy-lang.org/static/mypy_badge.svg)](http://mypy-lang.org/)

Quickly wrap Python scripts into a HTML template, pre-configured with [PyScript](https://pyscript.net).

```bash
❯ pyscript

 Usage: pyscript [OPTIONS] COMMAND [ARGS]...

 Command Line Interface for PyScript.

╭─ Options ──────────────────────────────────────────────────────────────────────────────────────╮
│ --version          Show project version and exit.                                              │
│ --help             Show this message and exit.                                                 │
╰────────────────────────────────────────────────────────────────────────────────────────────────╯
╭─ Commands ─────────────────────────────────────────────────────────────────────────────────────╮
│ create  Create a new pyscript project with the passed in name, creating a new directory in the │
│         current directory. Alternatively, use `--wrap` so as to embed a python file instead.   │
│ run     Creates a local server to run the app on the path and port specified.                  │
╰────────────────────────────────────────────────────────────────────────────────────────────────╯

```

## Installation

### Using Pip

```shell
$ pip install pyscript
```

### Installing the developer setup from the a repository clone


[see the Developer setup section on CONTRIBUTING page](CONTRIBUTING.md)

## Usage

### run

#### Spin up a local server to run on the path and specified port

```shell
$ pyscript run <path_of_folder>
```

This will serve the folder `path_of_folder` at `localhost:8000` by default
and will open the URL in a browser window. Default is current directory if
`path_of_folder` is not supplied.

To use a different port, use `--port` option.

```shell
$ pyscript run <path_of_folder> --port 9000
```

To avoid opening a browser window, use `--no-view` option.

```shell
$ pyscript run <path_of_folder> --no-view
```

### create

#### Create a new pyscript project with the passed in name, creating a new directory

```shell
$ pyscript create <name_of_app>
```

This will create a new directory named `name_of_app` under the current directory.

The interactive prompts will further ask for information such as `description of the app`,
`name of the author`, `email of the author`, etc. These of course can be provided via
options such as `--author-name` etc. Use `pyscript create --help` for more information.

The following files will be created:

- `index.html`: start page for the project
- `pyscript.toml`: project metadata and config file
- `main.py`: a "Hello world" python starter module

#### Use --wrap to embed a python file OR a command string

- ##### Embed a Python script into a PyScript HTML file

```shell
$ pyscript create --wrap <filename.py>
```

This will generate a project i.e. a new directory named `filename` under the current directory.

Similar to the above, interactive prompts will further ask for metadata information.

The following files will be created:

- `index.html`: start page for the project
- `pyscript.toml`: project metadata and config file
- `main.py`: contains code of `filename.py`

This can be overridden with the `-o` or `--output` option:

```shell
$ pyscript create --wrap <filename.py> -o <another_filename.html>
```

i.e. the HTML file created in the above directory will now be named `another_filename.html`

- ##### Very simple command examples with `--command` option

The `-c` or `--command` option can be used to demo very simple cases.

By default, the name of the project folder created will be `pyscript-command-app` with the HTML file named `index.html`.

`-o/--output` option can be used with the `-c/--command` option to configure name of the project folder as well
as the name of the resulting HTML file.

```shell
$ pyscript create --wrap -c 'print("Hello World!")' -o <output_filename.html>
```

This will generate a project i.e. a new directory named `output_filename` under the current directory.

Similar to the above, interactive prompts will further ask for metadata information.

The following files will be created:

- `output_filename.html`: start page for the project
- `pyscript.toml`: project metadata and config file
- `main.py`: contains code of the command string passed via `-c/--command`

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/pyscript/pyscript-cli",
    "name": "pyscript",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.9",
    "maintainer_email": null,
    "keywords": "pyscript, cli, pyodide, micropython, pyscript-cli",
    "author": "Matt Kramer, Fabio Pliger, Nicholas Tollervey, Fabio Rosado, Madhur Tandon",
    "author_email": "mkramer@anaconda.com, fpliger@anaconda.com, ntollervey@anaconda.com, frosado@anaconda.com, mtandon@anaconda.com",
    "download_url": "https://files.pythonhosted.org/packages/9d/4d/ee8606f71049fe29666e5541f0dd1a4f861dd3a6824334fac3c5aec3e8d9/pyscript-0.3.3.tar.gz",
    "platform": null,
    "description": "# PyScript CLI\n\nA command-line interface for [PyScript](https://pyscript.net).\n\n\n[![Version](https://img.shields.io/pypi/v/pyscript.svg)](https://pypi.org/project/pyscript/)\n[![Test](https://github.com/pyscript/pyscript-cli/actions/workflows/test.yml/badge.svg)](https://github.com/pyscript/pyscript-cli/actions/workflows/test.yml)\n[![codecov](https://codecov.io/gh/pyscript/pyscript-cli/branch/main/graph/badge.svg?token=dCxt9oBQPL)](https://codecov.io/gh/pyscript/pyscript-cli)\n[![pre-commit.ci status](https://results.pre-commit.ci/badge/github/pyscript/pyscript-cli/main.svg)](https://results.pre-commit.ci/latest/github/pyscript/pyscript-cli/main)\n[![Checked with mypy](http://www.mypy-lang.org/static/mypy_badge.svg)](http://mypy-lang.org/)\n\nQuickly wrap Python scripts into a HTML template, pre-configured with [PyScript](https://pyscript.net).\n\n```bash\n\u276f pyscript\n\n Usage: pyscript [OPTIONS] COMMAND [ARGS]...\n\n Command Line Interface for PyScript.\n\n\u256d\u2500 Options \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u256e\n\u2502 --version          Show project version and exit.                                              \u2502\n\u2502 --help             Show this message and exit.                                                 \u2502\n\u2570\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u256f\n\u256d\u2500 Commands \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u256e\n\u2502 create  Create a new pyscript project with the passed in name, creating a new directory in the \u2502\n\u2502         current directory. Alternatively, use `--wrap` so as to embed a python file instead.   \u2502\n\u2502 run     Creates a local server to run the app on the path and port specified.                  \u2502\n\u2570\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u256f\n\n```\n\n## Installation\n\n### Using Pip\n\n```shell\n$ pip install pyscript\n```\n\n### Installing the developer setup from the a repository clone\n\n\n[see the Developer setup section on CONTRIBUTING page](CONTRIBUTING.md)\n\n## Usage\n\n### run\n\n#### Spin up a local server to run on the path and specified port\n\n```shell\n$ pyscript run <path_of_folder>\n```\n\nThis will serve the folder `path_of_folder` at `localhost:8000` by default\nand will open the URL in a browser window. Default is current directory if\n`path_of_folder` is not supplied.\n\nTo use a different port, use `--port` option.\n\n```shell\n$ pyscript run <path_of_folder> --port 9000\n```\n\nTo avoid opening a browser window, use `--no-view` option.\n\n```shell\n$ pyscript run <path_of_folder> --no-view\n```\n\n### create\n\n#### Create a new pyscript project with the passed in name, creating a new directory\n\n```shell\n$ pyscript create <name_of_app>\n```\n\nThis will create a new directory named `name_of_app` under the current directory.\n\nThe interactive prompts will further ask for information such as `description of the app`,\n`name of the author`, `email of the author`, etc. These of course can be provided via\noptions such as `--author-name` etc. Use `pyscript create --help` for more information.\n\nThe following files will be created:\n\n- `index.html`: start page for the project\n- `pyscript.toml`: project metadata and config file\n- `main.py`: a \"Hello world\" python starter module\n\n#### Use --wrap to embed a python file OR a command string\n\n- ##### Embed a Python script into a PyScript HTML file\n\n```shell\n$ pyscript create --wrap <filename.py>\n```\n\nThis will generate a project i.e. a new directory named `filename` under the current directory.\n\nSimilar to the above, interactive prompts will further ask for metadata information.\n\nThe following files will be created:\n\n- `index.html`: start page for the project\n- `pyscript.toml`: project metadata and config file\n- `main.py`: contains code of `filename.py`\n\nThis can be overridden with the `-o` or `--output` option:\n\n```shell\n$ pyscript create --wrap <filename.py> -o <another_filename.html>\n```\n\ni.e. the HTML file created in the above directory will now be named `another_filename.html`\n\n- ##### Very simple command examples with `--command` option\n\nThe `-c` or `--command` option can be used to demo very simple cases.\n\nBy default, the name of the project folder created will be `pyscript-command-app` with the HTML file named `index.html`.\n\n`-o/--output` option can be used with the `-c/--command` option to configure name of the project folder as well\nas the name of the resulting HTML file.\n\n```shell\n$ pyscript create --wrap -c 'print(\"Hello World!\")' -o <output_filename.html>\n```\n\nThis will generate a project i.e. a new directory named `output_filename` under the current directory.\n\nSimilar to the above, interactive prompts will further ask for metadata information.\n\nThe following files will be created:\n\n- `output_filename.html`: start page for the project\n- `pyscript.toml`: project metadata and config file\n- `main.py`: contains code of the command string passed via `-c/--command`\n",
    "bugtrack_url": null,
    "license": "Apache-2.0",
    "summary": "Command Line Interface for PyScript",
    "version": "0.3.3",
    "project_urls": {
        "Documentation": "https://docs.pyscript.net",
        "Examples": "https://pyscript.com/@examples",
        "Homepage": "https://pyscript.net",
        "Repository": "https://github.com/pyscript/pyscript-cli"
    },
    "split_keywords": [
        "pyscript",
        " cli",
        " pyodide",
        " micropython",
        " pyscript-cli"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "f2d81881edf3b8653cf2f3b8005704126c738c151b6f8168a5806ea61f1efb5f",
                "md5": "053b9389b2bf3b2a24475fe31c8d8f21",
                "sha256": "320383f38e9eec6515dbe0c184d4ad9d9c58e2c98fb82ec09e8d8b2e93c9e62f"
            },
            "downloads": -1,
            "filename": "pyscript-0.3.3-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "053b9389b2bf3b2a24475fe31c8d8f21",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9",
            "size": 15556,
            "upload_time": "2024-09-09T13:02:32",
            "upload_time_iso_8601": "2024-09-09T13:02:32.756388Z",
            "url": "https://files.pythonhosted.org/packages/f2/d8/1881edf3b8653cf2f3b8005704126c738c151b6f8168a5806ea61f1efb5f/pyscript-0.3.3-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "9d4dee8606f71049fe29666e5541f0dd1a4f861dd3a6824334fac3c5aec3e8d9",
                "md5": "fd8e4897eb6ed70615c1b7e09352084b",
                "sha256": "11fc64a3f187d8645c601ae6a80e3f0142e0dd9e0c5d3244b0ec508ca0d373f9"
            },
            "downloads": -1,
            "filename": "pyscript-0.3.3.tar.gz",
            "has_sig": false,
            "md5_digest": "fd8e4897eb6ed70615c1b7e09352084b",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9",
            "size": 20791,
            "upload_time": "2024-09-09T13:02:34",
            "upload_time_iso_8601": "2024-09-09T13:02:34.234258Z",
            "url": "https://files.pythonhosted.org/packages/9d/4d/ee8606f71049fe29666e5541f0dd1a4f861dd3a6824334fac3c5aec3e8d9/pyscript-0.3.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-09-09 13:02:34",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "pyscript",
    "github_project": "pyscript-cli",
    "travis_ci": false,
    "coveralls": true,
    "github_actions": true,
    "lcname": "pyscript"
}
        
Elapsed time: 0.39507s