Skip to main content
Version: 0.2.0

CLI

The PlayTorch CLI (i.e., torchlive-cli) provides a set of commands to help you install build dependencies, initialize new PlayTorch projects, build and deploy them to emulator or physical devices.

Prerequisites

  • Node.js: If you don't have it already, you can download Node.js LTS from its website or install via Homebrew (ie, brew install node).

Index

PlayTorch CLI commands

Below is a list of PlayTorch CLI commands and their usages:

Options

NameDescription
--versionPrints the CLI version
--helpShows the CLI help

npx torchlive-cli setup-dev

The PlayTorch CLI provides a setup routine to install all required build dependencies including tooling like Yarn, Watchman, and CocoaPods, SDKs like OpenJDK, Android SDK, Android SDK Manager, Android Virtual Device Manager, and an Android Emulator, and it installs a default emulator device ready to be used with PlayTorch projects.

npx torchlive-cli setup-dev
note

The command may require sudo access for installing the different dependencies and can take approximately 20 minutes to complete. This depends on your laptop configuration, internet speed, and what dependencies have been installed previously.

note

You only need to run the npx torchlive-cli setup-dev command once and it is not necessary to run the command every time before you start a new project. However, it is recommended to re-run this command once in a while to update development dependencies over time.

If everything goes well, the terminal will looks similar to the following output.

➜  npx torchlive-cli setup-dev
_ _ _ _
| |_ ___ _ __ ___| |__ | (_)_ _____
| __/ _ \| '__/ __| '_ \| | \ \ / / _ \
| || (_) | | | (__| | | | | |\ V / __/
\__\___/|_| \___|_| |_|_|_| \_/ \___|

torchlive version 0.0.2-alpha.19
✔ Homebrew (3.3.3)
✔ OpenJDK (1.8.0)
✔ Watchman (null)
↓ Node (16.13.0) [SKIPPED]
✔ Yarn (1.22.15)
✔ Android SDK
✔ Android SDK Manager
✔ Android Emulator
✔ CocoaPods (1.11.2)

npx-torchlive-cli init [options] [name]

Initialize a new PlayTorch project.

npx torchlive-cli init MyFirstProject

Options

NameDefaultDescription
--templatereact-native-template-pytorch-liveSpecifies the template used to generate a new project
--skip-installSkips dependencies installation step

npx torchlive-cli run-android [options]

Runs the PlayTorch project on an Android emulator. It will run the project on a physical device if it is connected.

npx torchlive-cli run-android
info

If you want to deploy the app on your own device, you have to put it into developer mode.

On Android 4.1 and lower, the Developer options screen is available by default. On Android 4.2 and higher, you must enable this screen. To enable developer options follow the instructions from the Android Developers docs: Enable developer options and USB debugging.

Options

NameDefaultDescription
--name, -n"pytorch_live"Run PlayTorch project on a specific Android Virtual Device (AVD)

npx torchlive-cli run-ios

Runs the PlayTorch project on an iOS simulator.

info

In order to run a PlayTorch project on an iOS simulator or a physical iOS device, you need to install Xcode from the Apple App Store on your macOS device. PlayTorch currently supports Xcode version 12.5 or later.

npx torchlive-cli run-ios

npx torchlive-cli emulator [options]

Starts the "pytorch_live" Android Virtual Device emulator.

npx torchlive-cli clean

Cleans the build files and directories.

npx torchlive-cli clean

npx torchlive-cli emulator

Starts the emulator without building, deploying, and running the PlayTorch project.

npx torchlive-cli emulator

npx torchlive-cli doctor

Runs health checks to verify if all necessary dependencies are installed.

npx torchlive-cli doctor
note

Run the npx torchlive-cli setup-dev command if any of the health checks fail.

npx torchlive-cli log

Prints the PlayTorch CLI logs to the terminal.

npx torchlive-cli log

npx torchlive-cli help [command]

Shows additional help for a command.

npx torchlive-cli help init