Skip to content

Commit

Permalink
upgrade the wiki2/installation chapter
Browse files Browse the repository at this point in the history
  • Loading branch information
mmerickel committed Feb 4, 2024
1 parent b2457bb commit 7a68954
Show file tree
Hide file tree
Showing 15 changed files with 179 additions and 189 deletions.
60 changes: 28 additions & 32 deletions docs/tutorials/wiki2/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -177,19 +177,14 @@ The console will show ``pip`` checking for packages and installing missing packa

.. code-block:: bash
Successfully installed Jinja2-2.11.2 Mako-1.1.3 MarkupSafe-1.1.1 PasteDeploy-2.1.1 Pygments-2.7.3 SQLAlchemy-1.3.22 WebTest-2.0.35 alembic-1.4.3 attrs-20.3.0 beautifulsoup4-4.9.3 coverage-5.3.1 hupper-1.10.2 iniconfig-1.1.1 packaging-20.8 plaster-1.0 plaster-pastedeploy-0.7 pluggy-0.13.1 py-1.10.0 pyparsing-2.4.7 pyramid-1.10.5 pyramid-debugtoolbar-4.9 pyramid-jinja2-2.8 pyramid-mako-1.1.0 pyramid-retry-2.1.1 pyramid-tm-2.4 pytest-6.2.1 pytest-cov-2.10.1 python-dateutil-2.8.1 python-editor-1.0.4 repoze.lru-0.7 six-1.15.0 soupsieve-2.1 toml-0.10.2 transaction-3.0.1 translationstring-1.4 tutorial venusian-3.0.0 waitress-1.4.4 webob-1.8.6 zope.deprecation-4.4.0 zope.interface-5.2.0 zope.sqlalchemy-1.3
Successfully installed Mako-1.3.2 PasteDeploy-3.1.0 Pygments-2.17.2 SQLAlchemy-2.0.25 WebTest-3.0.0 alembic-1.13.1 beautifulsoup4-4.12.3 coverage-7.4.1 greenlet-3.0.3 hupper-1.12.1 iniconfig-2.0.0 jinja2-3.1.3 markupsafe-2.1.5 packaging-23.2 plaster-1.1.2 plaster-pastedeploy-1.0.1 pluggy-1.4.0 pyramid-2.0.2 pyramid-debugtoolbar-4.12 pyramid-jinja2-2.10 pyramid-mako-1.1.0 pyramid-retry-2.1.1 pyramid-tm-2.5 pytest-8.0.0 pytest-cov-4.1.0 soupsieve-2.5 transaction-4.0 translationstring-1.4 tutorial-0.0 typing-extensions-4.9.0 venusian-3.1.0 waitress-2.1.2 webob-1.8.7 zope.deprecation-5.0 zope.interface-6.1 zope.sqlalchemy-3.1
Testing requirements are defined in our project's ``setup.py`` file, in the ``tests_require`` and ``extras_require`` stanzas.
Testing requirements are defined in our project's ``pyproject.toml`` file in a ``testing`` optional dependency.

.. literalinclude:: src/installation/setup.py
.. literalinclude:: src/installation/pyproject.toml
:language: python
:lineno-match:
:lines: 25-29

.. literalinclude:: src/installation/setup.py
:language: python
:lineno-match:
:lines: 49-51
:lines: 34-39


.. _initialize_db_wiki2:
Expand Down Expand Up @@ -219,11 +214,11 @@ The output to your console should be something like this:

.. code-block:: text
2021-01-07 05:15:57,709 INFO [alembic.runtime.migration:155][MainThread] Context impl SQLiteImpl.
2021-01-07 05:15:57,709 INFO [alembic.runtime.migration:162][MainThread] Will assume non-transactional DDL.
2021-01-07 05:15:57,712 INFO [alembic.autogenerate.compare:134][MainThread] Detected added table 'models'
2021-01-07 05:15:57,712 INFO [alembic.autogenerate.compare:588][MainThread] Detected added index 'my_index' on '['name']'
Generating <somepath>/tutorial/tutorial/alembic/versions/20210107_d7ab09c3fdec.py ... done
2024-02-04 12:02:28,828 INFO [alembic.runtime.migration:216][MainThread] Context impl SQLiteImpl.
2024-02-04 12:02:28,828 INFO [alembic.runtime.migration:219][MainThread] Will assume non-transactional DDL.
2024-02-04 12:02:28,832 INFO [alembic.autogenerate.compare:189][MainThread] Detected added table 'models'
2024-02-04 12:02:28,832 INFO [alembic.autogenerate.compare:633][MainThread] Detected added index ''my_index'' on '('name',)'
Generating /Users/michael/work/oss/pyramid/tutorial/tutorial/alembic/versions/20240204_4b6614165904.py ... done
Upgrade to that revision.

