PyPAC


NamePyPAC JSON
Version 0.16.3 PyPI version JSON
download
home_pagehttps://github.com/carsonyl/pypac
SummaryProxy auto-config and auto-discovery for Python.
upload_time2023-04-01 03:45:33
maintainer
docs_urlNone
authorCarson Lam
requires_python!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,>=2.7
licenseApache-2.0
keywords pypac pac proxy autoconfig requests
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            PyPAC: Proxy auto-config for Python
===================================

.. image:: https://img.shields.io/pypi/v/pypac.svg?maxAge=2592000
    :target: https://pypi.python.org/pypi/pypac
.. image:: https://img.shields.io/pypi/pyversions/pypac.svg
    :target: https://pypi.python.org/pypi/pypac
.. image:: https://readthedocs.org/projects/pypac/badge/?version=latest
    :target: https://pypac.readthedocs.io/en/latest/?badge=latest
.. image:: https://github.com/carsonyl/pypac/actions/workflows/tests.yml/badge.svg
    :target: https://github.com/carsonyl/pypac/actions/workflows/tests.yml

PyPAC is a Python library for finding `proxy auto-config (PAC)`_ files and making HTTP requests
that respect them. PAC files are often used in organizations that need fine-grained and centralized control
of proxy settings.

PyPAC can find PAC files according to the DNS portion of the `Web Proxy Auto-Discovery (WPAD)`_ protocol.
On Windows, PyPAC will automatically get the PAC file URL from the Internet Options dialog.
On macOS, PyPAC will automatically get the PAC file URL from System Preferences.

.. _proxy auto-config (PAC): https://en.wikipedia.org/wiki/Proxy_auto-config

PyPAC provides a subclass of a `Requests <http://docs.python-requests.org/en/master/>`_ ``Session``,
so you can start using it immediately, with any PAC file transparently discovered and honoured:

.. code-block:: python

    >>> from pypac import PACSession
    >>> session = PACSession()
    >>> session.get('http://example.org')
    ...

If a PAC file isn't found, then ``PACSession`` behaves like a regular ``Session``.

.. _Web Proxy Auto-Discovery (WPAD): https://en.wikipedia.org/wiki/Web_Proxy_Autodiscovery_Protocol

If you're looking to add *basic* PAC functionality to a library that you're using,
try the ``pac_context_for_url()`` context manager:

.. code-block:: python

   from pypac import pac_context_for_url
   import boto3

   with pac_context_for_url('https://example.amazonaws.com'):
       client = boto3.client('sqs')
       client.list_queues()

This sets up proxy environment variables at the start of the scope, based on any auto-discovered PAC and the given URL.
``pac_context_for_url()`` should work for any library
that honours proxy environment variables.


Features
--------

* The same Requests API that you already know and love
* Honour PAC setting from Windows Internet Options and macOS System Preferences
* Follow DNS Web Proxy Auto-Discovery protocol
* Proxy authentication pass-through
* Proxy failover and load balancing
* Generic components for adding PAC support to other code

PyPAC supports Python 2.7 and 3.5+.


Installation
------------

Install PyPAC using `pip <https://pip.pypa.io>`_::

    $ python -m pip install pypac


Documentation
-------------

PyPAC's documentation is available at http://pypac.readthedocs.io/.

0.16.3 (2023-03-31)
-------------------

