Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 13 additions & 17 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,27 +43,23 @@ jobs:
steps:
- uses: actions/checkout@v6

- name: Install uv
uses: astral-sh/setup-uv@v6
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: "3.12"

- name: Install pre-commit
run: pip install pre-commit==4.2.0

- name: Ruff
run: uvx ruff@0.12.7 check dspace_rest_client tests
run: pre-commit run ruff --all-files

- name: Pylint
run: >-
uvx --with requests --with pysolr pylint@3.3.7
--rcfile=pyproject.toml dspace_rest_client

typecheck:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6

- name: Install uv
uses: astral-sh/setup-uv@v6
run: pre-commit run pylint --all-files

# Non-blocking: strict typing is being introduced incrementally, so a
# mypy finding is reported in the log but does not fail the job. The
# version is pinned by the mirrors-mypy rev in .pre-commit-config.yaml.
- name: Mypy
# Non-blocking: strict typing is being introduced incrementally, so a
# mypy failure is reported but does not fail the (green) job.
continue-on-error: true
run: uvx --with requests --with pysolr mypy dspace_rest_client
run: pre-commit run mypy --all-files
12 changes: 11 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,26 @@ repos:
rev: v2.3.2
hooks:
- id: autopep8
files: ^(dspace_rest_client/|tests/)
args: ['-i', '--max-line-length=90', '--ignore=E402']
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.12.7
hooks:
- id: ruff
files: ^(dspace_rest_client/|tests/)
args: [--fix, --exit-non-zero-on-fix]
- repo: https://github.com/pylint-dev/pylint
rev: v3.3.7
hooks:
- id: pylint
exclude: ^tests/
files: ^dspace_rest_client/
args: ['-rn', '-sn', '--rcfile=pyproject.toml']
additional_dependencies: [requests, pysolr]
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v2.3.1
hooks:
- id: mypy
files: ^dspace_rest_client/
args: [dspace_rest_client]
pass_filenames: false
additional_dependencies: [requests, pysolr]
30 changes: 30 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,35 @@
# Changelog

### 0.2.0

Date: Unreleased

**Changes**

1. Migrated packaging and release builds from `setup.py` to `pyproject.toml`.
2. Raised the minimum supported Python version to 3.10 and added type checking.
3. Hardened UUID validation across every UUID-taking method (`get_dso`, `get_item`,
`get_resourcepolicy`, `create_resourcepolicy`, `get_owningCollection`): a `None`
or non-string argument is now logged and returns `None` instead of raising
`TypeError`.
4. A non-JSON `401`/`403` body no longer crashes the CSRF-refresh/retry path of
`api_post`, `api_post_uri`, `api_put`, `api_put_uri`, `api_delete`, `api_patch`
and `create_bitstream`.
5. `get_communities`, `get_collections` and `get_bundle_by_name` return `None` on a
failed or non-JSON response instead of raising `TypeError`.
6. `add_metadata` / `remove_metadata` return `None` (not the client) on invalid input.
7. Model attribute defaults moved from the class body into `__init__` as plain
instance attributes, so no instance can share (or mutate) a class-level
`links`, `embedded`, `metadata`, `checkSum` or `sections` dict. `Group()` /
`User()` and `EntityType()` accept a `None` API resource, and `Item.from_dso` /
`DSpaceObject(dso=...)` deep-copy metadata instead of aliasing it. Side effect:
`id` on a `DSpaceObject` (and its subclasses) and `label` on an `EntityType`
now default to `None` rather than raising `AttributeError` when the API
resource omits them.
8. `models.__all__` exports the full model surface re-exported by the package.
9. Moved direct Solr support to the documented `solr` optional dependency group;
`solr_query()` raises an actionable `RuntimeError` when the extra is missing.

### 0.1.10

Date: 2024-04-04
Expand Down
17 changes: 8 additions & 9 deletions MAINTAINING.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,12 @@ These notes are for maintenance of the Git / PyPI source and releases, rather th

All the tasks we need to do, in order, when releasing a new version:

1. - [ ] **Check the main branch!** - we should have all the changes we want to include merged/picked and tested
2. - [ ] **Update setup.py** - this might include other dependency or project description changes, but usually will just be a case of incrementing the version number, e.g. `0.1.9` -> `0.1.10`. Note the new number.
3. - [ ] **Update publish.sh** - this simple publish script performs the publish to PyPI and will need the new version number
4. - [ ] **Update CHANGELOG.md** - new versions go at the top of the file. See previous release blocks for formatting. I include a 'thanks' or 'reported by' attribution for PRs contributed or issues reported. The new version number from `setup.py` is used for the heading and the (future) PyPI URL
4. - [ ] **Commit release preparation** - once you are happy with the steps above, commit with a message like 'Prepare release 0.1.10'
5. - [ ] **Push branch** - making sure github is up to date, (in future: CI)
6. - [ ] **Clear out build and dist directories**: OPTIONAL, but nice to start with a clean Python build environment before making this new version
7. - [ ] **Run publish script** - this will run `setup.py` to build a new version then upload to PyPI with twine - you will be prompted for credentials interactively
1. - [ ] **Check the main branch** — confirm all intended changes are merged and CI is green.
2. - [ ] **Update `project.version` in `pyproject.toml`** — note the new version number.
3. - [ ] **Update `CHANGELOG.md`** — move the new version to the top, add the release date and future PyPI URL, and summarize user-visible changes.
4. - [ ] **Install release tools** — run `python -m pip install ".[release]"`.
5. - [ ] **Run tests and checks** — run `python -m pytest tests/ -v` and `pre-commit run --all-files`.
6. - [ ] **Commit and push release preparation** — use a message such as `Prepare release 0.2.0`, then confirm CI remains green.
7. - [ ] **Run `./publish.sh`** — it clears old artifacts, builds the sdist and wheel from `pyproject.toml`, validates them with Twine, and uploads them to PyPI. Twine prompts for credentials when needed.

TODO: If we just keep a `version` file around some of these steps can be more easily automated or derived instead of updated by hand, but for now it's all pretty simple.
The publish script derives artifact names from the build output, so it does not need a version-specific edit.
17 changes: 14 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# DSpace Python REST Client Library
This client library allows Python 3 scripts (Python 2 probably compatible but not officially supported) to interact with
This client library allows Python 3.10+ scripts to interact with
DSpace 7+ repositories, using the DSpace REST API.

This library is a work in progress and so far offers basic create, update, retrieve functionality for
Expand All @@ -15,8 +15,8 @@ PyPI homepage: https://pypi.org/project/dspace-rest-client/
* Working DSpace 7 repository with an accessible REST API

## Installation
To install with pip:
`pip install dspace_rest_client`
To install with pip:
`pip install dspace-rest-client`

(or `pip3` or `python -m pip` as appropriate to your environment)

Expand All @@ -27,6 +27,17 @@ cd dspace-rest-python
pip install .
```

### Solr support

Direct Solr queries require the optional `solr` dependency group:

```commandline
pip install "dspace-rest-client[solr]"
```

Without that extra, REST API operations remain available, but `solr_query()`
raises an error explaining how to install Solr support.


## Usage
After installing dependencies, you're ready to run the script.
Expand Down
Loading