Skip to content

Commit d5b41c7

Browse files
samcunliffedstansbypaddyroddypre-commit-ci[bot]
authored
Rework README and move dev instructions to contributing (#481)
I've attempted to simplify the user-facing quick-start instructions. Not a huge fan of enumerated instructions and the optional (but cool) one-liner it doesn't really fit in 1. 2. 3.... Also it's a bit overkill to have a venv/conda environment just for cookiecutter itself. The cookiecutter docs recommend `pipx install`. I claim that we want to encourage `uvx` because it's fast and cool 😎 . I've spent a bit of effort trying to be clear but comments on clarity etc are very welcome. I also moved and merged the dev instructions into CONTRIBUTING so README is _**just**_ user-facing. And CONTRIBUTING is just dev. This addresses - #466 And two comments - #464 (comment) - #419 (comment) --------- Co-authored-by: David Stansby <[email protected]> Co-authored-by: Patrick J. Roddy <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 4a2687b commit d5b41c7

File tree

3 files changed

+99
-135
lines changed

3 files changed

+99
-135
lines changed

.markdownlint.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
---
2-
MD013: false
2+
# Markdown linting rules to ignore.
3+
MD013: false # line-length
4+
MD033: false # no-inline-html

CONTRIBUTING.md

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ To contribute a change, please:
2020

2121
1. Create a new branch (or fork if you're not in [@UCL-ARC/collaborations]).
2222
2. Modify an existing page, create a new one, or tweak the template. a. Run
23-
[pre-commit](https://pre-commit.com) which will lint your changes. b. Check
23+
[pre-commit] which will lint your changes. b. Check
2424
the tests pass if you modified the template (`pytest -s`).
2525
3. Open a _pull request_ (PR) with changes.
2626
4. Ask someone who did not contribute to the PR from [@UCL-ARC/collaborations]
@@ -29,6 +29,46 @@ To contribute a change, please:
2929
6. If changes are requested, the PR author should address the comments, and then
3030
ask for review again.
3131

32+
### Developing the cookiecutter template
33+
34+
We quite like installing cookiecutter as a [uv tool], so it's available globally:
35+
36+
```sh
37+
uv tool install cookiecutter
38+
```
39+
40+
To run cookiecutter using a specific branch of the template:
41+
42+
```sh
43+
cookiecutter gh:UCL-ARC/python-tooling --checkout <branch-name>
44+
```
45+
46+
If you have this repo locally (presumably the case if you're developing), you
47+
can instead run the following:
48+
49+
```sh
50+
cookiecutter /path/to/your/checkout/of/python-tooling --checkout <branch-name>
51+
```
52+
53+
You can omit the `--checkout` option if you're already on the
54+
branch you want to test.
55+
56+
### Developing the recommended tooling pages
57+
58+
Pages all live in the `docs/pages` sub-directory, and are written in markdown.
59+
60+
To build the webpage locally (for testing)
61+
62+
1. [Install jekyll]
63+
2. Run `bundle install` from the `docs/` directory of this repository to
64+
install dependencies.
65+
3. Run `bundle exec jekyll serve` from the root directory of this repository.
66+
This should fire up a local web server and tell you its address. By default
67+
the server will automatically refresh the HTML pages if any changes are made
68+
to the markdown sources.
69+
70+
See the [jekyll docs] for more info.
71+
3272
<!-- links here -->
3373

3474
<!-- prettier-ignore-start -->
@@ -37,5 +77,9 @@ To contribute a change, please:
3777
[open an issue]: https://github.com/UCL-ARC/python-tooling/issues/new/choose
3878
[Discussions tab]: https://github.com/UCL-ARC/python-tooling/discussions
3979
[Research software engineers]: https://society-rse.org/about/history
80+
[pre-commit]: https://pre-commit.com
4081
[@UCL-ARC/collaborations]: https://github.com/orgs/UCL-ARC/teams/collaborations
82+
[uv tool]: https://docs.astral.sh/uv/guides/tools
83+
[Install jekyll]: https://jekyllrb.com/docs/installation
84+
[jekyll docs]: https://jekyllrb.com/docs
4185
<!-- prettier-ignore-end -->

README.md

Lines changed: 51 additions & 133 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!-- markdownlint-disable MD033 MD041 -->
1+
<!-- markdownlint-disable MD041 -->
22
<div style="text-align: center;" align="center">
33
<img src="https://raw.githubusercontent.com/UCL-ARC/python-tooling/main/images/logo.svg" alt="UCL ARC Python tooling logo" width="120"/>
44
<h1> UCL ARC Python Recommendations</h1>
@@ -19,12 +19,61 @@ Python packages with our recommended tooling set up and ready to go.
1919
> package template (e.g., [`scikit-hep`](https://github.com/scikit-hep/cookie)),
2020
> we recommend using their template instead of this one.
2121
22+
## Tutorial
23+
24+
Some quick instructions for using our template are below.
25+
We also have a [tutorial](./tutorial.md) that has been presented in a couple of workshops aimed at researchers at UCL.
26+
27+
## Using our template
28+
29+
If you have [uv] installed, you can use our template with the following one-liner:
30+
31+
```sh
32+
uvx cookiecutter gh:ucl-arc/python-tooling --checkout latest
33+
```
34+
35+
Alternatively you can [install cookiecutter] (following the recommended instructions).
36+
Do this if you don't use [uv], or if you're likely to want to use cookiecutter again.
37+
38+
Then you'll need to run cookiecutter with our template:
39+
40+
```sh
41+
cookiecutter gh:ucl-arc/python-tooling --checkout latest
42+
```
43+
44+
When [cookiecutter] runs, it will ask you a series of questions to configure your project.
45+
Type the answer or hit return without typing anything to use the default option (shown in parenthesis).
46+
At the end, it will print some more follow-up information in the terminal for things like creating a remote repository and making a website for your package.
47+
48+
It will have created a directory for your project.
49+
You can see the structure with the `tree` command.
50+
In our example we've called our project `example-research-software-project`:
51+
52+
```sh
53+
ls -ltr | tail -n1 # Shows the last directory that was created
54+
tree example-research-software-project
55+
```
56+
57+
To work on your project, initialise a `git` repository and _install_ your new package editable mode.
58+
You probably want to do this in a [virtual environment](./docs/pages/virtual.md).
59+
The comments show how to do this in [uv] with `uv venv`:
60+
61+
```sh
62+
cd example-research-software-project
63+
git init
64+
# uv venv
65+
# source .venv/bin/activate
66+
uv pip install -e ".[dev]"
67+
```
68+
2269
<!-- links here -->
2370

2471
<!-- prettier-ignore-start -->
2572
[website]: https://github-pages.arc.ucl.ac.uk/python-tooling
2673
[UCL ARC]: https://ucl.ac.uk/arc
27-
[cookiecutter]: https://libraries.io/pypi/cookiecutter
74+
[cookiecutter]: https://cookiecutter.readthedocs.io/en/stable
75+
[install cookiecutter]: https://cookiecutter.readthedocs.io/en/stable/README.html#installation
76+
[uv]: https://docs.astral.sh/uv
2877
<!-- prettier-ignore-end -->
2978

3079
## Contributors
@@ -68,134 +117,3 @@ Python packages with our recommended tooling set up and ready to go.
68117
<!-- prettier-ignore-end -->
69118

70119
<!-- ALL-CONTRIBUTORS-LIST:END -->
71-
72-
## Using this template
73-
74-
Some quick instructions for using our template are below.
75-
We also have a detailed [tutorial](tutorial.md) that has been given in a couple of workshops geared towards researchers at UCL.
76-
The tutorial goes into much more pedagogical detail, it both describes using the template to create a package
77-
and how to use the newly created package with some of the tools included.
78-
79-
1. Install [cookiecutter] in a `uv venv` or `conda` environment (commented lines for
80-
`uv venv` example).
81-
82-
```sh
83-
# uv venv # creates a .venv directory wherever you are
84-
# source ./.venv/bin/activate
85-
uv pip install cookiecutter
86-
```
87-
88-
2. Run cookiecutter in the desired directory
89-
90-
```sh
91-
cookiecutter gh:ucl-arc/python-tooling --checkout latest
92-
```
93-
94-
If you have this repo locally (this may be the case if you are developing),
95-
you can run the following:
96-
97-
```sh
98-
cookiecutter /path/to/your/checkout/of/python-tooling --checkout latest
99-
```
100-
101-
3. A series of questions will pop up to configure the project. Type the answer
102-
or hit return to use the default option (shown in parenthesis).
103-
104-
Note that these project variables are defined in the `cookiecutter.json`
105-
file.
106-
107-
4. This will create a specific directory structure.
108-
109-
For example, for a project with the following variables:
110-
111-
```yaml
112-
project_name [Python Template]: PROJECT_NAME
113-
project_slug [python-template]: PROJECT_SLUG
114-
package_name [python_template]: PACKAGE_NAME
115-
```
116-
117-
5. To work on your project, initialise a Git repository and _install_ it in
118-
editable mode.
119-
120-
```sh
121-
cd PROJECT_SLUG
122-
git init
123-
uv pip install -e ".[dev]"
124-
```
125-
126-
6. Build your package
127-
128-
```sh
129-
python -m build
130-
```
131-
132-
## Notes for developers
133-
134-
<details><summary>Click to expand...</summary> <!-- markdownlint-disable-line MD033 -->
135-
136-
First, clone repository
137-
138-
- (Optional) Generate your SSH keys as suggested
139-
[here](https://docs.github.com/en/github/authenticating-to-github/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent)
140-
- (Optional) GitHub CLI as suggested
141-
[here](https://docs.github.com/en/authentication/connecting-to-github-with-ssh/adding-a-new-ssh-key-to-your-github-account?tool=cli)
142-
- Clone the repository by typing (or copying) the following line in a terminal
143-
at your selected path in your machine:
144-
145-
```sh
146-
git clone [email protected]:UCL-ARC/python-tooling.git
147-
cd python-tooling
148-
```
149-
150-
### Developing the cookiecutter template
151-
152-
- To create and remove your virtual environment
153-
154-
```sh
155-
uv venv
156-
source .venv/bin/activate
157-
# do your work
158-
deactivate
159-
```
160-
161-
- To run template in the same path of this repo. We do a test cookiecut of a
162-
dummy package and install it to ensure the template setup works.
163-
164-
```sh
165-
cookiecutter .
166-
cd python-template
167-
git init
168-
uv pip install -e ".[dev]"
169-
```
170-
171-
- To run cookiecutter using a specific branch of the template:
172-
173-
```sh
174-
cookiecutter https://github.com/UCL-ARC/python-tooling --checkout <branch-name>
175-
```
176-
177-
- To run the tests locally:
178-
179-
```sh
180-
pytest -s
181-
```
182-
183-
### Developing the recommended tooling pages
184-
185-
Pages all live in the
186-
[docs/pages](https://github.com/UCL-ARC/python-tooling/tree/main/docs/pages)
187-
sub-directory, and are written in markdown.
188-
189-
To build the webpage locally (for testing)
190-
191-
1. [Install jekyll](https://jekyllrb.com/docs/installation)
192-
2. Run `bundle install` from the `docs/` directory of this repository to
193-
install dependencies.
194-
3. Run `bundle exec jekyll serve` from the root directory of this repository.
195-
This should fire up a local web server and tell you its address. By default
196-
the server will automatically refresh the HTML pages if any changes are made
197-
to the markdown sources.
198-
199-
See the [jekyll docs](https://jekyllrb.com/docs) for more info.
200-
201-
</details>

0 commit comments

Comments
 (0)