|
1 | 1 | # Contributor Guide
|
2 | 2 |
|
3 | 3 | ## Getting Started
|
| 4 | +Glad that you decided to make your contribution in Dash. This guide provides instructions to set up and build the Dash repository and describes best practices when contributing to the Dash repository. |
4 | 5 |
|
5 |
| -Glad that you decided to make your contribution in Dash, to set up your development environment, run the following commands: |
| 6 | +### Fork the Dash repository |
| 7 | +When contributing to the Dash repository you should always work in your own copy of the Dash repository. Create a fork of the `dev`-branch, to create a copy of the Dash repository in your own GitHub account. See official instructions for [creating a fork](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/fork-a-repo) if needed. |
| 8 | + |
| 9 | +Clone the forked repository (either of both options will work). Replace `<your_user_name>` with your user name. |
| 10 | +``` |
| 11 | +git clone https://github.com/<your_user_name>/dash.git |
| 12 | +``` |
| 13 | +or |
| 14 | +``` |
| 15 | +git clone [email protected]:<your_user_name>/dash.git |
| 16 | +``` |
| 17 | + |
| 18 | +When working on a new feature, always create a new branch and create the feature in that branch. For more best practices, read the [Git section](#git). |
| 19 | + |
| 20 | +## Building Dash |
| 21 | + |
| 22 | +### Windows configuration |
| 23 | +The scripts that run during the build process are designed for a Bash terminal. The default terminals on Windows systems are either PowerShell or Command Prompt. However, the build process will fail (potentially bricking you Node environment) when using these terminals. The listed commands should be executed from a Bash terminal, e.g. you can use the Git Bash terminal (which should be installed when installing Git under default settings). Otherwise, you need to find another way to access a Bash terminal. |
| 24 | + |
| 25 | +<details> |
| 26 | + |
| 27 | +<summary>Set up JavaScript environment (for JavaScript beginners)</summary> |
| 28 | + |
| 29 | +#### JavaScript introduction |
| 30 | + If you are new to JavaScript, many aspects of setting up a working environment and working with the new ecosystem can be a bit overwhelming. Especially if Plotly Dash is your first experience with the JavaScript ecosystem. This section is intended to help you set up your JavaScript environment so you can start working with Dash. When setting up JavaScript you will encounter terms as `nvm`, `Node`, and `npm` |
| 31 | + - `nvm` stands for Node Version Manager. This is a tool that allows you to manage Node installations. Quite convenient if you are working on multiple tools that require different versions of Node.js. `nvm` will allow you to switch between Node installations with a single command. `nvm` is not integrated in Windows so a third-party tool needs to be used. If you don't have one yet, you can start with [NVM for Windows](https://github.com/coreybutler/nvm-windows) (`nvm-windows`). This version manager is widely used and is well recommended. |
| 32 | + - `Node.js` is the actual JavaScript runtime environment. Visit the [official site](https://nodejs.org/en) for more info. Don't download Node just yet, install it through `nvm`. |
| 33 | + - `npm` stands for Node Package Manager. This is the largest software registry for JavaScript packages. Check the [official site](https://docs.npmjs.com/about-npm) for more info. |
| 34 | + |
| 35 | + #### JavaScript Installation |
| 36 | + Carefully follow the installation instructions on the [GitHub page](https://github.com/coreybutler/nvm-windows) for NVM for Windows. As recommended by the installation instructions there: uninstall any pre-existsing Node installations. You will run into permission errors otherwise. |
| 37 | + After NVM for Windows has been installed, open any terminal of your preference and install Node and npm: |
| 38 | + ``` |
| 39 | + nvm install latest |
| 40 | + ``` |
| 41 | + After installation is complete, activate the Node environment (**admin access required**) |
| 42 | + ``` |
| 43 | + nvm use latest |
| 44 | + ``` |
| 45 | + Confirm that the activation was successfull |
| 46 | + ``` |
| 47 | + node -v |
| 48 | + npm -v |
| 49 | + ``` |
| 50 | + If these commands are not recognized, close the terminal, re-open a new instance and retry. If the commands return a version number, you have set up your JavaScript environment successfully! |
| 51 | +</details> |
| 52 | + |
| 53 | +<details> |
| 54 | + <summary> Working with Pycharm </summary> |
| 55 | + |
| 56 | + If you work in Pycharm you can open the Dash repo directory as a project (`File -> Open` then browse search for the `dash` directory containing your dash repo, and open the directory as a project). You can configure your Python virtual environment using the Python Interpreter tool. Secondly, you can open the Git Bash terminal in Pycharm and it will automatically activate your selected Python Interpreter in the terminal. You can verify this by executing `pip --version` in the Git Bash terminal, it will show you the path from where pip is run, which is the path where your virtual environment is installed. If you follow these steps, you can skip the first few steps in the overview below. |
| 57 | +</details> |
| 58 | + |
| 59 | +### Build process |
| 60 | +The build process is mostly the same for Windows and Linux systems. Wherever there are differences between the operating systems, it is marked. |
| 61 | + |
| 62 | +Open a Bash terminal in the `dash` repository, Git Bash terminal for example on Windows: |
6 | 63 |
|
7 | 64 | ```bash
|
8 |
| -# in your working directory |
9 |
| -$ git clone [email protected]:plotly/dash.git |
10 |
| -$ cd dash |
11 |
| -$ python3 -m venv .venv/dev |
12 |
| -# activate the virtualenv |
13 |
| -# on windows `.venv\dev\scripts\activate` |
14 |
| -# on some linux / mac environments, use `.` instead of `source` |
15 |
| -$ source .venv/dev/bin/activate |
| 65 | +# Create and activate virtual environment |
| 66 | +#### LINUX #### |
| 67 | + $ python3 -m venv .venv/dev |
| 68 | + # on some linux / mac environments, use `.` instead of `source` |
| 69 | + $ source .venv/dev/bin/activate |
| 70 | +#### WINDOWS #### |
| 71 | + # Skip this if you manage the Python Interpreter via Pycharm. |
| 72 | + # Create and activate virtual environment |
| 73 | + $ python -m venv .venv/dev |
| 74 | + # on some linux / mac environments, use `.` instead of `source` |
| 75 | + $ source .venv/dev/scripts/activate |
| 76 | +######## |
| 77 | + |
16 | 78 | # install dash and dependencies
|
17 | 79 | $ pip install -e .[ci,dev,testing,celery,diskcache] # in some shells you need \ to escape []
|
| 80 | + |
| 81 | +# Do a clean install of all packages listed in package-lock.json. Package versions will be |
| 82 | +# exactly like stated in the file |
18 | 83 | $ npm ci
|
19 |
| -# this script will build the dash-core-components, dash-html-components, dash-table, |
| 84 | + |
| 85 | +# Build dash-core-components, dash-html-components, dash-table, |
20 | 86 | # and renderer bundles; this will build all bundles from source code in their
|
21 | 87 | # respective directories. The only true source of npm version is defined
|
22 | 88 | # in package.json for each package.
|
23 |
| -# |
24 |
| -$ npm run build # runs `renderer build` and `npm build` in dcc, html, table |
25 |
| -# build and install components used in tests |
26 |
| -# on windows, the developer will need to use `npm run first-build` this performs additional first steps |
27 |
| -# |
28 |
| -# Alternatively one could run part of the build process e.g. |
29 |
| -$ dash-update-components "dash-core-components" |
| 89 | +#### LINUX #### |
| 90 | + $ npm run build # runs `renderer build` and `npm build` in dcc, html, table |
| 91 | +#### WINDOWS #### |
| 92 | + # On Windows the build is done via the first-build script. This adds extra steps |
| 93 | + # that are automatically applied on Linux systems, but not on Windows systems. |
| 94 | + $ npm run first-build |
| 95 | +######## |
| 96 | + |
| 97 | +# When you first clone the repository, and check out a new branch, you must |
| 98 | +# run the full build as above. Later on, when you only work in one part of |
| 99 | +# the library, you could run part of the build process e.g. |
| 100 | +# $ dash-update-components "dash-core-components" |
30 | 101 | # to only build dcc when developing dcc
|
31 |
| -# But when you first clone check out a new branch, you must run the full build as above. |
32 |
| -# |
| 102 | + |
| 103 | +# Build and install components used in tests |
33 | 104 | $ npm run setup-tests.py # or npm run setup-tests.R
|
34 |
| -# you should see dash points to a local source repo |
| 105 | + |
| 106 | +# Verify that Dash is refering to a local source repo |
35 | 107 | $ pip list | grep dash
|
36 | 108 | ```
|
37 | 109 |
|
|
0 commit comments