@@ -88,14 +88,13 @@ Below that table identifier are key/value pairs that
8888support configuration for that particular table.
8989
9090- Below ` [build-system] ` is considered a table in the toml language.
91- - Within the build-system table below requires = is a key.
92- - The associated value for requires is an array containing the value "hatchling".
91+ - Within the ` build-system ` table below ` requires = ` is a key.
92+ - The associated value for ` requires ` is an array containing the value ` "hatchling" ` .
9393
94- ``` toml
95- [build-system ] # <- this is a table
96- requires = [" hatchling" ] # requires = is a key and "hatchling" is a value contained within an array specified by square brackets [].
97-
98- ```
94+ :::{literalinclude} ../examples/pure-hatch/pyproject.toml
95+ :language: toml
96+ :lines: 1-2
97+ :::
9998
10099### How the pyproject.toml is used when you build a package
101100
@@ -160,11 +159,10 @@ what dependencies your package requires.
160159- ** Authors:** these are the original authors of the package. Sometimes the authors are different from the maintainers. Other times they might be the same.
161160- ** Maintainers:** you can choose to populate this or not. You can populate this using a list with a sub element for each author or maintainer name, email
162161
163- ``` toml
164- authors = [
165- {name = " A. Random Developer" , email = " author@example.com" }
166- ]
167- ```
162+ :::{literalinclude} ../examples/pure-hatch/pyproject.toml
163+ :language: toml
164+ :lines: 7-9
165+ :::
168166
169167- ** dependencies:** dependencies are optional but we strongly suggest you include them in your pyproject.toml. Dependencies will be installed by pip when your project is installed creating a better user-experience.
170168
@@ -194,21 +192,10 @@ To add dependencies to your build, add a `[project.optional-dependencies]` table
194192
195193Then specify dependency groups as follows:
196194
197- ```
198- [project.optional-dependencies]
199- tests = [
200- "pytest,
201- "pytest-cov"
202- ]
203- lint = [
204- "black",
205- "flake8"
206- ]
207- docs = [
208- "sphinx",
209- "pydata-sphinx-theme
210- ]
211- ```
195+ :::{literalinclude} ../examples/pure-hatch/pyproject.toml
196+ :language: toml
197+ :lines: 26-38
198+ :::
212199
213200Following the above example, you install dependencies like this:
214201
@@ -232,32 +219,10 @@ You can also setup sets of recursive dependencies. [See this blog post for more.
232219Below is an example build configuration for a Python project. This example
233220package setup uses ** hatchling** to build the [ package's sdist and wheels] ( python-package-distribution-files-sdist-wheel ) .
234221
235- ``` toml
236- [build-system ]
237- requires = [" hatchling" ]
238- build-backend = " hatchling.build"
239-
240- [project ]
241- name = " examplePy"
242- authors = [
243- {name = " Some Maintainer" , email = " some-email@pyopensci.org" },
244- ]
245- maintainers = [
246- {name = " All the contributors" },
247- ]
248- description = " An example Python package used to support Python packaging tutorials"
249- keywords = [" pyOpenSci" , " python packaging" ]
250- readme = " README.md"
251- classifiers = [
252- " Programming Language :: Python :: 3" ,
253- " License :: OSI Approved :: BSD License" ,
254- " Operating System :: OS Independent" ,
255- ]
256- dependencies = [
257- " dependency-package-name-1" ,
258- " dependency-package-name-2" ,
259- ]
260- ```
222+ :::{literalinclude} ../examples/pure-hatch/pyproject.toml
223+ :language: toml
224+ :lines: 1-24
225+ :::
261226
262227Notice that dependencies are specified in this file.
263228
@@ -278,32 +243,10 @@ of values. It has two keys that specify the build backend API and containing pac
2782431 . ` requires = `
2792441 . ` build-back-end = `
280245
281- ```
282- [build-system]
283- requires = ["setuptools>=61"]
284- build-backend = "setuptools.build_meta"
285-
286- [project]
287- name = "examplePy"
288- authors = [
289- {name = "Some Maintainer", email = "some-email@pyopensci.org"},
290- ]
291- maintainers = [
292- {name = "All the contributors"},
293- ]
294- description = "An example Python package used to support Python packaging tutorials"
295- keywords = ["pyOpenSci", "python packaging"]
296- readme = "README.md"
297- classifiers = [
298- "Programming Language :: Python :: 3",
299- "License :: OSI Approved :: BSD License",
300- "Operating System :: OS Independent",
301- ]
302- dependencies = [
303- "dependency-package-name-1",
304- "dependency-package-name-2",
305- ]
306- ```
246+ :::{literalinclude} ../examples/pure-setuptools/pyproject.toml
247+ :language: toml
248+ :lines: 1-24
249+ :::
307250
308251``` {note}
309252[Click here to read about our packaging build tools including PDM, setuptools, Poetry and Hatch.](/package-structure-code/python-package-build-tools)
0 commit comments