Skip to content

Commit 9d1cd37

Browse files
authored
Merge pull request #1058 from quarto-dev/render-dependencies
2 parents a59b3f4 + 3fd02aa commit 9d1cd37

File tree

12 files changed

+4807
-453
lines changed

12 files changed

+4807
-453
lines changed

.env

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
PIPENV_VENV_IN_PROJECT=1

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@
99
*_cache/
1010
/env/
1111
/_site/
12+
/.venv/
1213

1314

1415
/.luarc.json
16+
17+
# Use pipenv to manage dependencies
18+
# so we don't want to track this file in git
19+
requirements.txt

DESCRIPTION

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
Type: quarto-web
2+
Description: Quarto Web project for quarto.org
3+
Depends:
4+
broom,
5+
dplyr,
6+
DT,
7+
dygraphs,
8+
fs,
9+
ggplot2,
10+
htmltools,
11+
knitr,
12+
leaflet,
13+
openintro,
14+
palmerpenguins,
15+
readr,
16+
renv,
17+
reticulate,
18+
rmarkdown,
19+
shiny,
20+
tidyverse,
21+
webshot2,
22+
yaml

Pipfile

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
[[source]]
2+
url = "https://pypi.org/simple"
3+
verify_ssl = true
4+
name = "pypi"
5+
6+
[packages]
7+
jupyter = "*"
8+
colorama = {version = "*", markers="sys_platform == 'win32'"}
9+
pywin32 = {version = "*", markers="sys_platform == 'win32'"}
10+
pywinpty = {version = "*", markers="os_name == 'nt'"}
11+
appnope = {version = "*", markers="sys_platform == 'darwin'"}
12+
pexpect = {version = "*", markers="sys_platform != 'win32'"}
13+
ptyprocess = {version = "*", markers="sys_platform != 'win32'"}
14+
matplotlib = "*"
15+
ipython = "*"
16+
tabulate = "*"
17+
great-tables = "*"
18+
pandas = "*"
19+
altair = "*"
20+
seaborn = "*"
21+
numpy = "*"
22+
ipyleaflet = "*"
23+
vega-datasets = "*"
24+
itables = "*"
25+
shiny = "*"
26+
plotly = "*"
27+
pathlib = "*"
28+
nbformat = "*"
29+
30+
[dev-packages]
31+
32+
[requires]
33+
python_version = "3.12"
34+
python_full_version = "3.12.1"

Pipfile.lock

Lines changed: 2215 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,81 @@ This is the repo for the documentation hosted at [quarto.org](https://quarto.org
66

77
Please report issues on quarto.org by opening a "Documentation Issue" in the `quarto-dev/quarto-cli` repository: [New Issue](https://github.com/quarto-dev/quarto-cli/issues/new/choose)
88

9+
## Contributing
10+
11+
This section discusses how to contribute to the documentation by rendering a document locally.
12+
13+
### Quarto-web uses a frozen state of computation
14+
15+
This Quarto project uses `freeze: true`, meaning it will never run computation engines during a project render. No Knitr or Jupyter configuration is needed to build the whole website. The `_freeze` folder is tracked on the git repo for this purpose. (See about [freeze](https://quarto.org/docs/projects/code-execution.html#freeze) for a reminder of how this works).
16+
17+
What is the impact if you modify (or add) a document:
18+
19+
- If you modify a document that doesn't use any computation (i.e default `engine: markdown` is used), committing only the changes in the document is enough.
20+
- If you modify a document that uses `engine: knitr` or `engine: jupyter`, you need to render the document locally and commit the changes in the `_freeze` folder as well. See [incremental render](https://quarto.org/docs/projects/code-execution.html#incremental-render).
21+
22+
### Rendering the whole website
23+
24+
To render the whole website locally, you can use the following command:
25+
26+
```bash
27+
# Update freeze state if needed
28+
quarto render /docs/path/to/modified-or-added-document.qmd
29+
# Render the whole website using freeze state for all the other docs
30+
quarto render
31+
```
32+
33+
### Installing and managing computation environment
34+
35+
To manage computational dependencies this project uses
36+
37+
- **renv** for the R environment (https://rstudio.github.io/renv/) - it will be installed automatically first time the project is run with R.
38+
- **pipenv** for the Python environment (https://pipenv.pypa.io/en/latest/) - Please install pipenv manually if you don't have it yet.
39+
40+
#### R environment for Knitr engine
41+
42+
This project uses R 4.3.2 and **renv** to manage its R dependencies. To install the R environment, you can use the following command at the project root:
43+
44+
```bash
45+
Rscript -e "renv::restore()"
46+
```
47+
48+
The project library will be located under the `renv` folder.
49+
50+
You don't need to worry about the R environment when you are working on this project. **renv** sets up `.Rprofile` to activate the project library when R is ran from the project's root. Just run your R code as usual, and **renv** will be activated automatically, meaning R will correctly use the project's library.
51+
52+
If you are adding a new document that may use a new package, follow these steps:
53+
54+
- Dependencies are explicitly declared in `DESCRIPTION` file. So add the new package to the list.
55+
- Run `renv::install('package_name')` to add the new package to project library, and render your document to test everything is working fine.
56+
- Run `renv::snapshot()` to update the `renv.lock` file with the new package and its dependencies.
57+
- Commit the modified `DESCRIPTION` and `renv.lock` files with your document change (don't forget any change in the `_freeze` folder if needed).
58+
59+
**Note: Python dependencies are not tracked through renv but are tracked with pipenv.** See below
60+
61+
#### Python environment for Jupyter engine and Knitr through reticulate
62+
63+
This project uses **pipenv** (https://pipenv.pypa.io/zh-cn/stable/index.html) to handle the Python dependencies. **pipenv** takes care of managing dependencies and virtual environments for you.
64+
65+
To install the Python environment, you can use the following command at the project root:
66+
67+
```bash
68+
pipenv sync
69+
```
70+
71+
If you are using `pyenv` to manage your python installation, `pipenv` will ask you to install a newer version of python if the one currently used does not match the one from `Pipfile.lock`. Though, the exact match of version isn't required and this should not be a problem to not upgrade your python installation.
72+
73+
The virtual environment will be located in the project directory under `.venv` (following the configuration of `pipenv` set in the `.env` file).
74+
75+
When in the root of the project, you can run `pipenv shell` to activate the virtual environment associated with the project. Any `quarto` command should then use the correct python environment.
76+
You can also run `pipenv run quarto ...` to run the `quarto` command in the virtual environment without activating it.
77+
78+
Inside VSCODE, The Python extension should find the same Python version (e.g. Python > Select Interpreter) which Quarto Preview uses. As this extension integrates also in the terminal, it should use the same Python version in the terminal as well without needing to use `pipenv shell` or `pipenv run`.
79+
80+
If you are adding a new document that may use a new package, follow these steps:
81+
82+
- Run `pipenv install <package_name>` to add the new package to the project. It will update the `Pipfile` and `Pipfile.lock` files with the new package and its dependencies.
83+
- `Pipfile` could be manually edited but using the command is recommended.
84+
- Commit the modified `Pipfile` and `Pipfile.lock` files with your document changes (don't forget any changes in the `_freeze` folder if needed).
85+
86+
Documents running python with the Knitr engine will go through **reticulate**. **reticulate** will use the python version defined with `pipenv` when a `PipFile` is present. So, it will use the Python version from `.venv` --- no specific configuration is needed as [reticulate's python discovery mechanism](https://rstudio.github.io/reticulate/articles/versions.html#order-of-discovery) will find it.

0 commit comments

Comments
 (0)