Skip to content

Commit 4f1874f

Browse files
rgommersdnicolodi
authored andcommitted
DOC: clean up front page and intro tutorial, state files must be in VCS
Closes gh-420
1 parent a331ed0 commit 4f1874f

File tree

2 files changed

+40
-87
lines changed

2 files changed

+40
-87
lines changed

docs/index.rst

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ meson-python
99

1010
.. highlights::
1111

12-
``meson-python`` is a Python build backend built on top of the Meson_
13-
build-system. It enables you to use Meson_ for your Python packages.
12+
``meson-python`` is a Python build backend built on top of the Meson
13+
build-system. It enables you to use Meson for your Python packages.
1414

1515

1616
Want to look at examples in real projects? Check out our curated list of
@@ -20,19 +20,12 @@ Want to look at examples in real projects? Check out our curated list of
2020
Where to start?
2121
===============
2222

23-
24-
New to Python packaging
25-
-----------------------
26-
2723
If you are new to Python packaging, we recommend you check our
2824
:ref:`tutorial-introduction` tutorial, which walks you through creating and
2925
releasing your first Python package.
3026

3127

32-
Experienced users
33-
-----------------
34-
35-
If you are already familiarized with Python packaging, we recommend you check
28+
If you are already familiar with Python packaging, we recommend you check
3629
our :ref:`how-to-guides-first-project` guide, which shows you how to quickly
3730
setup a ``meson-python`` project.
3831

@@ -55,10 +48,6 @@ free to open an issue on our bugtracker_.
5548
`discussion page`_ first.
5649

5750

58-
In addition, the `#meson-python`_ channel on the `PyPA Discord`_ may be useful
59-
for quick questions - one ``meson-python`` maintainer is active there.
60-
61-
6251
.. toctree::
6352
:caption: Tutorials
6453
:hidden:
@@ -117,7 +106,6 @@ for quick questions - one ``meson-python`` maintainer is active there.
117106
Issue Tracker <https://github.com/mesonbuild/meson-python/issues>
118107

119108

120-
.. _Meson: https://github.com/mesonbuild/meson
121109
.. _getting started: usage/start.html
122110
.. _pip: https://github.com/pypa/pip
123111
.. _pypa/build: https://github.com/pypa/build

docs/tutorials/introduction.rst

Lines changed: 37 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@ We will give you a quick introduction to what steps releasing a Python package
1414
consists of, and walk you through them to get started.
1515

1616

17-
Create a Meson_ project
18-
=======================
17+
Creating a Meson project
18+
========================
1919

2020
To get started, we need a project to publish. As ``meson-python`` is built on
21-
top of Meson, we will create a really simple Meson project. You may already have
22-
a Meson project you wish to publish, in that case, you can simply skip this
23-
step.
21+
top of Meson_, we will create a really simple Meson project. You may already
22+
have a Meson project you wish to publish, in that case, you can simply skip
23+
this step.
2424

2525

2626
The module
@@ -87,8 +87,7 @@ we want it to build, and how to do it.
8787
8888
project('purelib-and-platlib', 'c')
8989
90-
py_mod = import('python')
91-
py = py_mod.find_installation(pure: false)
90+
py = import('python').find_installation(pure: false)
9291
9392
py.extension_module(
9493
'our_first_module',
@@ -97,16 +96,16 @@ we want it to build, and how to do it.
9796
)
9897
9998
100-
Here, we use the `Meson Python module`_ to build our ``our_first_module``
99+
Here, we use Meson's `Python module`_ to build our ``our_first_module``
101100
module. We make sure to install it, by passing ``install: true`` to
102101
``extension_module``, as ``meson-python`` will only include in the binary
103102
distribution artifacts targets that Meson would install onto system. Having non
104103
installed targets allows you to build targets for use within the build, or for
105104
tests.
106105

107106

108-
Configure our Python package
109-
============================
107+
Configuring our Python package
108+
==============================
110109

111110
Now, we need to tell Python packaging tooling what build backend to use to build
112111
our package. We do this by creating a ``build-system`` section in the
@@ -115,12 +114,10 @@ tooling.
115114

116115
Inside the ``build-system`` section, we need to define two keys,
117116
``build-backend`` and ``requires``. ``build-backend`` defines which build
118-
backend should be used for the project, in meson-python it should always have
119-
the value of ``mesonpy``. ``requires`` lets us specify which packages need to be
117+
backend should be used for the project - set it to ``'mesonpy'`` to use
118+
``meson-python``. ``requires`` lets us specify which packages need to be
120119
installed for the build process, it should include ``meson-python`` and any
121-
other dependencies you might need (eg. ``Cython``), in our case it's just
122-
``meson-python``.
123-
120+
other dependencies you might need (e.g., ``Cython``).
124121

125122
.. code-block:: toml
126123
:caption: pyproject.toml
@@ -129,11 +126,9 @@ other dependencies you might need (eg. ``Cython``), in our case it's just
129126
build-backend = 'mesonpy'
130127
requires = ['meson-python']
131128
132-
133129
After we specify which backend to use, we'll want to define the package
134130
metadata. This is done in the ``project`` section, and the format is pretty
135-
self-explanatory by looking at our example.
136-
131+
self-explanatory:
137132

