@@ -198,93 +198,76 @@ this. For a small app like polls, this process isn't too difficult.
198
198
license. Just be aware that your licensing choice will affect who is able
199
199
to use your code.
200
200
201
- #. Next we'll create ``pyproject.toml``, ``setup.cfg``, and ``setup.py`` files
202
- which detail how to build and install the app. A full explanation of these
203
- files is beyond the scope of this tutorial, but the `setuptools
204
- documentation <https://setuptools.pypa.io/en/latest/>`_ has a good
205
- explanation. Create the ``django-polls/pyproject.toml``,
206
- ``django-polls/setup.cfg``, and ``django-polls/setup.py`` files with the
201
+ #. Next we'll create the ``pyproject.toml`` file which details how to build and
202
+ install the app. A full explanation of this file is beyond the scope of this
203
+ tutorial, but the `Python Packaging User Guide
204
+ <https://packaging.python.org/guides/writing-pyproject-toml/>`_ has a good
205
+ explanation. Create the ``django-polls/pyproject.toml`` file with the
207
206
following contents:
208
207
209
208
.. code-block:: toml
210
- :caption: ``django-polls/pyproject.toml``
211
-
212
- [build-system]
213
- requires = ['setuptools>=40.8.0']
214
- build-backend = 'setuptools.build_meta'
215
-
216
- .. code-block:: ini
217
- :caption: ``django-polls/setup.cfg``
218
-
219
- [metadata]
220
- name = django-polls
221
- version = 0.1
222
- description = A Django app to conduct web-based polls.
223
- long_description = file: README.rst
224
- url = https://www.example.com/
225
- author = Your Name
226
- author_email = yourname@example.com
227
- license = BSD-3-Clause # Example license
228
- classifiers =
229
- Environment :: Web Environment
230
- Framework :: Django
231
- Framework :: Django :: X.Y # Replace "X.Y" as appropriate
232
- Intended Audience :: Developers
233
- License :: OSI Approved :: BSD License
234
- Operating System :: OS Independent
235
- Programming Language :: Python
236
- Programming Language :: Python :: 3
237
- Programming Language :: Python :: 3 :: Only
238
- Programming Language :: Python :: 3.10
239
- Programming Language :: Python :: 3.11
240
- Programming Language :: Python :: 3.12
241
- Topic :: Internet :: WWW/HTTP
242
- Topic :: Internet :: WWW/HTTP :: Dynamic Content
243
-
244
- [options]
245
- include_package_data = true
246
- packages = find:
247
- python_requires = >=3.10
248
- install_requires =
249
- Django >= X.Y # Replace "X.Y" as appropriate
250
-
251
- .. code-block:: python
252
- :caption: ``django-polls/setup.py``
253
-
254
- from setuptools import setup
255
-
256
- setup()
257
-
258
- #. Only Python modules and packages are included in the package by default. To
259
- include additional files, we'll need to create a ``MANIFEST.in`` file. The
260
- ``setuptools`` docs referred to in the previous step discuss this file in
261
- more detail. To include the templates, the ``README.rst`` and our
262
- ``LICENSE`` file, create a file ``django-polls/MANIFEST.in`` with the
263
- following contents:
209
+ :caption: ``django-polls/pyproject.toml``
210
+
211
+ [build-system]
212
+ requires = ["setuptools>=61.0"]
213
+ build-backend = "setuptools.build_meta"
214
+
215
+ [project]
216
+ name = "django-polls"
217
+ version = "0.1"
218
+ dependencies = [
219
+ "django>=X.Y", # Replace "X.Y" as appropriate
220
+ ]
221
+ description = "A Django app to conduct web-based polls."
222
+ readme = "README.rst"
223
+ requires-python = ">= 3.10"
224
+ authors = [
225
+ {name = "Your Name", email = "yourname@example.com"},
226
+ ]
227
+ classifiers = [
228
+ "Environment :: Web Environment",
229
+ "Framework :: Django",
230
+ "Framework :: Django :: X.Y", # Replace "X.Y" as appropriate
231
+ "Intended Audience :: Developers",
232
+ "License :: OSI Approved :: BSD License",
233
+ "Operating System :: OS Independent",
234
+ "Programming Language :: Python",
235
+ "Programming Language :: Python :: 3",
236
+ "Programming Language :: Python :: 3 :: Only",
237
+ "Programming Language :: Python :: 3.10",
238
+ "Programming Language :: Python :: 3.11",
239
+ "Programming Language :: Python :: 3.12",
240
+ "Topic :: Internet :: WWW/HTTP",
241
+ "Topic :: Internet :: WWW/HTTP :: Dynamic Content",
242
+ ]
243
+
244
+ [project.urls]
245
+ Homepage = "https://www.example.com/"
246
+
247
+ #. Many common files and Python modules and packages are included in the
248
+ package by default. To include additional files, we'll need to create a
249
+ ``MANIFEST.in`` file. To include the templates and static files, create a
250
+ file ``django-polls/MANIFEST.in`` with the following contents:
264
251
265
252
.. code-block:: text
266
- :caption: ``django-polls/MANIFEST.in``
253
+ :caption: ``django-polls/MANIFEST.in``
267
254
268
- include LICENSE
269
- include README.rst
270
- recursive-include django_polls/static *
271
- recursive-include django_polls/templates *
255
+ recursive-include django_polls/static *
256
+ recursive-include django_polls/templates *
272
257
273
258
#. It's optional, but recommended, to include detailed documentation with your
274
259
app. Create an empty directory ``django-polls/docs`` for future
275
- documentation. Add an additional line to ``django-polls/MANIFEST.in``:
276
-
277
- .. code-block:: text
278
-
279
- recursive-include docs *
260
+ documentation.
280
261
281
262
Note that the ``docs`` directory won't be included in your package unless
282
263
you add some files to it. Many Django apps also provide their documentation
283
264
online through sites like `readthedocs.org <https://readthedocs.org>`_.
284
265
285
- #. Try building your package by running ``python setup.py sdist`` inside
266
+ #. Check that the :pypi:`build` package is installed (``python -m pip install
267
+ build``) and try building your package by running ``python -m build`` inside
286
268
``django-polls``. This creates a directory called ``dist`` and builds your
287
- new package, ``django-polls-0.1.tar.gz``.
269
+ new package into source and binary formats, ``django-polls-0.1.tar.gz`` and
270
+ ``django_polls-0.1-py3-none-any.whl``.
288
271
289
272
For more information on packaging, see Python's `Tutorial on Packaging and
290
273
Distributing Projects
0 commit comments