Skip to content

Commit 4434620

Browse files
committed
Fix: comments from review
1 parent c2e399f commit 4434620

File tree

1 file changed

+26
-15
lines changed

1 file changed

+26
-15
lines changed

tutorials/pyproject-toml.md

Lines changed: 26 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,12 @@ of your GitHub or GitLab repository.
3636

3737
In this lesson you will learn:
3838

39-
1. What a `pyproject.toml` file is
39+
1. More about the `pyproject.toml` file and how it's used to store different types of metadata about your package
4040
1. How to declare information (metadata) about your project to help users find and understand it on PyPI.
4141

4242
If you wish to learn more about the `pyproject.toml` format, [check out this page. ](../package-structure-code/pyproject-toml-python-package-metadata.md)
4343
:::
4444

45-
<!-- TODO:Friends - As you are reviewing ...as a beginner is this TLDR too technical when you have no idea what the elements in it are? or is it a nice summary? -->
46-
47-
4845
:::{dropdown} Click for lesson highlights
4946
:color: secondary
5047
:icon: unlock
@@ -79,14 +76,16 @@ The TOML format can be compared to other structured formats such as`.json`. Howe
7976

8077
The **pyproject.toml** file is written in [TOML (Tom's Obvious, Minimal Language) format](https://toml.io/en/). TOML is an easy-to-read structure that is founded on key/value pairs. Each section in the **pyproject.toml** file contains a `[table identifier]`.
8178

82-
Below you can see the build-system table. Within
83-
that table there is one key/value pair.
79+
Below you can see the `[build-system]` table. Within
80+
that table there are two required key/value pairs.
8481

85-
`requires =` is the key and the value is `["hatchling"]`.
82+
`requires =` is the key and the value is `["hatchling"]` within the `[build-system]` array specified by square brackets [].
8683

8784
```toml
8885
[build-system] # <- this is a table
89-
requires = ["hatchling"] # requires = is a key and "hatchling" is a value contained within an array specified by square brackets [].
86+
requires = ["hatchling"]
87+
# The build backend defines the tool that should be used to build your package distribution files.
88+
build-backend = "hatchling.build"
9089
```
9190

9291

@@ -285,12 +284,16 @@ dependencies = ["numpy", "requests", "pandas", "pydantic"]
285284
```
286285

287286
:::{admonition} Pin dependencies with caution
288-
Pinnning dependencies refers to specifying a specific version of a dependency like this `numpy == 1.0`. In some specific cases, you may chose to pin or specify a lower or upper bound of a specific package. You can do that using syntax like this:
287+
Pinning dependencies refers to specifying a specific version of a dependency like this `numpy == 1.0`. In some specific cases, you may chose to pin or specify a lower or upper bound of a specific package.
288+
289+
You can declare a lower bound using syntax like this:
289290

290291
`ruamel-yaml>=0.17.21`
291292

293+
[Learn more about various ways to specify ranges of package versions here.](https://packaging.python.org/en/latest/specifications/version-specifiers/#id5)
294+
292295
Note that unless you are building an application, you want to be cautious about pinning dependencies. This is because
293-
users will be installing your package into various environments. A pinned dependency can make resolving an environment more challenging. As such only pin dependencies to a specific version if you absolutely need to do so.
296+
users will be installing your package into various environments. A pinned dependency can make resolving an environment more challenging to resolve. As such only pin dependencies to a specific version or bound if you absolutely need to do so.
294297

295298
One build tool that you should be aware of that pins dependencies by default is Poetry. [Read more about how to safely add dependencies with Poetry, here.](../package-structure-code/python-package-build-tools.html#challenges-with-poetry)
296299
:::
@@ -320,6 +323,8 @@ description = "Tools that update the pyOpenSci contributor and review metadata t
320323
authors = [{ name = "Firstname lastname", email = "email@pyopensci.org" }]
321324
maintainers = [{ name = "Firstname lastname", email = "email@pyopensci.org" }, { name = "Firstname lastname", email = "email@pyopensci.org" }]
322325

326+
requires-python = ">=3.10"
327+
323328
classifiers = [
324329
"Development Status :: 4 - Beta",
325330
"Intended Audience :: Developers",
@@ -340,14 +345,11 @@ Once you have those files, you can add them to your pyproject.toml file as
340345
links following the example below.
341346

342347

343-
```
344-
requires-python = ">=3.10"
348+
```toml
345349
readme = "README.md"
346350
license = {file = 'LICENSE'}
347351
```
348352

349-
and a `requires-Python = ">=3.10"` that is important to have for pip.
350-
351353
## Add the `[project.urls]` table
352354

353355
Finally, add the project.urls table to your
@@ -366,6 +368,10 @@ pyproject.toml file.
366368
"Source" = "https://github.com/pyopensci/pyosmeta/"
367369
```
368370

371+
:::{tip}
372+
There are many other urls that you can add here. Check out the [README file here for an overview](https://github.com/patrick91/links-demo).
373+
:::
374+
369375
## Putting it all together - your completed pyproject.toml file
370376

371377
Below is an example of a complete `pyproject.toml` file that
@@ -378,7 +384,7 @@ build-backend = "hatchling.build"
378384

379385
[project]
380386
name = "pyosmeta"
381-
dynamic = ["version"]
387+
version = "0.1.0"
382388
description = "Tools that update the pyOpenSci contributor and review metadata that is posted on our website"
383389
authors = [{ name = "Firstname lastname", email = "email@pyopensci.org" }]
384390

@@ -529,3 +535,8 @@ You now have all of the skills that you need to publish
529535
your package to PyPI.
530536

531537
If you also want to publish your package on conda-forge (which is a channel within the conda ecosystem), you will learn how to do that in the next lesson.
538+
539+
540+
:::{todo}
541+
Really good resources frm jeremiah https://daniel.feldroy.com/posts/2023-08-pypi-project-urls-cheatsheet useful (and the linked links-demo even more so)
542+
:::

0 commit comments

Comments
 (0)