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: CONTRIBUTING.md
+54-33
Original file line number
Diff line number
Diff line change
@@ -18,8 +18,8 @@ or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any addi
18
18
Pull requests are welcome.
19
19
1. Fork the repository.
20
20
2. Make and test your changes (see Developer Guide below).
21
-
3. Run `python -m black .` to format the code (`python -m pip install black` if necessary).
22
-
4. Run `python -m pylint src` and check for no new errors or warnings (`python -m pip install pylint` if necessary).
21
+
3. Run `poetry run black sarif` to format the code.
22
+
4. Run `poetry run pylint sarif` and check for no new errors or warnings.
23
23
5. Raise Pull Request in GitHub.com.
24
24
25
25
# Developer Guide
@@ -29,41 +29,75 @@ Pull requests are welcome.
29
29
- You need Python 3.8 installed.
30
30
- This is the minimum supported version of the tool. Developing with a later version risks introducing type hints such as `list[dict]` that are not compatible with Python 3.8.
31
31
32
-
## Running without installing
32
+
Initialise Poetry by telling it where Python 3.8 is, e.g.
33
33
34
-
Use `run.py`. E.g.
35
34
```
36
-
python run.py ls "C:\temp\sarif_files"
35
+
# Windows - adjust to the path where you have installed Python 3.8.
36
+
poetry env use "C:\Python38\python.exe"
37
+
# Linux
38
+
poetry env use 3.8
37
39
```
38
40
39
-
## Package using `build`
41
+
This is not necessary if your system Python version is 3.8.
42
+
43
+
## Running locally in Poetry virtualenv
40
44
41
-
Install the [build](https://pypi.org/project/build/) package:
42
45
```
43
-
python -m pip install --upgrade build
46
+
poetry install
47
+
poetry run sarif <OPTIONS>
44
48
```
45
49
46
-
Run it on the source code:
50
+
To check that the right versions are being run:
47
51
```
48
-
python -m build
52
+
poetry run python --version
53
+
poetry run sarif --version
54
+
poetry run python -m sarif --version
49
55
```
50
56
51
-
Install the package built by `build` locally:
57
+
To see what executable is being run:
52
58
```
53
-
python -m pip install dist/sarif-*.whl
59
+
# Windows
60
+
poetry run cmd /c "where sarif"
61
+
# Linux
62
+
poetry run which sarif
54
63
```
55
64
56
-
## Install locally using `setuptools`
65
+
## Update dependency versions
66
+
67
+
Run `poetry update` to bump package versions in the `poetry.lock` file.
68
+
69
+
## Update product version
57
70
58
-
Run this in the base directory:
71
+
Change the `version = ` line in `pyproject.toml` for the new semantic version for your change.
72
+
73
+
To make sure you're paying attention, you need to change it in the test `test_version.py` as well.
74
+
75
+
## Run unit tests
59
76
```
60
-
python -m pip install .
77
+
poetry run pytest
78
+
```
79
+
80
+
## Package using `poetry build`
81
+
82
+
Run it on the source code:
83
+
```
84
+
poetry build
85
+
```
86
+
87
+
If you want, you can install the package built locally at system level (outside the Poetry virtual environment):
88
+
```
89
+
pip install dist/sarif-*.whl
90
+
```
91
+
92
+
To remove it again:
93
+
```
94
+
pip uninstall sarif-tools
61
95
```
62
-
`pip` uses a small shim `setup.py` to invoke `setuptools`. Then `setuptools` installs all runtime requirements and also installs `sarif`.
63
96
64
97
Note that there are two possible levels of installation:
65
98
66
99
### User installation
100
+
67
101
When you run `pip install` and `pip` doesn't have permissions to write to the Python installation's `site-packages` directory, probably because you are not running as an admin/superuser, the package is installed at "user" level only. You can run it using:
68
102
```
69
103
python -m sarif
@@ -81,28 +115,15 @@ When you run `pip install` and `pip` has permissions to write to the Python inst
81
115
sarif
82
116
```
83
117
84
-
## Running locally-installed sarif-tools
85
-
86
-
Run the installed package using the `python -m sarif` command:
87
-
```
88
-
python -m sarif ls "C:\temp\sarif_files"
89
-
```
90
-
If installed at system level, you can alternatively run the installed package using the `sarif command`.
91
-
```
92
-
sarif ls "C:\temp\sarif_files"
93
-
```
94
-
95
118
## Adding packages from pypi to the project
96
119
97
-
Add the package and its version to `install_requires` in `setup.cfg`.
120
+
Add the package and its latest version number (as minimum version) to `[tool.poetry.dependencies]` in `pyproject.toml`.
98
121
99
-
Then run this in the base directory to install the tool and all its requirements locally:
122
+
Then run this to update Poetry's lockfile.
100
123
```
101
-
pip install .
124
+
poetry update
102
125
```
103
126
104
-
You can also run `pip install <packagename>` before or after this, as you wish. But you need to add the dependency to `setup.cfg` to make sure that the packaged application depends on this dependency when other people install it.
105
-
106
127
## Adding resource files to the project
107
128
108
-
Add the glob to `MANIFEST.in`. This is read because `include_package_data` in `setup.cfg` is `True`.
129
+
Add the file within the `sarif` directory and it will be installed with the Python source. For example, `sarif/operations/templates/sarif_summary.html`.
0 commit comments