Expand All @@ -245,9 +240,9 @@ The output to your console should be something like this:

.. code-block:: text
2021-01-07 05:16:21,558 INFO [alembic.runtime.migration:155][MainThread] Context impl SQLiteImpl.
2021-01-07 05:16:21,558 INFO [alembic.runtime.migration:162][MainThread] Will assume non-transactional DDL.
2021-01-07 05:16:21,560 INFO [alembic.runtime.migration:517][MainThread] Running upgrade -> d7ab09c3fdec, init
2024-02-04 12:03:04,738 INFO [alembic.runtime.migration:216][MainThread] Context impl SQLiteImpl.
2024-02-04 12:03:04,738 INFO [alembic.runtime.migration:219][MainThread] Will assume non-transactional DDL.
2024-02-04 12:03:04,739 INFO [alembic.runtime.migration:622][MainThread] Running upgrade -> 4b6614165904, init
.. _load_data_wiki2:
Expand Down Expand Up @@ -337,24 +332,26 @@ If successful, you will see output something like this:

.. code-block:: bash
======================== test session starts ========================
platform darwin -- Python 3.9.0, pytest-6.2.1, py-1.10.0, pluggy-0.13.1
rootdir: <somepath>/tutorial, inifile: pytest.ini, testpaths: tutorial, tests
plugins: cov-2.10.1
====================================== test session starts ======================================
platform darwin -- Python 3.11.7, pytest-8.0.0, pluggy-1.4.0
rootdir: /Users/michael/work/oss/pyramid/tutorial
configfile: pyproject.toml
testpaths: tutorial, tests
plugins: cov-4.1.0
collected 5 items
tests/test_functional.py .. [ 40%]
tests/test_views.py ... [100%]
---------- coverage: platform darwin, python 3.9.0-final-0 -----------
tests/test_functional.py .. [ 40%]
tests/test_views.py ... [100%]
---------- coverage: platform darwin, python 3.11.7-final-0 ----------
Name Stmts Miss Cover Missing
----------------------------------------------------------------------------------
tutorial/__init__.py 8 0 100%
tutorial/alembic/env.py 23 4 83% 28-30, 56
tutorial/alembic/versions/20200106_8c274fe5f3c4.py 12 2 83% 31-32
tutorial/models/__init__.py 32 2 94% 71, 82
tutorial/models/meta.py 5 0 100%
tutorial/models/mymodel.py 8 0 100%
tutorial/alembic/versions/20240204_4b6614165904.py 12 2 83% 31-32
tutorial/models/__init__.py 32 2 94% 111, 122
tutorial/models/meta.py 4 0 100%
tutorial/models/mymodel.py 10 0 100%
tutorial/pshell.py 7 5 29% 5-13
tutorial/routes.py 3 0 100%
tutorial/scripts/__init__.py 0 0 100%
Expand All @@ -363,13 +360,12 @@ If successful, you will see output something like this:
tutorial/views/default.py 13 0 100%
tutorial/views/notfound.py 5 0 100%
----------------------------------------------------------------------------------
TOTAL 138 27 80%
TOTAL 139 27 81%
===================== 5 passed in 0.77 seconds ======================
================================= 5 passed, 6 warnings in 0.54s =================================
Our package doesn't quite have 100% test coverage.


.. _test_and_coverage_cookiecutter_defaults_sql:

Test and coverage cookiecutter defaults
Expand Down
2 changes: 0 additions & 2 deletions docs/tutorials/wiki2/src/installation/.coveragerc

This file was deleted.

4 changes: 0 additions & 4 deletions docs/tutorials/wiki2/src/installation/CHANGES.txt

This file was deleted.

