Skip to content

Commit f88ecab

Browse files
committed
Updating to uv
1 parent 51ffb78 commit f88ecab

17 files changed

Lines changed: 1742 additions & 58 deletions

.devcontainer/Dockerfile

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
FROM ubuntu:latest
2+
3+
4+
RUN apt-get -y update \
5+
&& apt-get install -y --no-install-recommends \
6+
python3.12 \
7+
python3.12-dev \
8+
git \
9+
make \
10+
wget \
11+
vim \
12+
build-essential \
13+
openssh-client \
14+
ca-certificates \
15+
gnupg2 \
16+
&& rm -rf /var/lib/apt/lists/*
17+
18+
ARG USERNAME=ubuntu
19+
20+
USER $USERNAME
21+
WORKDIR /home/$USERNAME
22+
23+
24+
SHELL ["/bin/bash", "-c"]
25+
RUN set -o pipefail \
26+
&& wget -qO- https://astral.sh/uv/install.sh \
27+
| sh
28+
RUN set -o pipefail \
29+
&& wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.3/install.sh \
30+
| bash
31+
# Required as when using a mount with write permissions in a RUN command
32+
# it fails because of permission reasons.
33+
COPY --chown=ubuntu:ubuntu docs docs
34+
RUN source .nvm/nvm.sh \
35+
&& nvm install 24 \
36+
&& corepack enable yarn \
37+
&& cd docs \
38+
&& corepack use yarn \
39+
&& cd .. \
40+
&& rm -rf docs
41+
42+
ENV PATH="/home/$USERNAME/.local/bin/:$PATH"
43+
44+
RUN uv python install 3.11
45+
46+
RUN --mount=type=bind,source=uv.lock,target=uv.lock \
47+
--mount=type=bind,source=pyproject.toml,target=pyproject.toml \
48+
uv sync --no-install-project --no-install-workspace

.devcontainer/devcontainer.json

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
2+
// README at: https://github.com/devcontainers/templates/tree/main/src/python
3+
{
4+
"name": "Node+Python",
5+
"remoteUser": "ubuntu",
6+
"updateRemoteUserUID": true,
7+
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
8+
"build": {
9+
"dockerfile": "Dockerfile",
10+
"context": ".."
11+
},
12+
"customizations": {
13+
// Configure properties specific to VS Code.
14+
"vscode": {
15+
// Add the IDs of extensions you want installed when the container is created.
16+
"extensions": ["streetsidesoftware.code-spell-checker",
17+
"ms-toolsai.jupyter",
18+
"ms-toolsai.jupyter-renderers",
19+
"ms-python.python",
20+
"ms-python.vscode-pylance",
21+
"ms-python.vscode-python-envs",
22+
"ms-vscode.makefile-tools",
23+
"redhat.vscode-yaml",
24+
"tamasfe.even-better-toml"],
25+
"settings": {
26+
"python-envs.defaultEnvManager": "ms-python.python:venv"
27+
}
28+
}
29+
},
30+
"postStartCommand": "uv sync"
31+
}

.dockerignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
*
22
! docs/yarn.lock
33
! docs/package.json
4-
! docs/.yarnrc.yml
4+
! docs/.yarnrc.yml
5+
! uv.lock
6+
! pyproject.toml

.flake8

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[flake8]
2+
ignore = E266, E501, W503, W293
3+
max-line-length = 200
4+
select = B,C,E,F,W,T4,B9
5+
statistics = true
6+
count = true
7+
show_source = true

.python-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3.12

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,21 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1111

1212
- The documentation now has a `How-to` guide on `Tag CoNLL-U Files`.
1313
- The documentation now has a `How-to Tag Text` guide for Finnish and English.
14+
- Using [developer/dev containers](https://containers.dev/) of which the files for this can be found in the [.devcontainer folder](./.devcontainer). This will allow for easier on boarding and development consistency.
1415

1516
## Changed
1617

1718
- [./scripts/py2md.py](./scripts/py2md.py) script has been updated so that it works with the newest version of Python that [pydoc_markdown](https://github.com/NiklasRosenstein/pydoc-markdown) supports, which is version 3.11. This required upgrading `pydoc_markdown` from version `4.6.0` to `>=4.7` which did come with some breaking changes for this repository hence the updates to the script. With the release of [uv](https://docs.astral.sh/uv/) the Python package manager we have made use of it's ability to have script level isolated virtual environments therefore removing any `py2md` script specific requirements from the dev/tests requirements that this package requires, e.g. `pydoc_markdown` requirement has been removed and is `py2md` script specific requirement. This also means that the [makefile](./makefile) has been changed to reflect this through the command `create-api-docs` which has been changed but it's functionility and use is the same.
1819
- [github/workflows/documentation_check_build_deploy.yml](./.github/workflows/documentation_check_build_deploy.yml) has been added but this is a change to the original documentation build and deploy workflow. This workflow now uses [uv](https://docs.astral.sh/uv/) for managing Python as it runs the `py2md.py` script. It only deploys the documentation website when there are push events to the `main` branch rather than pull requests. In addition during the build test we save the build artifact, when we want to deploy we use that build artifact to save processing time.
1920
- Removed the `Docs_Docker.dockerfile` as we have setup a DevContainer that encompasses all of the requirements that this Dockerfile provides. Therefore the [makefile](./makefile) commands that correspond to building/serving the documentation have been updated, along with the [documentation](./CONTRIBUTING.md).
2021
- Removed the requirement for a docker container to validate the [CITATION.cff file](./CITATION.cff), now we use `uv tool run`, of which this has been documentated in [RELEASE_PROCESS.md](./RELEASE_PROCESS.md).
22+
- Using [uv](https://docs.astral.sh/uv/) as the Python package manager and the package build front and back end replacing setup tools for the build backend.
23+
- Setting the new version of PyMUSAS is through the [uv tool](https://docs.astral.sh/uv/guides/package/#updating-your-version) and this uses the version set in [./pyproject.toml](./pyproject.toml) rather than [./pymusas/__init__.py](./pymusas/__init__.py)
2124

2225
## Removed
2326

2427
- `Docs_Docker.dockerfile` - see the Changed section above for the reason.
28+
- `requirements.txt`, `dev_requirements.txt`, and `setup.cfg`. These files are no longer needed as we have moved to using [uv](https://docs.astral.sh/uv/) as the Python package manager, and using [./pyproject.toml](./pyproject.toml) to store all of the packages's requirements and build dependencies.
2529

2630
## [v0.3.0](https://github.com/UCREL/pymusas/releases/tag/v0.3.0) - 2022-05-04
2731

CONTRIBUTING.md

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,24 @@ The last part of any pull request is to update the [CHANGELOG](./CHANGELOG.md) w
2121

2222
### Changing / Updating Python requirements
2323

24-
If you are changing the Python requirements, this needs to be done in a few different places:
25-
26-
1. If it is a development only requirement, not required to run the core code base within [./pymusas](./pymusas), then update:
27-
* [./dev_requirements.txt](./dev_requirements.txt)
28-
* [./binder/environment.yml](./binder/environment.yml)
29-
* [The `tests` section of ./setup.cfg](./setup.cfg)
30-
2. If it is a requirement that is needed to run the core code base within [./pymusas](./pymusas), then update:
31-
* [./requirements.txt](./requirements.txt)
32-
* [./binder/environment.yml](./binder/environment.yml)
33-
* [The `install_requires` section of ./setup.cfg](./setup.cfg)
34-
35-
In all cases you may need to add this requirement to the `tool.isort` section `known_third_party` list of the [./pyproject.toml file.](./pyproject.toml)
24+
If you are changing/updating a core requirement i.e. a requirement needed to run `pymusas` see [#core](#core) else if it is only for development of the project see [#development](#development).
25+
26+
**Note**:
27+
28+
1. In all cases you may need to add this requirement to the `tool.isort` section `known_third_party` list of the [./pyproject.toml file.](./pyproject.toml).
29+
2. Add the requirement to [./binder/environment.yml](./binder/environment.yml)
30+
31+
#### Core
32+
33+
``` bash
34+
uv add REQUIREMENT
35+
```
36+
37+
#### Development
38+
39+
``` bash
40+
uv add --dev REQUIREMENT
41+
```
3642

3743
### Writing docstrings
3844
[A lot of this has been copied from the AllenNLP CONTRIBUTING guidelines, which I think are really great!](https://github.com/allenai/allennlp/blob/main/CONTRIBUTING.md)

README.md

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -104,37 +104,27 @@ To run locally first ensure you have the following tools installted locally:
104104
When developing on the project you will want to install the Python package locally in editable format with all the extra requirements, this can be done like so:
105105

106106
```bash
107-
pip install -e .[tests]
108-
```
109-
110-
For a `zsh` shell, which is the default shell for the new Macs you will need to escape with `\` the brackets:
111-
112-
```zsh
113-
pip install -e .\[tests\]
107+
uv sync
114108
```
115109

116110
### Running linters and tests
117111

118-
This code base uses flake8 and mypy to ensure that the format of the code is consistent and contain type hints. The flake8 settings can be found in [./setup.cfg](./setup.cfg) and the mypy settings within [./pyproject.toml](./pyproject.toml). To run these linters:
112+
This code base uses isort, flake8 and mypy to ensure that the format of the code is consistent and contain type hints. ISort and mypy settings can be found within [./pyproject.toml](./pyproject.toml) and the flake8 settings can be found in [./.flake8](./.flake8). To run these linters:
119113

120114
``` bash
121-
isort pymusas tests scripts
122-
flake8
123-
mypy
115+
make lint
124116
```
125117

126118
To run the tests with code coverage (**NOTE** these are the code coverage tests that the Continuos Integration (CI) reports at the top of this README, the doc tests are not part of this report):
127119

128120
``` bash
129-
coverage run # Runs the tests (uses pytest)
130-
coverage report # Produces a report on the test coverage
121+
make tests
131122
```
132123

133124
To run the [doc tests](https://docs.python.org/3/library/doctest.html), these are tests to ensure that examples within the documentation run as expected:
134125

135126
``` bash
136-
coverage run -m pytest --doctest-modules pymusas/ # Runs the doc tests
137-
coverage report # Produces a report on the doc tests coverage
127+
make doc-tests
138128
```
139129

140130
### Setting a different default python version

RELEASE_PROCESS.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ to `git@github.com:UCREL/pymusas.git` (or the `HTTPS` equivalent).
2323
set -x TAG 'v1.0.0'
2424
```
2525

26-
2. Update `pymusas/__init__.py` with the correct version and check that it matches the `TAG` environment variable you created in the first step.
26+
2. Use the uv tool to update the version within [./pyproject.toml](./pyproject.toml) and check that it matches the `TAG` environment variable you created in the first step. `uv version ${TAG}`
2727

2828
3. Update the `CHANGELOG.md` so that everything under the "Unreleased" section is now under a section corresponding to this release.
2929

binder/environment.yml

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,19 @@
11
name: pymusas
22
channels:
3-
- defaults
3+
- conda-forge
44
dependencies:
5-
- python=3.9
5+
- python=3.11
66
- pip
77
- pip:
88
- nbgitpuller # This is a special Binder requirement
99
- "spacy>=3.1.4"
10-
- "srsly>=2.4.1,<3.0.0"
11-
- "tqdm>=4.50.0,<5.0.0"
12-
- "requests>=2.13.0,<3.0.0"
13-
- "pytest>=6.0.0,!=7.1.0"
10+
- "srsly>=2.4.1,<3.0"
11+
- "tqdm>=4.50.0,<5.0"
12+
- "requests>=2.13.0,<3.0"
13+
- "pytest>=6.0,!=7.1.0,!=8.1.0"
1414
- "coverage[toml]>=6.0.0"
15-
- "responses>=0.16.0"
16-
- mypy==0.910
17-
- types-requests
18-
- "flake8>=3.8.0,<3.10.0"
19-
- "pydoc-markdown>=4.0.0,<4.6.0"
20-
- "isort>=5.5.4"
21-
- "click<8.1.0"
15+
- "responses>=0.25.7"
16+
- "mypy>=1.12"
17+
- "types-requests>=2.32.4.20250913"
18+
- "flake8>=3.8"
19+
- "isort>=6.0"

0 commit comments

Comments
 (0)