glfs/general/prog/python-modules/requests.xml
Bruce Dubbs 569925c77f Update python modules for pythonhosted
Move the pythonhoted page to python_modules even though it is not
yet activated to render in the book.

Change location of pythonhosted md5sum ENTITIES to packages.ent
so they can be used in multiple pages but only need to be updated
in one place.

Note that pages not have entries like:
  <!ENTITY asciidoc-md5sum        "&asciidoc-md5sum;">
so this seems to be redefinig the entity to the version
in packages.ent.  This seems to be OK with the build system.
2023-01-31 18:02:12 -06:00

191 lines
6.5 KiB
XML

<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE sect2 PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
"http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
<!ENTITY % general-entities SYSTEM "../../../general.ent">
%general-entities;
<!ENTITY requests-download-http "https://files.pythonhosted.org/packages/source/r/requests/requests-&requests-version;.tar.gz">
<!ENTITY requests-download-ftp " ">
<!ENTITY requests-md5sum "&requests-md5sum;">
<!ENTITY requests-size "106 KB">
<!ENTITY requests-buildsize "1.4 MB (add 129 MB for tests)">
<!ENTITY requests-time "less than 0.1 SBU (0.8 SBU for tests)">
]>
<sect2 id="requests" xreflabel="requests-&requests-version;">
<title>Requests-&requests-version;</title>
<indexterm zone="requests">
<primary sortas="a-requests">requests</primary>
</indexterm>
<sect3 role="package">
<title>Introduction to Requests Module</title>
<para>
The <application>Requests</application> package is an elegant and
simple HTTP library for Python, built for human beings. It allows
sending HTTP/1.1 requests extremely easily.
</para>
&lfs112_checked;
<bridgehead renderas="sect4">Package Information</bridgehead>
<itemizedlist spacing="compact">
<listitem>
<para>
Download (HTTP): <ulink url="&requests-download-http;"/>
</para>
</listitem>
<listitem>
<para>
Download (FTP): <ulink url="&requests-download-ftp;"/>
</para>
</listitem>
<listitem>
<para>
Download MD5 sum: &requests-md5sum;
</para>
</listitem>
<listitem>
<para>
Download size: &requests-size;
</para>
</listitem>
<listitem>
<para>
Estimated disk space required: &requests-buildsize;
</para>
</listitem>
<listitem>
<para>
Estimated build time: &requests-time;
</para>
</listitem>
</itemizedlist>
<bridgehead renderas="sect4">Additional Download</bridgehead>
<itemizedlist spacing="compact">
<listitem>
<para>
Recommended patch: <ulink
url="&patch-root;/requests-&requests-version;-use_system_certs-1.patch"/>
</para>
</listitem>
</itemizedlist>
<bridgehead renderas="sect4">Requests Dependencies</bridgehead>
<bridgehead renderas="sect5">Required</bridgehead>
<para role="required">
<xref linkend="charset-normalizer"/>,
<xref linkend="idna"/>, and
<xref linkend="urllib3"/>
</para>
<bridgehead renderas="sect5">Recommended</bridgehead>
<para role="recommended">
<xref linkend="make-ca"/>, with
<xref linkend="p11-kit"/> (both needed to use system https: certificates,
removing an unnecessary dependency on the <application>Certifi</application>
module).
</para>
<bridgehead renderas="sect5">Optional</bridgehead>
<para role="optional">
<ulink url="https://pypi.org/project/PySocks/">PySocks</ulink> (also needed for testing)
</para>
<bridgehead renderas="sect5">Optional (for testing)</bridgehead>
<para role="optional">
<xref linkend="pytest"/>,
<ulink url="https://pypi.org/project/Flask/">Flask</ulink>&lt;2,
<ulink url="https://pypi.org/project/httpbin/">httpbin</ulink>,
<ulink url="https://pypi.org/project/MarkupSafe/">MarkupSafe</ulink>&lt;2.1,
<ulink url="https://pypi.org/project/pytest-mock/">pytest-mock</ulink>,
<ulink url="https://pypi.org/project/pytest-httpbin/">pytest-httpbin</ulink>,
<ulink url="https://pypi.org/project/sphinx/">sphinx</ulink>&lt;5,
<ulink url="https://pypi.org/project/trustme/">trustme</ulink>, and
<ulink url="https://pypi.org/project/Werkzeug/">Werkzeug</ulink>&lt;2
</para>
</sect3>
<sect3 role="installation">
<title>Installation of Requests</title>
<para>
First apply a patch so that the same environment variable already used to
point to system certificates in <application>Python3</application> following
the installation of <application>make-ca</application> can also be used by
this module:
</para>
<screen><userinput>patch -Np1 -i ../requests-&requests-version;-use_system_certs-1.patch</userinput></screen>
<para> Build the module: </para>
<screen><userinput>pip3 wheel -w dist --no-build-isolation --no-deps $PWD</userinput></screen>
<para>
Now, as the <systemitem class="username">root</systemitem> user:
</para>
<screen role="root"><userinput>pip3 install --no-index --find-links dist --no-cache-dir --no-user requests</userinput></screen>
<para>
Assuming <xref linkend="pytest"/> is installed, but the other optional
dependencies are not, the installation can be tested with the following
commands:
</para>
<screen remap="test"><userinput>python3 -m venv --system-site-packages testenv &amp;&amp;
source testenv/bin/activate &amp;&amp;
pip3 install --force-reinstall sphinx\&lt;5 &amp;&amp;
pip3 install pytest-mock \
werkzeug\&lt;2 \
flask\&lt;2 \
pytest-httpbin \
pysocks \
trustme &amp;&amp;
pip3 install --force-reinstall Markupsafe\&lt;2.1 &amp;&amp;
python3 /usr/bin/pytest tests &amp;&amp;
deactivate</userinput></screen>
<note>
<para>
See <xref linkend="make-ca"/> for how to set the environment variable,
and for how local copies of the Certifi and Requests modules installed
in a virtual environment <emphasis>will</emphasis> override the system
certificates.
</para>
</note>
</sect3>
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
href="../../../xincludes/pip3-cmd-explain.xml"/>
<sect3 role="content">
<title>Contents</title>
<segmentedlist>
<segtitle>Installed Programs</segtitle>
<segtitle>Installed Libraries</segtitle>
<segtitle>Installed Directories</segtitle>
<seglistitem>
<seg>None</seg>
<seg>None</seg>
<seg>
/usr/lib/python&python3-majorver;/site-packages/requests and
/usr/lib/python&python3-majorver;/site-packages/requests-&requests-version;.dist-info
</seg>
</seglistitem>
</segmentedlist>
</sect3>
</sect2>