2 changes: 1 addition & 1 deletion docs/tutorials/wiki2/src/installation/MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
include *.txt *.ini *.cfg *.rst
include *.txt *.ini *.cfg *.rst *.toml
recursive-include tutorial *.ico *.png *.css *.gif *.jpg *.pt *.txt *.mak *.mako *.js *.html *.xml *.jinja2
recursive-include tests *
recursive-exclude * __pycache__
Expand Down
60 changes: 60 additions & 0 deletions docs/tutorials/wiki2/src/installation/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# myproj

## Getting Started

- Change directory into your newly created project if not already there. Your
current directory should be the same as this `README.md` file and `pyproject.toml`.

```
cd tutorial
```

- Create a Python virtual environment, if not already created.

```
python3 -m venv env
```

- Upgrade packaging tools, if necessary.

```
env/bin/pip install --upgrade pip
```

- Install the project in editable mode with its testing requirements.

```
env/bin/pip install -e ".[testing]"
```

- Initialize and upgrade the database using Alembic.

- Generate your first revision.

```
env/bin/alembic -c development.ini revision --autogenerate -m "init"
```
- Upgrade to that revision.
```
env/bin/alembic -c development.ini upgrade head
```
- Load default data into the database using a script.
```
env/bin/initialize_tutorial_db development.ini
```
- Run your project's tests.
```
env/bin/pytest
```
- Run your project.
```
env/bin/pserve development.ini
```
44 changes: 0 additions & 44 deletions docs/tutorials/wiki2/src/installation/README.txt

This file was deleted.

8 changes: 4 additions & 4 deletions docs/tutorials/wiki2/src/installation/development.ini
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,16 @@ retry.attempts = 3
[pshell]
setup = tutorial.pshell.setup

###
# wsgi server configuration
###

[alembic]
# path to migration scripts
script_location = tutorial/alembic
file_template = %%(year)d%%(month).2d%%(day).2d_%%(rev)s
# file_template = %%(rev)s_%%(slug)s

###
# wsgi server configuration
###

[server:main]
use = egg:waitress#main
listen = localhost:6543
Expand Down
8 changes: 4 additions & 4 deletions docs/tutorials/wiki2/src/installation/production.ini
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,16 @@ retry.attempts = 3
[pshell]
setup = tutorial.pshell.setup

###
# wsgi server configuration
###

[alembic]
# path to migration scripts
script_location = tutorial/alembic
file_template = %%(year)d%%(month).2d%%(day).2d_%%(rev)s
# file_template = %%(rev)s_%%(slug)s

###
# wsgi server configuration
###

[server:main]
use = egg:waitress#main
listen = *:6543
Expand Down
58 changes: 58 additions & 0 deletions docs/tutorials/wiki2/src/installation/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
[build-system]
requires = ["setuptools"]
build-backend = "setuptools.build_meta"

[project]
version = "0.0"
name = "tutorial"
authors = []
description = "myproj"
readme = "README.md"
keywords = ["web", "pyramid", "pylons"]
classifiers = [
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Framework :: Pyramid",
"Topic :: Internet :: WWW/HTTP",
"Topic :: Internet :: WWW/HTTP :: WSGI :: Application",
]
requires-python = ">=3.8"
dependencies = [
"plaster_pastedeploy",
"pyramid",
"pyramid_jinja2",
"pyramid_debugtoolbar",
"waitress",
"alembic",
"pyramid_retry",
"pyramid_tm",
"SQLAlchemy",
"transaction",
"zope.sqlalchemy",
]

[project.optional-dependencies]
testing = [
"WebTest",
"pytest",
"pytest-cov",
]

[project.scripts]
initialize_tutorial_db = "tutorial.scripts.initialize_db:main"

[project.entry-points."paste.app_factory"]
main = "tutorial:main"

[tool.setuptools.packages.find]
exclude = ["tests"]

[tool.coverage.run]
source = "tutorial"

[tool.pytest.ini_options]
addopts = "--strict-markers"
testpaths = [
"tutorial",
"tests",
]
6 changes: 0 additions & 6 deletions docs/tutorials/wiki2/src/installation/pytest.ini

This file was deleted.

61 changes: 0 additions & 61 deletions docs/tutorials/wiki2/src/installation/setup.py

This file was deleted.

Loading

0 comments on commit 7a68954

Please sign in to comment.