You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/building-projects/build_steps.md
+10-11Lines changed: 10 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -17,9 +17,9 @@ $ view build
17
17
18
18
This will export your app into a static folder called `build`, which can then be served via something like [http.server](https://docs.python.org/3/library/http.server.html). An exported route cannot contain:
19
19
20
-
- Route Inputs
21
-
- Path Parameters
22
-
- A method other than `GET`
20
+
-Route Inputs
21
+
-Path Parameters
22
+
-A method other than `GET`
23
23
24
24
As stated above, you can also build your app programatically via `build_app`:
25
25
@@ -37,7 +37,7 @@ build_app(app)
37
37
38
38
## Build Steps
39
39
40
-
Instead of exporting static HTML, you might just want to call some build script at runtime for your app to use. For example, this could be something like a [Next.js](https://nextjs.org) app, which you want to use as the UI for your website. Each different build is called a **build step** in View. View's build system does not aim to be a full fledged build system, but instead a bridge to use other package managers or tools to build requirements for your app. It tries to be *extendable*, instead of batteries-included.
40
+
Instead of exporting static HTML, you might just want to call some build script at runtime for your app to use. For example, this could be something like a [Next.js](https://nextjs.org) app, which you want to use as the UI for your website. Each different build is called a **build step** in View. View's build system does not aim to be a full fledged build system, but instead a bridge to use other package managers or tools to build requirements for your app. It tries to be _extendable_, instead of batteries-included.
41
41
42
42
To specify a build step, add it under `build.steps` in your configuration. A build step should contain a list of requirements under `requires` and a `command`:
As you've seen above, build requirements are specified via the `requires` value. Out of the box, view.py supports a number of different build tools, compilers, and interpreters. To specify a requirement for one, simply add the name of their executable (*i.e.*, how you access their CLI). For example, since `pip` is accessed via using the `pip` command in your terminal, `pip` is the name of the requirement.
125
+
As you've seen above, build requirements are specified via the `requires` value. Out of the box, view.py supports a number of different build tools, compilers, and interpreters. To specify a requirement for one, simply add the name of their executable (_i.e._, how you access their CLI). For example, since `pip` is accessed via using the `pip` command in your terminal, `pip` is the name of the requirement.
126
126
127
127
However, view.py might not support checking for a command by default (this is the case if you get a `Unknown build requirement` error). If so, you need a custom requirement. If you would like to, you can make an [issue](https://github.com/ZeroIntensity/view.py/issues) requesting support for it as well.
128
128
129
129
### Custom Requirements
130
130
131
131
There are four types of custom requirements, which are specified by adding a prefix to the requirement name:
132
132
133
-
- Importing a Python module (`mod+`)
134
-
- Executing a Python script (`script+`)
135
-
- Checking if a path exists (`path+`)
136
-
- Checking if a command exists (`command+`)
133
+
-Importing a Python module (`mod+`)
134
+
-Executing a Python script (`script+`)
135
+
-Checking if a path exists (`path+`)
136
+
-Checking if a command exists (`command+`)
137
137
138
138
For example, the `command+gcc` would make sure that `gcc --version` return `0`:
The above could actually be used via both `script+check_310.py` and `mod+check_310`.
166
+
The above could actually be used via both `script+check_310.py` and `mod+check_310`.
167
167
168
168
!!! tip
169
169
170
170
Don't use the view.py build system to check the Python version or if a Python package is installed. Instead, use the `dependencies` section of a `pyproject.toml` file, or [PEP 723](https://peps.python.org/pep-0723/) script metadata.
171
171
172
-
173
172
## Review
174
173
175
174
View can build static HTML with the `view build` command, or via `view.build.build_app`. Build steps in view.py are used to call external build systems, which can then in turn be used to build things your app needs at runtime (such as static HTML generated by [Next.js](https://nextjs.org)). Builds can run commands, Python scripts, or both.
0 commit comments