Standardize Unix capitalization
| | |
| | | A package which logs Pyramid application exception (error) information |
| | | to a standard Python logger. This add-on is most useful when |
| | | used in production applications, because the logger can be configured to |
| | | log to a file, to UNIX syslog, to the Windows Event Log, or even to |
| | | log to a file, to Unix syslog, to the Windows Event Log, or even to |
| | | email. See its `documentation |
| | | <https://docs.pylonsproject.org/projects/pyramid_exclog/en/latest/>`_. |
| | | |
| | | console script |
| | | A script written to the ``bin`` (on UNIX, or ``Scripts`` on Windows) |
| | | A script written to the ``bin`` (on Unix, or ``Scripts`` on Windows) |
| | | directory of a Python installation or :term:`virtual environment` as the |
| | | result of running ``pip install`` or ``pip install -e .``. |
| | | |
| | |
| | | :class:`pyramid.interfaces.IAssetDescriptor`. |
| | | |
| | | Waitress |
| | | A :term:`WSGI` server that runs on UNIX and Windows under Python 2.7+ |
| | | A :term:`WSGI` server that runs on Unix and Windows under Python 2.7+ |
| | | and Python 3.3+. Projects generated via Pyramid cookiecutters use |
| | | Waitress as a WGSI server. See |
| | | https://docs.pylonsproject.org/projects/waitress/en/latest/ for detailed |
| | | information. |
| | | |
| | | Green Unicorn |
| | | Aka ``gunicorn``, a fast :term:`WSGI` server that runs on UNIX under |
| | | Aka ``gunicorn``, a fast :term:`WSGI` server that runs on Unix under |
| | | Python 2.6+ or Python 3.1+. See http://gunicorn.org/ for detailed |
| | | information. |
| | | |
| | |
| | | ``pyvenv`` command for `creating virtual environments on Python 3.4 and |
| | | 3.5 |
| | | <https://packaging.python.org/tutorials/installing-packages/#creating-virtual-environments>`_, |
| | | but it was deprecated in 3.6 in favor of ``python3 -m venv`` on UNIX or |
| | | but it was deprecated in 3.6 in favor of ``python3 -m venv`` on Unix or |
| | | ``python -m venv`` on Windows, which is backward compatible on Python |
| | | 3.3 and greater. |
| | | |
| | |
| | | executed by a Python interpreter which has the :app:`Pyramid` software |
| | | installed, an HTTP server is started on TCP port 8080. |
| | | |
| | | On UNIX: |
| | | On Unix: |
| | | |
| | | .. code-block:: bash |
| | | |
| | |
| | | to work properly, you will need to have :term:`Lingua` and :term:`Gettext` |
| | | installed into the same environment in which :app:`Pyramid` is installed. |
| | | |
| | | Installation on UNIX |
| | | Installation on Unix |
| | | ++++++++++++++++++++ |
| | | |
| | | Gettext is often already installed on UNIX systems. You can check if it is |
| | | Gettext is often already installed on Unix systems. You can check if it is |
| | | installed by testing if the ``msgfmt`` command is available. If it is not |
| | | available you can install it through the packaging system from your OS; the |
| | | package name is almost always ``gettext``. For example on a Debian or Ubuntu |
| | |
| | | As of this writing, :app:`Pyramid` is tested against Python 2.7, |
| | | Python 3.4, Python 3.5, Python 3.6, and PyPy. |
| | | |
| | | :app:`Pyramid` is known to run on all popular UNIX-like systems such as Linux, |
| | | Mac OS X, and FreeBSD, as well as on Windows platforms. It is also known to |
| | | :app:`Pyramid` is known to run on all popular Unix-like systems such as Linux, |
| | | macOS, and FreeBSD, as well as on Windows platforms. It is also known to |
| | | run on :term:`PyPy` (1.9+). |
| | | |
| | | :app:`Pyramid` installation does not require the compilation of any C code. |
| | |
| | | |
| | | .. _if-you-don-t-yet-have-a-python-interpreter-unix: |
| | | |
| | | If You Don't Yet Have a Python Interpreter (UNIX) |
| | | If You Don't Yet Have a Python Interpreter (Unix) |
| | | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| | | |
| | | If your system doesn't have a Python interpreter, and you're on UNIX, you can |
| | | If your system doesn't have a Python interpreter, and you're on Unix, you can |
| | | either install Python using your operating system's package manager *or* you |
| | | can install Python from source fairly easily on any UNIX system that has |
| | | can install Python from source fairly easily on any Unix system that has |
| | | development tools. |
| | | |
| | | .. seealso:: See the official Python documentation :ref:`Using Python on Unix |
| | |
| | | |
| | | |
| | | .. index:: |
| | | single: installing on UNIX |
| | | single: installing on Unix |
| | | single: installing on Mac OS X |
| | | |
| | | .. _installing_unix: |
| | | |
| | | Installing :app:`Pyramid` on a UNIX System |
| | | Installing :app:`Pyramid` on a Unix System |
| | | ------------------------------------------ |
| | | |
| | | After installing Python as described previously in :ref:`for-mac-os-x-users` or |
| | |
| | | |
| | | We then run through the following commands. |
| | | |
| | | On UNIX: |
| | | On Unix: |
| | | |
| | | .. code-block:: bash |
| | | |
| | |
| | | environment. Your terminal's current working directory *must* be the newly |
| | | created project directory. |
| | | |
| | | On UNIX: |
| | | On Unix: |
| | | |
| | | .. code-block:: bash |
| | | |
| | |
| | | |
| | | %VENV%\Scripts\pip install -e . |
| | | |
| | | Elided output from a run of this command on UNIX is shown below: |
| | | Elided output from a run of this command on Unix is shown below: |
| | | |
| | | .. code-block:: bash |
| | | |
| | |
| | | To run unit tests for your application, you must first install the testing |
| | | dependencies. |
| | | |
| | | On UNIX: |
| | | On Unix: |
| | | |
| | | .. code-block:: bash |
| | | |
| | |
| | | the ``py.test`` command that was just installed in the ``bin`` directory of |
| | | your virtual environment. |
| | | |
| | | On UNIX: |
| | | On Unix: |
| | | |
| | | .. code-block:: bash |
| | | |
| | |
| | | |
| | | %VENV%\Scripts\py.test -q |
| | | |
| | | Here's sample output from a test run on UNIX: |
| | | Here's sample output from a test run on Unix: |
| | | |
| | | .. code-block:: bash |
| | | |
| | |
| | | represents using the ``pserve`` command against the generated configuration |
| | | file. In our case, this file is named ``development.ini``. |
| | | |
| | | On UNIX: |
| | | On Unix: |
| | | |
| | | .. code-block:: bash |
| | | |
| | |
| | | |
| | | %VENV%\Scripts\pserve development.ini |
| | | |
| | | Here's sample output from a run of ``pserve`` on UNIX: |
| | | Here's sample output from a run of ``pserve`` on Unix: |
| | | |
| | | .. code-block:: bash |
| | | |
| | |
| | | makes development easier, as changes to Python code made within a |
| | | :app:`Pyramid` application is not put into effect until the server restarts. |
| | | |
| | | For example, on UNIX: |
| | | For example, on Unix: |
| | | |
| | | .. code-block:: text |
| | | |
| | |
| | | case, this is the directory containing the file that defines the |
| | | ``sample_view`` function. Although a renderer path is usually just a simple |
| | | relative pathname, a path named as a renderer can be absolute, starting with a |
| | | slash on UNIX or a drive letter prefix on Windows. The path can alternatively |
| | | slash on Unix or a drive letter prefix on Windows. The path can alternatively |
| | | be an :term:`asset specification` in the form |
| | | ``some.dotted.package_name:relative/path``. This makes it possible to address |
| | | template assets which live in another package. For example: |
| | |
| | | See also :ref:`built_in_renderers`. |
| | | |
| | | Although a renderer path is usually just a simple relative pathname, a path |
| | | named as a renderer can be absolute, starting with a slash on UNIX or a drive |
| | | named as a renderer can be absolute, starting with a slash on Unix or a drive |
| | | letter prefix on Windows. The path can alternatively be an :term:`asset |
| | | specification` in the form ``some.dotted.package_name:relative/path``, making |
| | | it possible to address template assets which live in another package. |
| | |
| | | |
| | | In this circumstance, you can start your application interactively under a |
| | | server run with the ``PYTHONWARNINGS`` environment variable set to ``default``. |
| | | On UNIX, you can do that via: |
| | | On Unix, you can do that via: |
| | | |
| | | .. code-block:: bash |
| | | |
| | |
| | | When the renderer is a path—although a path is usually just a simple relative |
| | | pathname (e.g., ``templates/foo.pt``, implying that a template named "foo.pt" |
| | | is in the "templates" directory relative to the directory of the current |
| | | :term:`package`)—the path can be absolute, starting with a slash on UNIX or a |
| | | :term:`package`)—the path can be absolute, starting with a slash on Unix or a |
| | | drive letter prefix on Windows. The path can alternatively be a :term:`asset |
| | | specification` in the form ``some.dotted.package_name:relative/path``, making |
| | | it possible to address template assets which live in a separate package. |
| | |
| | | Of course Pyramid runs fine on Python 2.7+, as do the examples in this *Quick |
| | | Tour*. We're showing Python 3 for simplicity. (Pyramid had production support |
| | | for Python 3 in October 2011.) Also for simplicity, the remaining examples will |
| | | show only UNIX commands. |
| | | show only Unix commands. |
| | | |
| | | .. seealso:: See also: |
| | | :ref:`Quick Tutorial section on Requirements <qtut_requirements>`, |
| | |
| | | projects* (a directory with packaging information and *Python packages* of |
| | | working code.) |
| | | |
| | | * **Unix commands**. Commands in this tutorial use UNIX syntax and paths. |
| | | * **Unix commands**. Commands in this tutorial use Unix syntax and paths. |
| | | Windows users should adjust commands accordingly. |
| | | |
| | | .. note:: |
| | |
| | | │ └── app.py |
| | | └── setup.py |
| | | |
| | | For Linux, the commands to do so are as follows: |
| | | For macOS and Linux, the commands to do so are as follows: |
| | | |
| | | .. code-block:: bash |
| | | |
| | | # Mac and Linux |
| | | # macOS and Linux |
| | | cd ~ |
| | | mkdir -p projects/quick_tutorial |
| | | cd projects/quick_tutorial |
| | |
| | | |
| | | .. code-block:: bash |
| | | |
| | | # Mac and Linux |
| | | # macOS and Linux |
| | | export VENV=~/projects/quick_tutorial/env |
| | | |
| | | .. code-block:: doscon |
| | |
| | | |
| | | .. code-block:: bash |
| | | |
| | | # Mac and Linux |
| | | # macOS and Linux |
| | | python3 -m venv $VENV |
| | | |
| | | .. code-block:: doscon |
| | |
| | | |
| | | .. code-block:: bash |
| | | |
| | | # Mac and Linux |
| | | # macOS and Linux |
| | | $VENV/bin/pip install --upgrade pip setuptools |
| | | |
| | | .. code-block:: doscon |
| | |
| | | |
| | | .. parsed-literal:: |
| | | |
| | | # Mac and Linux |
| | | # macOS and Linux |
| | | $VENV/bin/pip install "pyramid==\ |release|\ " waitress |
| | | |
| | | # Windows |
| | |
| | | URLs to code. It can also be followed by people without any prior |
| | | Python web framework experience. |
| | | |
| | | To code along with this tutorial, the developer will need a UNIX |
| | | To code along with this tutorial, the developer will need a Unix |
| | | machine with development tools (Mac OS X with XCode, any Linux or BSD |
| | | variant, and so on) *or* a Windows system of any kind. |
| | | |
| | |
| | | Make sure your current working directory is the root of the project (the |
| | | directory in which ``setup.py`` lives) and execute the following command. |
| | | |
| | | On UNIX: |
| | | On Unix: |
| | | |
| | | .. code-block:: bash |
| | | |
| | |
| | | current working directory contains the ``tutorial`` package and the |
| | | ``setup.py`` file. |
| | | |
| | | On UNIX: |
| | | On Unix: |
| | | |
| | | .. code-block:: bash |
| | | |
| | |
| | | Generate a Pyramid project from a cookiecutter |
| | | ---------------------------------------------- |
| | | |
| | | We will create a Pyramid project in your home directory for UNIX or at the root for Windows. It is assumed you know the path to where you installed ``cookiecutter``. Issue the following commands and override the defaults in the prompts as follows. |
| | | We will create a Pyramid project in your home directory for Unix or at the root for Windows. It is assumed you know the path to where you installed ``cookiecutter``. Issue the following commands and override the defaults in the prompts as follows. |
| | | |
| | | On UNIX |
| | | On Unix |
| | | ^^^^^^^ |
| | | |
| | | .. code-block:: bash |
| | |
| | | Change directory into your newly created project |
| | | ------------------------------------------------ |
| | | |
| | | On UNIX |
| | | On Unix |
| | | ^^^^^^^ |
| | | |
| | | .. code-block:: bash |
| | |
| | | |
| | | We will set the ``VENV`` environment variable to the absolute path of the virtual environment, and use it going forward. |
| | | |
| | | On UNIX |
| | | On Unix |
| | | ^^^^^^^ |
| | | |
| | | .. code-block:: bash |
| | |
| | | Create a virtual environment |
| | | ---------------------------- |
| | | |
| | | On UNIX |
| | | On Unix |
| | | ^^^^^^^ |
| | | |
| | | .. code-block:: bash |
| | |
| | | Upgrade packaging tools in the virtual environment |
| | | -------------------------------------------------- |
| | | |
| | | On UNIX |
| | | On Unix |
| | | ^^^^^^^ |
| | | |
| | | .. code-block:: bash |
| | |
| | | |
| | | In order to do development on the project easily, you must "register" the project as a development egg in your workspace. We will install testing requirements at the same time. We do so with the following command. |
| | | |
| | | On UNIX |
| | | On Unix |
| | | ^^^^^^^ |
| | | |
| | | .. code-block:: bash |
| | |
| | | provide options to py.test that specify the module for which its tests shall be |
| | | run, and to run py.test in quiet mode. |
| | | |
| | | On UNIX |
| | | On Unix |
| | | ^^^^^^^ |
| | | |
| | | .. code-block:: bash |
| | |
| | | We've already installed the ``pytest-cov`` package into our virtual |
| | | environment, so we can run the tests with coverage. |
| | | |
| | | On UNIX |
| | | On Unix |
| | | ^^^^^^^ |
| | | |
| | | .. code-block:: bash |
| | |
| | | the root of your package. Without these defaults, we would need to specify the |
| | | path to the module on which we want to run tests and coverage. |
| | | |
| | | On UNIX |
| | | On Unix |
| | | ^^^^^^^ |
| | | |
| | | .. code-block:: bash |
| | |
| | | Start the application. See :ref:`what_is_this_pserve_thing` for more |
| | | information on ``pserve``. |
| | | |
| | | On UNIX |
| | | On Unix |
| | | ^^^^^^^ |
| | | |
| | | .. code-block:: bash |
| | |
| | | already been satisfied and ``py.test`` and coverage have already been |
| | | configured, so we can jump right to running tests. |
| | | |
| | | On UNIX: |
| | | On Unix: |
| | | |
| | | .. code-block:: bash |
| | | |
| | |
| | | URLs to code. It can also be followed by people without any prior |
| | | Python web framework experience. |
| | | |
| | | To code along with this tutorial, the developer will need a UNIX |
| | | To code along with this tutorial, the developer will need a Unix |
| | | machine with development tools (Mac OS X with XCode, any Linux or BSD |
| | | variant, etc.) *or* a Windows system of any kind. |
| | | |
| | |
| | | Make sure your current working directory is the root of the project (the |
| | | directory in which ``setup.py`` lives) and execute the following command. |
| | | |
| | | On UNIX: |
| | | On Unix: |
| | | |
| | | .. code-block:: bash |
| | | |
| | |
| | | |
| | | Now that we have written our models, we need to modify the database schema to reflect the changes to our code. Let's generate a new revision, then upgrade the database to the latest revision (head). |
| | | |
| | | On UNIX: |
| | | On Unix: |
| | | |
| | | .. code-block:: bash |
| | | |
| | |
| | | current working directory contains the ``tutorial`` package and the |
| | | ``setup.py`` file. |
| | | |
| | | On UNIX: |
| | | On Unix: |
| | | |
| | | .. code-block:: bash |
| | | |
| | |
| | | Generate a Pyramid project from a cookiecutter |
| | | ---------------------------------------------- |
| | | |
| | | We will create a Pyramid project in your home directory for UNIX or at the root for Windows. It is assumed you know the path to where you installed ``cookiecutter``. Issue the following commands and override the defaults in the prompts as follows. |
| | | We will create a Pyramid project in your home directory for Unix or at the root for Windows. It is assumed you know the path to where you installed ``cookiecutter``. Issue the following commands and override the defaults in the prompts as follows. |
| | | |
| | | On UNIX |
| | | On Unix |
| | | ^^^^^^^ |
| | | |
| | | .. code-block:: bash |
| | |
| | | Change directory into your newly created project |
| | | ------------------------------------------------ |
| | | |
| | | On UNIX |
| | | On Unix |
| | | ^^^^^^^ |
| | | |
| | | .. code-block:: bash |
| | |
| | | |
| | | We will set the ``VENV`` environment variable to the absolute path of the virtual environment, and use it going forward. |
| | | |
| | | On UNIX |
| | | On Unix |
| | | ^^^^^^^ |
| | | |
| | | .. code-block:: bash |
| | |
| | | Create a virtual environment |
| | | ---------------------------- |
| | | |
| | | On UNIX |
| | | On Unix |
| | | ^^^^^^^ |
| | | |
| | | .. code-block:: bash |
| | |
| | | Upgrade packaging tools in the virtual environment |
| | | -------------------------------------------------- |
| | | |
| | | On UNIX |
| | | On Unix |
| | | ^^^^^^^ |
| | | |
| | | .. code-block:: bash |
| | |
| | | |
| | | In order to do development on the project easily, you must "register" the project as a development egg in your workspace. We will install testing requirements at the same time. We do so with the following command. |
| | | |
| | | On UNIX |
| | | On Unix |
| | | ^^^^^^^ |
| | | |
| | | .. code-block:: bash |
| | |
| | | |
| | | Generate your first revision. |
| | | |
| | | On UNIX |
| | | On Unix |
| | | ^^^^^^^ |
| | | |
| | | .. code-block:: bash |
| | |
| | | |
| | | Upgrade to that revision. |
| | | |
| | | On UNIX |
| | | On Unix |
| | | ^^^^^^^ |
| | | |
| | | .. code-block:: bash |
| | |
| | | |
| | | Load default data into the database using a :term:`console script`. Type the following command, making sure you are still in the ``tutorial`` directory (the directory with a ``development.ini`` in it): |
| | | |
| | | On UNIX |
| | | On Unix |
| | | ^^^^^^^ |
| | | |
| | | .. code-block:: bash |
| | |
| | | provide options to py.test that specify the module for which its tests shall be |
| | | run, and to run py.test in quiet mode. |
| | | |
| | | On UNIX |
| | | On Unix |
| | | ^^^^^^^ |
| | | |
| | | .. code-block:: bash |
| | |
| | | We've already installed the ``pytest-cov`` package into our virtual |
| | | environment, so we can run the tests with coverage. |
| | | |
| | | On UNIX |
| | | On Unix |
| | | ^^^^^^^ |
| | | |
| | | .. code-block:: bash |
| | |
| | | the root of your package. Without these defaults, we would need to specify the |
| | | path to the module on which we want to run tests and coverage. |
| | | |
| | | On UNIX |
| | | On Unix |
| | | ^^^^^^^ |
| | | |
| | | .. code-block:: bash |
| | |
| | | Start the application. See :ref:`what_is_this_pserve_thing` for more |
| | | information on ``pserve``. |
| | | |
| | | On UNIX |
| | | On Unix |
| | | ^^^^^^^ |
| | | |
| | | .. code-block:: bash |
| | |
| | | |
| | | We can run these tests similarly to how we did in :ref:`running_tests`, but first delete the SQLite database ``tutorial.sqlite``. If you do not delete the database, then you will see an integrity error when running the tests. |
| | | |
| | | On UNIX: |
| | | On Unix: |
| | | |
| | | .. code-block:: bash |
| | | |
| | |
| | | when porting your application from an older version of Pyramid. Use the |
| | | ``PYTHONWARNINGS`` environment variable with the value ``all`` in the |
| | | shell you use to invoke ``paster serve`` to see these warnings, e.g. on |
| | | UNIX, ``PYTHONWARNINGS=all $VENV/bin/paster serve development.ini``. |
| | | Unix, ``PYTHONWARNINGS=all $VENV/bin/paster serve development.ini``. |
| | | Python 2.5 and 2.6 show deprecation warnings by default, |
| | | so this is unnecessary there. |
| | | All deprecation warnings are emitted to the console. |