From 863d0c991184ef234777a46541bb80c1887a4df6 Mon Sep 17 00:00:00 2001 From: Lukas Westholt Date: Mon, 5 May 2025 23:46:31 +0200 Subject: [PATCH] Feat: Allow usage of atlassian-python-api without BeautifulSoup by set it as extra dependency --- README.rst | 6 ++++++ atlassian/confluence.py | 5 ++++- atlassian/crowd.py | 5 ++++- docs/index.rst | 4 ++++ setup.py | 4 ++-- 5 files changed, 20 insertions(+), 4 deletions(-) diff --git a/README.rst b/README.rst index 25a851766..6c2182534 100644 --- a/README.rst +++ b/README.rst @@ -35,6 +35,12 @@ From PyPI $ pip install atlassian-python-api +And if you want to use Crowd() or Confluence() + +.. code-block:: console + + $ pip install atlassian-python-api[html] + From Source - Git clone repository diff --git a/atlassian/confluence.py b/atlassian/confluence.py index 4e455b3bd..0416c70d6 100644 --- a/atlassian/confluence.py +++ b/atlassian/confluence.py @@ -8,7 +8,10 @@ from typing import cast import requests -from bs4 import BeautifulSoup +try: + from bs4 import BeautifulSoup +except ImportError: + raise ImportError("Please install atlassian-python-api with extra=html like `pip install atlassian-python-api[html]`.") from deprecated import deprecated from requests import HTTPError diff --git a/atlassian/crowd.py b/atlassian/crowd.py index 9d153d37f..91d663bd3 100644 --- a/atlassian/crowd.py +++ b/atlassian/crowd.py @@ -2,7 +2,10 @@ import logging from jmespath import search -from bs4 import BeautifulSoup +try: + from bs4 import BeautifulSoup +except ImportError: + raise ImportError("Please install atlassian-python-api with extra=html like `pip install atlassian-python-api[html]`.") from .rest_client import AtlassianRestAPI diff --git a/docs/index.rst b/docs/index.rst index c7cc920e5..46333f4cf 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -15,6 +15,10 @@ Install package using pip: ``pip install atlassian-python-api`` +and if you want to use Crowd() or Confluence() use: + +``pip install atlassian-python-api[html]`` + Add a connection: .. code-block:: python diff --git a/setup.py b/setup.py index 7a03f9ae6..7a990374a 100644 --- a/setup.py +++ b/setup.py @@ -26,8 +26,8 @@ package_dir={"atlassian": "atlassian"}, include_package_data=True, zip_safe=False, - install_requires=["deprecated", "requests", "oauthlib", "requests_oauthlib", "jmespath", "beautifulsoup4", "typing-extensions"], - extras_require={"kerberos": ["requests-kerberos"]}, + install_requires=["deprecated", "requests", "oauthlib", "requests_oauthlib", "jmespath", "typing-extensions"], + extras_require={"kerberos": ["requests-kerberos"], "html": ["beautifulsoup4"]}, platforms="Platform Independent", classifiers=[ "Development Status :: 4 - Beta",