138133
.. code-block:: toml
139134
:caption: pyproject.toml
@@ -151,35 +146,20 @@ self-explanatory by looking at our example.
151146
{name = 'Bowsette Koopa', email = '[email protected]'},
152147
]
153148
154-
155-
.. admonition:: Adding dependencies
156-
:class: seealso
157-
158-
If you need to add dependencies to the project metadata, you can check our
159-
:ref:`how-to-guides-add-dependencies` guide.
160-
161-
162149
.. admonition:: Declaring project metadata
163150
:class: seealso
164151

165-
Our example doesn't make use of all the fields available, so we recommend you
166-
check out the `PyPA documentation on project metadata`_.
167-
168-
169-
.. admonition:: Writing TOML
170-
:class: seealso
171-
172-
If you are not familiar with the TOML configuration language or need some
173-
help, be sure to check out `toml.io <https://toml.io>`_.
152+
Our example doesn't make use of all the fields available in the ``[project]``
153+
section. Check out the `PyPA documentation on project metadata`_ for more
154+
examples and details.
174155

175156

176157
Testing the project
177158
-------------------
178159

179-
Now we should have a valid Python project, let's test it.
180-
181-
We will install it with pip_
160+
Now we should have a valid Python project, so let's test it.
182161

162+
We will install it with pip_:
183163

184164
.. code-block:: console
185165
@@ -214,23 +194,22 @@ commonly referred to as *sdists*, and `binary distributions`_, which use a
214194
custom format named *wheel*, so they're generally referred to as *wheels*.
215195

216196

217-
What are the roles of *sdists* and *wheels*
218-
-------------------------------------------
219-
197+
What are the roles of sdists and wheels?
198+
----------------------------------------
220199

221-
As you might have figured out by the name, *sdists* contain the source code of
222-
the project, and *wheels* contain a compiled [#pure-wheels]_ version of the
223-
project, ready to be copied to the file-system.
200+
As you might have figured out by the name, sdists contain the source code of
201+
the project, and wheels contain a compiled [#pure-wheels]_ version of the
202+
project, ready to be copied to the file system.
224203

225-
If your project uses Python extension modules, your *wheels* will be specific to
204+
If your project uses Python extension modules, your wheels will be specific to
226205
both the platform and the Python version [#stable-abi]_.
227206

228-
While distributing *wheels* is not mandatory, they make the
207+
While distributing wheels is not mandatory, they make the
229208
user experience much nicer. Unless you have any reason not to, we highly
230-
recommend you distribute *wheels* for at least the most common systems. When
231-
*wheels* are not available for a system, the project can still be installed, be
232-
it needs to be build from the *sdist*, which involves fetching all the build
233-
dependencies and going through the likely expensive build.
209+
recommend you distribute wheels for at least the most common systems. When
210+
wheels are not available for a system, the project can still be installed, be
211+
it needs to be build from the sdist, which involves fetching all the build
212+
dependencies and going through the likely expensive build process.
234213

235214

236215
.. [#pure-wheels]
@@ -249,32 +228,26 @@ dependencies and going through the likely expensive build.
249228
Building the project
250229
--------------------
251230

231+
Before continuing, ensure you have committed the three files we created so far
232+
to your Git repository - ``meson-python`` will only take into account the files
233+
that Git knows about.
234+
252235
To generate the distribution artifacts we will use the `pypa/build`_ tool. It
253236
will create a temporary virtual environment, install all the required build
254237
dependencies, and ask ``meson-python`` to build the artifacts.
255238

256-
257239
.. code-block:: console
258240
259241
$ pip install build
260242
$ python -m build
261243
262-
263244
If the build succeeded, you'll have the binary artifacts in the ``dist`` folder.
264245

265-
266-
.. admonition:: Check the pypa/build documentation
267-
:class: seealso
268-
269-
To learn more about `pypa/build`_, you can check
270-
`their documentation <https://pypa-build.readthedocs.io/>`__.
271-
272-
273246
.. admonition:: Building wheels for multiple platforms
274247
:class: tip
275248

276-
If our project only contains pure-Python (``.py``) code, the *wheel* we just
277-
built will work on all platforms, as it is a *pure* wheel, but if the
249+
If our project only contains pure-Python (``.py``) code, the wheel we just
250+
built will work on all platforms, as it is a pure wheel, but if the
278251
project contains native code, it will be specific for our machine's platform.
279252

280253
When releasing, you'll usually want to build for at least most of the other
@@ -314,14 +287,6 @@ For this, we will use Twine_.
314287
You can find more about how to use the `Test PyPI`_ in
315288
`its PyPA documentation page <https://packaging.python.org/en/latest/guides/using-testpypi/>`_.
316289

317-
318-
.. admonition:: Check the twine documentation
319-
:class: seealso
320-
321-
To learn more about Twine_, you can check
322-
`their documentation <https://twine.readthedocs.io/>`__.
323-
324-
325290
After this, your package should be available on PyPI_, and installable with
326291
pip_.
327292

@@ -332,8 +297,8 @@ pip_.
332297
333298
334299
335-
.. _Meson: https://github.com/mesonbuild/meson
336-
.. _Meson Python module: https://mesonbuild.com/Python-module.html
300+
.. _Meson: https://mesonbuild.com/
301+
.. _Python module: https://mesonbuild.com/Python-module.html
337302
.. _PyPA documentation on project metadata: https://packaging.python.org/en/latest/specifications/declaring-project-metadata/
338303
.. _source distributions: https://packaging.python.org/en/latest/specifications/source-distribution-format/
339304
.. _binary distributions: https://packaging.python.org/en/latest/specifications/binary-distribution-format/

0 commit comments

Comments
 (0)