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: README.md
+8-2Lines changed: 8 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,6 +8,7 @@ This package contains common Python utility classes and functions.
8
8
* Decrypting values with KMS
9
9
* Encoding and decoding records using a given Avro schema
10
10
* Connecting to and querying a MySQL database
11
+
* Connecting to and querying a PostgreSQL database
11
12
* Connecting to and querying a PostgreSQL database using a connection pool
12
13
* Connecting to and querying Redshift
13
14
* Making requests to the Oauth2 authenticated APIs such as NYPL Platform API and Sierra
@@ -25,11 +26,16 @@ python3 -m venv testenv
25
26
source testenv/bin/activate
26
27
pip install --upgrade pip
27
28
pip install .
28
-
pip install '.[tests]'
29
+
pip install '.[development]'
29
30
deactivate && source testenv/bin/activate
30
31
```
31
32
32
-
Add any new dependencies required by code in the `nypl_py_utils` directory to the `dependencies` section of `pyproject.toml`. Add dependencies only required by code in the `tests` directory to the `[project.optional-dependencies]` section.
33
+
## Managing dependencies
34
+
In order to prevent dependency bloat, this package has no required dependencies. Instead, each class and helper file has its own optional dependency set. For instance, if an app needs to use the KMS client and the obfuscation helper, it should add `nypl-py-utils[kms-client, obfuscation-helper]` to the app's requirements. This way, only the required dependencies are installed.
35
+
36
+
When a new client or helper file is created, a new optional dependency set should be added to `pyproject.toml`. The `development` dependency set, which includes all the dependencies required by all of the classes and tests, should also be updated.
37
+
38
+
The optional dependency sets also give the developer the option to manually list out the dependencies of the clients rather than relying upon what the package thinks is required, which can be beneficial in certain circumstances. For instance, AWS lambda functions come with `boto3` and `botocore` pre-installed, so it's not necessary to include these (rather hefty) dependencies in the lambda deployment package.
33
39
34
40
### Troubleshooting
35
41
If running `main.py` in this virtual environment produces the following error:
0 commit comments