- ``isInNet()``: Return False immediately for invalid host arg. (#71)

0.16.2 (2023-03-26)
-------------------

- Handle boolean args to ``isInNet()``. (#69)
- Remove Python 3.5, 3.6 from CIB test matrix.
- Windows Python 2.7 CIB: Pin to dukpy 0.2.3.


0.16.1 (2022-11-08)
-------------------

- Disable ``tldextract`` caching. (#64) Thanks @mpkuth.


0.16.0 (2022-01-01)
-------------------

- Change ``tld`` dependency to ``tldextract``. (#61)


0.15.0 (2021-02-27)
-------------------

- Drop support for Python 3.4. (#48)
- Support more proxy keywords: HTTP, HTTPS, SOCKS4, SOCKS5. (#41)
- Absorb any exception from ``tld.get_tld()``, not just TldDomainNotFound. (#30) Thanks @santiavenda2.
- Reimplement ``dnsDomainIs(host, domain)`` as case-insensitive 'host ends with domain'. (#42, #57)


0.14.0 (2020-12-05)
-------------------

- Add ability to supply ``PACFile`` to ``pac_context_for_url()``. (#52) Thanks @alexrohvarger.


0.13.0 (2019-09-16)
-------------------

- Make it possible to configure the request for the PAC file. (#44) Thanks @SeyfSV.
- urlencode proxy username and password. (#46) Thanks @aslafy-z.


0.12.0 (2018-09-11)
-------------------

- Fix possible error when ``dnsResolve()`` fails. (#34) Thanks @maximinus.


0.11.0 (2018-09-08)
-------------------

- Require dukpy 0.2.2, to fix memory leak. (#32) Thanks @maximinus.
- Change Mac environment marker. (#30)
- Support Python 3.7.


0.10.1 (2018-08-26)
-------------------

- Require tld 0.9.x. (#29)


0.10.0 (2018-08-26)
-------------------

- Switch JavaScript interpreter to dukpy. (#24)
- Fix ``pac_context_for_url()`` erroring with ``DIRECT`` PAC setting. (#27)
- Fix warning about invalid escape sequence (#26). Thanks @BoboTiG.


0.9.0 (2018-06-02)
------------------

- Add macOS support for PAC in System Preferences (#23). Thanks @LKleinNux.
- The `from_registry` argument on `pypac.get_pac()` and `pypac.collect_pac_urls()`
  is now deprecated and will be removed in 1.0.0. Use `from_os_settings` instead.


0.8.1 (2018-03-01)
------------------

- Defer Js2Py import until it's needed. It uses a lot of memory.
  See #20 for details.


0.8.0 (2018-02-28)
------------------

- Add support for ``file://`` PAC URLs on Windows.


0.7.0 (2018-02-21)
------------------

- Drop support for Python 3.3.
- Add doc explaining how to use ``pac_context_for_url()``.
- Internal changes to dev and test processes.


0.6.0 (2018-01-28)
------------------

- Add ``pac_context_for_url()``, a context manager that adds basic PAC functionality
  through proxy environment variables.


0.5.0 (2018-01-18)
------------------

- Accept PAC files served with no ``Content-Type`` header.


0.4.0 (2017-11-07)
------------------

- Add ``recursion_limit`` keyword argument to ``PACSession`` and ``PACFile``.
  The default is an arbitrarily high value (10000), which should cover most applications.
- Exclude port numbers from ``host`` passed to ``FindProxyForURL(url, host)``.


0.3.1 (2017-06-23)
------------------

- Update GitHub username.


0.3.0 (2017-04-12)
------------------
- Windows: Get system auto-proxy config setting using ``winreg`` module.
- Windows: Accept local filesystem paths from system proxy auto-config setting.
- Raise ``PacComplexityError`` when recursion limit is hit while parsing PAC file.
- Support setting ``PACSession.proxy_auth`` and ``ProxyResolver.proxy_auth`` after constructing an instance.
- Narrative docs.


0.2.1 (2017-01-19)
------------------

- Require Js2Py >= 0.43 for Python 3.6 support, and to avoid needing to monkeypatch out ``pyimport``.


0.1.0 (2016-06-12)
------------------

- First release.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/carsonyl/pypac",
    "name": "PyPAC",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,>=2.7",
    "maintainer_email": "",
    "keywords": "pypac,pac,proxy,autoconfig,requests",
    "author": "Carson Lam",
    "author_email": "46059+carsonyl@users.noreply.github.com",
    "download_url": "",
    "platform": null,
    "description": "PyPAC: Proxy auto-config for Python\n===================================\n\n.. image:: https://img.shields.io/pypi/v/pypac.svg?maxAge=2592000\n    :target: https://pypi.python.org/pypi/pypac\n.. image:: https://img.shields.io/pypi/pyversions/pypac.svg\n    :target: https://pypi.python.org/pypi/pypac\n.. image:: https://readthedocs.org/projects/pypac/badge/?version=latest\n    :target: https://pypac.readthedocs.io/en/latest/?badge=latest\n.. image:: https://github.com/carsonyl/pypac/actions/workflows/tests.yml/badge.svg\n    :target: https://github.com/carsonyl/pypac/actions/workflows/tests.yml\n\nPyPAC is a Python library for finding `proxy auto-config (PAC)`_ files and making HTTP requests\nthat respect them. PAC files are often used in organizations that need fine-grained and centralized control\nof proxy settings.\n\nPyPAC can find PAC files according to the DNS portion of the `Web Proxy Auto-Discovery (WPAD)`_ protocol.\nOn Windows, PyPAC will automatically get the PAC file URL from the Internet Options dialog.\nOn macOS, PyPAC will automatically get the PAC file URL from System Preferences.\n\n.. _proxy auto-config (PAC): https://en.wikipedia.org/wiki/Proxy_auto-config\n\nPyPAC provides a subclass of a `Requests <http://docs.python-requests.org/en/master/>`_ ``Session``,\nso you can start using it immediately, with any PAC file transparently discovered and honoured:\n\n.. code-block:: python\n\n    >>> from pypac import PACSession\n    >>> session = PACSession()\n    >>> session.get('http://example.org')\n    ...\n\nIf a PAC file isn't found, then ``PACSession`` behaves like a regular ``Session``.\n\n.. _Web Proxy Auto-Discovery (WPAD): https://en.wikipedia.org/wiki/Web_Proxy_Autodiscovery_Protocol\n\nIf you're looking to add *basic* PAC functionality to a library that you're using,\ntry the ``pac_context_for_url()`` context manager:\n\n.. code-block:: python\n\n   from pypac import pac_context_for_url\n   import boto3\n\n   with pac_context_for_url('https://example.amazonaws.com'):\n       client = boto3.client('sqs')\n       client.list_queues()\n\nThis sets up proxy environment variables at the start of the scope, based on any auto-discovered PAC and the given URL.\n``pac_context_for_url()`` should work for any library\nthat honours proxy environment variables.\n\n\nFeatures\n--------\n\n* The same Requests API that you already know and love\n* Honour PAC setting from Windows Internet Options and macOS System Preferences\n* Follow DNS Web Proxy Auto-Discovery protocol\n* Proxy authentication pass-through\n* Proxy failover and load balancing\n* Generic components for adding PAC support to other code\n\nPyPAC supports Python 2.7 and 3.5+.\n\n\nInstallation\n------------\n\nInstall PyPAC using `pip <https://pip.pypa.io>`_::\n\n    $ python -m pip install pypac\n\n\nDocumentation\n-------------\n\nPyPAC's documentation is available at http://pypac.readthedocs.io/.\n\n0.16.3 (2023-03-31)\n-------------------\n\n- ``isInNet()``: Return False immediately for invalid host arg. (#71)\n\n0.16.2 (2023-03-26)\n-------------------\n\n- Handle boolean args to ``isInNet()``. (#69)\n- Remove Python 3.5, 3.6 from CIB test matrix.\n- Windows Python 2.7 CIB: Pin to dukpy 0.2.3.\n\n\n0.16.1 (2022-11-08)\n-------------------\n\n- Disable ``tldextract`` caching. (#64) Thanks @mpkuth.\n\n\n0.16.0 (2022-01-01)\n-------------------\n\n- Change ``tld`` dependency to ``tldextract``. (#61)\n\n\n0.15.0 (2021-02-27)\n-------------------\n\n- Drop support for Python 3.4. (#48)\n- Support more proxy keywords: HTTP, HTTPS, SOCKS4, SOCKS5. (#41)\n- Absorb any exception from ``tld.get_tld()``, not just TldDomainNotFound. (#30) Thanks @santiavenda2.\n- Reimplement ``dnsDomainIs(host, domain)`` as case-insensitive 'host ends with domain'. (#42, #57)\n\n\n0.14.0 (2020-12-05)\n-------------------\n\n- Add ability to supply ``PACFile`` to ``pac_context_for_url()``. (#52) Thanks @alexrohvarger.\n\n\n0.13.0 (2019-09-16)\n-------------------\n\n- Make it possible to configure the request for the PAC file. (#44) Thanks @SeyfSV.\n- urlencode proxy username and password. (#46) Thanks @aslafy-z.\n\n\n0.12.0 (2018-09-11)\n-------------------\n\n- Fix possible error when ``dnsResolve()`` fails. (#34) Thanks @maximinus.\n\n\n0.11.0 (2018-09-08)\n-------------------\n\n- Require dukpy 0.2.2, to fix memory leak. (#32) Thanks @maximinus.\n- Change Mac environment marker. (#30)\n- Support Python 3.7.\n\n\n0.10.1 (2018-08-26)\n-------------------\n\n- Require tld 0.9.x. (#29)\n\n\n0.10.0 (2018-08-26)\n-------------------\n\n- Switch JavaScript interpreter to dukpy. (#24)\n- Fix ``pac_context_for_url()`` erroring with ``DIRECT`` PAC setting. (#27)\n- Fix warning about invalid escape sequence (#26). Thanks @BoboTiG.\n\n\n0.9.0 (2018-06-02)\n------------------\n\n- Add macOS support for PAC in System Preferences (#23). Thanks @LKleinNux.\n- The `from_registry` argument on `pypac.get_pac()` and `pypac.collect_pac_urls()`\n  is now deprecated and will be removed in 1.0.0. Use `from_os_settings` instead.\n\n\n0.8.1 (2018-03-01)\n------------------\n\n- Defer Js2Py import until it's needed. It uses a lot of memory.\n  See #20 for details.\n\n\n0.8.0 (2018-02-28)\n------------------\n\n- Add support for ``file://`` PAC URLs on Windows.\n\n\n0.7.0 (2018-02-21)\n------------------\n\n- Drop support for Python 3.3.\n- Add doc explaining how to use ``pac_context_for_url()``.\n- Internal changes to dev and test processes.\n\n\n0.6.0 (2018-01-28)\n------------------\n\n- Add ``pac_context_for_url()``, a context manager that adds basic PAC functionality\n  through proxy environment variables.\n\n\n0.5.0 (2018-01-18)\n------------------\n\n- Accept PAC files served with no ``Content-Type`` header.\n\n\n0.4.0 (2017-11-07)\n------------------\n\n- Add ``recursion_limit`` keyword argument to ``PACSession`` and ``PACFile``.\n  The default is an arbitrarily high value (10000), which should cover most applications.\n- Exclude port numbers from ``host`` passed to ``FindProxyForURL(url, host)``.\n\n\n0.3.1 (2017-06-23)\n------------------\n\n- Update GitHub username.\n\n\n0.3.0 (2017-04-12)\n------------------\n- Windows: Get system auto-proxy config setting using ``winreg`` module.\n- Windows: Accept local filesystem paths from system proxy auto-config setting.\n- Raise ``PacComplexityError`` when recursion limit is hit while parsing PAC file.\n- Support setting ``PACSession.proxy_auth`` and ``ProxyResolver.proxy_auth`` after constructing an instance.\n- Narrative docs.\n\n\n0.2.1 (2017-01-19)\n------------------\n\n- Require Js2Py >= 0.43 for Python 3.6 support, and to avoid needing to monkeypatch out ``pyimport``.\n\n\n0.1.0 (2016-06-12)\n------------------\n\n- First release.\n",
    "bugtrack_url": null,
    "license": "Apache-2.0",
    "summary": "Proxy auto-config and auto-discovery for Python.",
    "version": "0.16.3",
    "split_keywords": [
        "pypac",
        "pac",
        "proxy",
        "autoconfig",
        "requests"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "4b4fc0c2a757d3daacc6174768d865afbf705a537419f961112207af58ffd809",
                "md5": "b8a6efbcb1c1dc4eac23e80562526f4a",
                "sha256": "ed47980a47f0079c1ff7a7b28d40a1df5e6f7745afd1fd1115dc315d84d3387b"
            },
            "downloads": -1,
            "filename": "PyPAC-0.16.3-py2.py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "b8a6efbcb1c1dc4eac23e80562526f4a",
            "packagetype": "bdist_wheel",
            "python_version": "py2.py3",
            "requires_python": "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,>=2.7",
            "size": 23015,
            "upload_time": "2023-04-01T03:45:33",
            "upload_time_iso_8601": "2023-04-01T03:45:33.915452Z",
            "url": "https://files.pythonhosted.org/packages/4b/4f/c0c2a757d3daacc6174768d865afbf705a537419f961112207af58ffd809/PyPAC-0.16.3-py2.py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-04-01 03:45:33",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "carsonyl",
    "github_project": "pypac",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "pypac"
}
        
Elapsed time: 0.05641s