@@ -88,14 +88,13 @@ Below that table identifier are key/value pairs that
88
88
support configuration for that particular table.
89
89
90
90
- 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" ` .
93
93
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
+ :::
99
98
100
99
### How the pyproject.toml is used when you build a package
101
100
@@ -160,11 +159,10 @@ what dependencies your package requires.
160
159
- ** Authors:** these are the original authors of the package. Sometimes the authors are different from the maintainers. Other times they might be the same.
161
160
- ** 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
162
161
163
- ``` toml
164
- authors = [
165
- {
name =
" A. Random Developer" ,
email =
" [email protected] " }
166
- ]
167
- ```
162
+ :::{literalinclude} ../examples/pure-hatch/pyproject.toml
163
+ :language: toml
164
+ :lines: 7-9
165
+ :::
168
166
169
167
- ** 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.
170
168
@@ -194,21 +192,10 @@ To add dependencies to your build, add a `[project.optional-dependencies]` table
194
192
195
193
Then specify dependency groups as follows:
196
194
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
+ :::
212
199
213
200
Following the above example, you install dependencies like this:
214
201
@@ -232,32 +219,10 @@ You can also setup sets of recursive dependencies. [See this blog post for more.
232
219
Below is an example build configuration for a Python project. This example
233
220
package setup uses ** hatchling** to build the [ package's sdist and wheels] ( python-package-distribution-files-sdist-wheel ) .
234
221
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 =
" [email protected] " },
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
+ :::
261
226
262
227
Notice that dependencies are specified in this file.
263
228
@@ -278,32 +243,10 @@ of values. It has two keys that specify the build backend API and containing pac
278
243
1 . ` requires = `
279
244
1 . ` build-back-end = `
280
245
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 = "[email protected] "},
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
+ :::
307
250
308
251
``` {note}
309
252
[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