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
35 changes: 32 additions & 3 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ jobs:
strategy:
fail-fast: false
matrix:
# Matches the DSpace-ISstag-integration consumer CI matrix; the library
# itself declares support for >=3.8 (see setup.py).
# Matches the DSpace-ISstag-integration consumer CI matrix.
python-version: ["3.10", "3.12"]

steps:
Expand All @@ -27,7 +26,7 @@ jobs:
python-version: ${{ matrix.python-version }}
cache: pip
cache-dependency-path: |
setup.py
pyproject.toml
requirements-test.txt

- name: Install package + test deps
Expand All @@ -38,3 +37,33 @@ jobs:

- name: Run tests
run: python -m pytest tests/ -v

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

- name: Install uv
uses: astral-sh/setup-uv@v6

- name: Ruff
run: uvx ruff@0.12.7 check dspace_rest_client tests

- 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

- 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
27 changes: 27 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Pre-commit hooks for local development. Mirrors the consumer repo
# (DSpace-ISstag-integration) so both repositories share one standard.
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
- id: check-json
- id: mixed-line-ending
args: ['--fix=lf']
- id: check-added-large-files
- repo: https://github.com/hhatto/autopep8
rev: v2.3.2
hooks:
- id: autopep8
args: ['-i', '--max-line-length=90', '--ignore=E402']
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.12.7
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
- repo: https://github.com/pylint-dev/pylint
rev: v3.3.7
hooks:
- id: pylint
exclude: ^tests/
args: ['-rn', '-sn', '--rcfile=pyproject.toml']
additional_dependencies: [requests, pysolr]
7 changes: 3 additions & 4 deletions MAINTAINING.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,11 @@ 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
2. - [ ] **Update `project.version` in pyproject.toml** - 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 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 `pyproject.toml` 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
7. - [ ] **Run publish script** - this will run `python -m build` (needs `pip install build twine`) to build the sdist and wheel from `pyproject.toml`, check them and upload `dist/*` to PyPI with twine - you will be prompted for credentials interactively

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.
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ Help with extending the scope and improving the code is always welcome!
PyPI homepage: https://pypi.org/project/dspace-rest-client/

## Requirements
* Python 3.x (developed using Python 3.8.5)
* Python Requests module (see `requirements.txt`)
* Python 3.8+
* Python Requests module (installed automatically; declared in `pyproject.toml`)
* Working DSpace 7 repository with an accessible REST API

## Installation
Expand All @@ -20,10 +20,11 @@ To install with pip:

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

To install manually, clone this repository and install the requirements:
To install manually, clone this repository and install the package:
```commandline
git clone https://github.com/the-library-code/dspace-rest-python.git
pip install -r requirements.txt
cd dspace-rest-python
pip install .
```


Expand Down
62 changes: 61 additions & 1 deletion dspace_rest_client/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,61 @@
from . import *
"""DSpace 7 REST API client."""

from typing import TYPE_CHECKING, Any

from .models import (
HALResource,
AddressableHALResource,
ExternalDataObject,
DSpaceObject,
SimpleDSpaceObject,
Item,
Community,
Collection,
Bundle,
Bitstream,
Group,
User,
InProgressSubmission,
WorkspaceItem,
EntityType,
RelationshipType,
License,
Label,
ResourcePolicy,
)

if TYPE_CHECKING:
from .client import DSpaceClient

__all__ = [
"DSpaceClient",
"HALResource",
"AddressableHALResource",
"ExternalDataObject",
"DSpaceObject",
"SimpleDSpaceObject",
"Item",
"Community",
"Collection",
"Bundle",
"Bitstream",
"Group",
"User",
"InProgressSubmission",
"WorkspaceItem",
"EntityType",
"RelationshipType",
"License",
"Label",
"ResourcePolicy",
]


def __getattr__(name: str) -> Any:
# client reads its env-based class defaults (DSPACE_API_ENDPOINT, PROXY_URL,
# ...) at import time, so it is imported on first use, never as a side
# effect of importing the package or one of its submodules
if name == "DSpaceClient":
from .client import DSpaceClient # pylint: disable=import-outside-toplevel
return DSpaceClient
raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
Loading
Loading