The CLI tool
The CLI tool
Checking the requirements
$ neutrapy check
# Checks if neu-cli, poetry and pyoxidizer are installed
$ neutrapy check --python /path/to/python
# Specify the path to python used in the project
Creating a new project
$ neutrapy create --help
DESCRIPTION:
Create a new project.
USAGE:
neutrapy create --name STR [OPTIONS]
REQUIRED OPTIONS:
-n, --name <STR> - The name of the project. It's used to create
a directory under current directory, and
also the project name in
neutralinojs.config.json and pyproject.toml.
OPTIONAL OPTIONS:
--python <STR> - The path to the python executable.
Default: python
-v, --version <STR> - The version of the project. It's used in
neutralinojs.config.json and pyproject.toml.
Default: 0.1.0
-d, --description <STR> - The description of the project. Default: ''
-l, --license <STR> - The license of the project. Default: MIT
-t, --template <STR> - The template used to create the project.
Default: default
--force [BOOL] - Remove existing project directory and then
create. Default: False
--ext-loglevel <STR> - Default logging level for the python
extension. Default: INFO
-h, --help - Print help information for this command
This command will:
- Remove the existing project directory if
--forceis passed - Run
neu create <name>to create a neutralinojs project (A directory with<name>will be created under current directory) - Copy the template files to the project directory and replace the placeholders with the values passed to the command
- Create
neutrapy.tomlin the project directory with given configurations from the template and the values passed to the command -
Syncronize the
neutrapy.tomlto other configurations files, including:poetry.lockandrequirements.txt(for PyOxidizer to build the python extension)pyoxidizer.bzlfor PyOxidizer to build the python extension
Syncronizing the configurations
$ neutrapy sync
# Syncronize the neutrapy.toml to other configurations files
These configurations include:
pyproject.toml(items underpoetrysection inneutrapy.tomlwill be synced totool.poetrysection inpyproject.toml)neutralinojs.config.json(items underneutralinosection inneutrapy.tomlwill be synced toneutralinosection inneutralinojs.config.json)poetry.lockandrequirements.txt(for PyOxidizer to build the python extension)pyoxidizer.bzlfor PyOxidizer to build the python extension
Note
The best practice is to always modify neutrapy.toml and then run neutrapy sync to syncronize the configurations, except pyoxidizer.bzl which is generated by PyOxidizer.
Warning
To manage the python dependences for the python extension, do NOT use poetry add and poetry remove. Instead, use neutrapy add and neutrapy remove to add and remove python packages, so that they will be sync'ed to all the configuration files.
If you accidentally use poetry add and poetry remove, neutrapy sync will lose those dependencies.
Adding/Removing python packages
$ neutrapy add --help
DESCRIPTION:
Add a python dependency.
USAGE:
neutrapy add - LIST [OPTIONS]
REQUIRED OPTIONS:
POSITIONAL <LIST> - The names of the dependencies.
OPTIONAL OPTIONS:
-D, --dev [BOOL] - Add the dependencies to dev-dependencies.
Default: False
-E, --extras <LIST> - Extras to activate for the dependency.
Default: []
--optional [BOOL] - Add the dependencies as optional.
Default: False
--pyver <STR> - Python version for which the dependency must
be installed. Default: ''
--platform <STR> - Platform for which the dependency must be
installed. Default: ''
--source <STR> - Name of the source to use for the
dependency. Default: ''
--allow-prereleases [BOOL] - Allow prereleases. Default: False
--lock [BOOL] - Do not perform operations (only update the
lockfile). Default: False
-h, --help - Print help information for this command
$ neutrapy remove --help
DESCRIPTION:
Remove a python dependency.
USAGE:
neutrapy remove - LIST [OPTIONS]
REQUIRED OPTIONS:
POSITIONAL <LIST> - The names of the dependencies.
OPTIONAL OPTIONS:
-D, --dev [BOOL] - Remove the dependencies from
dev-dependencies. Default: False
-h, --help - Print help information for this command
Note
--pyver will be passed as --python to poetry add command.
Running the application
$ neutrapy run --help
DESCRIPTION:
Run current project.
See also: https://neutralino.js.org/docs/cli/neu-cli/#neu-run
USAGE:
neutrapy run [OPTIONS]
OPTIONAL OPTIONS:
--disable-auto-reload [BOOL] - Disables the auto-reloading feature.
Default: False
--frontend-lib-dev [BOOL] - Enables both frontend library's development
environment and Neutralinojs's development
evironment at the same time. Default: False
-- <LIST> - Sets additional CLI arguments for the
Neutralinojs application process.
Default: []
-h, --help - Print help information for this command
This will simply call neu run to run the application.
Building the application
$ neutrapy build --help
DESCRIPTION:
Build the project.
USAGE:
neutrapy build [OPTIONS]
OPTIONAL OPTIONS:
--force [BOOL] - Do not check if we need to do `neutrapy
sync` before building. Default: False
-h, --help - Print help information for this command
This will:
- Check if
neutrapy syncis needed (ifneutrapy.tomlis modified since lastneutrapy sync) if--forceis not passed - Build the python extension using PyOxidizer
- Modify the
neutralinojs.config.jsonto use the built python extension - Build the Neutralinojs application using
neu build - Restore the
neutralinojs.config.json - Copy the built python extension to the app directory (
./dist) underbackend - Copy the
neutrapy.tomlto the app directory for the backend to use