Skip to content

Commit b64790b

Browse files
authored
Merge pull request #630 from belm0/patch-1
clarify test property in example module
2 parents ec098ac + 5dff866 commit b64790b

1 file changed

Lines changed: 6 additions & 17 deletions

File tree

source/tutorials/packaging-projects.rst

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,8 @@ To create this project locally, create the following file structure:
2525
Once you create this structure, you'll want to run all of the commands in this
2626
tutorial within the top-level folder - so be sure to ``cd packaging_tutorial``.
2727

28-
You should also edit :file:`example_pkg/__init__.py` and put the following
29-
code in there:
30-
31-
.. code-block:: python
32-
33-
name = "example_pkg"
34-
35-
This is just so that you can verify that it installed correctly later in this
36-
tutorial and is not used by PyPI.
28+
:file:`example_pkg/__init__.py` is required to import the directory as a package,
29+
and can simply be an empty file.
3730

3831
.. _Python documentation for packages and modules:
3932
https://docs.python.org/3/tutorial/modules.html#packages
@@ -294,25 +287,21 @@ something like this:
294287
295288
.. note:: This example uses ``--index-url`` flag to specify TestPyPI instead of live PyPI. Additionally, it specifies ``--no-deps``. Since TestPyPI doesn't have the same packages as the live PyPI, it's possible that attempting to install dependencies may fail or install something unexpected. While our example package doesn't have any dependencies, it's a good practice to avoid installing dependencies when using TestPyPI.
296289

297-
You can test that it was installed correctly by importing the module and
298-
referencing the ``name`` property you put in :file:`__init__.py` earlier.
299-
290+
You can test that it was installed correctly by importing the package.
300291
Run the Python interpreter (make sure you're still in your virtualenv):
301292

302293
.. code-block:: bash
303294
304295
python
305296
306-
And then import the module and print out the ``name`` property. This should be
307-
the same regardless of what you name you gave your :term:`distribution package`
308-
in :file:`setup.py` (in this case, ``example-pkg-YOUR-USERNAME-HERE``) because your :term:`import package` is ``example_pkg``.
297+
and from the interpreter shell import the package:
309298

310299
.. code-block:: python
311300
312301
>>> import example_pkg
313-
>>> example_pkg.name
314-
'example_pkg'
315302
303+
Note that the :term:`import package` is ``example_pkg`` regardless of what name you gave your :term:`distribution package`
304+
in :file:`setup.py` (in this case, ``example-pkg-YOUR-USERNAME-HERE``).
316305

317306
Next steps
318307
----------

0 commit comments

Comments
 (0)