File: dev_setup.md

package info (click to toggle)
python-azure 20230112%2Bgit-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 749,544 kB
  • sloc: python: 6,815,827; javascript: 287; makefile: 195; xml: 109; sh: 105
file content (63 lines) | stat: -rw-r--r-- 2,859 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# Run SDK tests

This document describes how to create a dev environment in order to run SDK tests
or execute the various commands available in the toolbox.

## Set up a virtual environment

1.  If you don't already have it, install Python:

    - Windows: [Python website][python_website] or from the [Windows store][python_39]
    - Ubuntu/Debian `sudo apt-get install python3`
    - RHEL/CentOS `sudo yum install python3`

    Python is also available in Bash for Windows natively.

2.  Clone the repository and go to the folder

    ```
    git clone https://github.com/Azure/azure-sdk-for-python.git
    cd azure-sdk-for-python
    ```

3.  Create a [virtual environment][virtual_environment]

    You can initialize a virtual environment this way:

    ```
    python -m venv env # Might be "python3" or "py -3.6" depending on your Python installation
    source env/bin/activate      # Linux shell (Bash, ZSH, etc.) only
    ./env/scripts/activate       # PowerShell only
    ./env/scripts/activate.bat   # Windows CMD only
    ```

4. Setup your development environment

    Install the development requirements for a specific library (located in the `dev_requirements.txt` file at the root of the library), [Tox][tox], [Tox monorepo][tox_monorepo] and an editable install of your library. For example, to install requirements for `azure-ai-formrecognizer`:
    ```
    azure-sdk-for-python> cd sdk/formrecognizer/azure-ai-formrecognizer
    azure-sdk-for-python/sdk/formrecognizer/azure-ai-formrecognizer> pip install -r dev_requirements.txt
    azure-sdk-for-python/sdk/formrecognizer/azure-ai-formrecognizer> pip install tox tox-monorepo
    azure-sdk-for-python/sdk/formrecognizer/azure-ai-formrecognizer> pip install -e .
    ```

5.  Create a .env file to store your secrets.

    The recommended place to store your .env file is one directory higher than the `azure-sdk-for-python` location.
    This ensures the secrets will be loaded by the interpreter and most importantly not be committed to Git history.

## Set up the SDK's test-running tool

SDK tests use an in-house tool called the test proxy, which runs in a container and enables recording and playing back HTTP interactions.

Follow the instructions in the [Perform one-time test proxy setup][proxy_setup] section of [tests.md][tests] to set up the test proxy on your machine.


<!-- LINKS -->
[python_website]: https://www.python.org/downloads/
[python_39]: https://www.microsoft.com/p/python-39/9p7qfqmjrfp7
[proxy_setup]: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/tests.md#perform-one-time-test-proxy-setup
[tests]: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/tests.md
[tox]: https://tox.readthedocs.io/en/latest/
[tox_monorepo]: https://pypi.org/project/tox-monorepo/
[virtual_environment]: https://docs.python.org/3/tutorial/venv.html