diff --git a/dev_scripts/update_pt_data.py b/dev_scripts/update_pt_data.py index 8799adef19b..58bdc301f99 100644 --- a/dev_scripts/update_pt_data.py +++ b/dev_scripts/update_pt_data.py @@ -11,12 +11,17 @@ from itertools import product import requests -from bs4 import BeautifulSoup +from monty.dev import requires from monty.serialization import dumpfn, loadfn from ruamel import yaml from pymatgen.core import Element, get_el_sp +try: + from bs4 import BeautifulSoup +except ImportError: + BeautifulSoup = None + ptable_yaml_path = "periodic_table.yaml" @@ -231,6 +236,7 @@ def gen_iupac_ordering(): periodic_table[el]["IUPAC ordering"] = iupac_ordering_dict[get_el_sp(el)] +@requires(BeautifulSoup, "BeautifulSoup must be installed to use this method.") def add_electron_affinities(): """Update the periodic table data file with electron affinities.""" diff --git a/pymatgen/io/vasp/help.py b/pymatgen/io/vasp/help.py index f057cb09b81..92c54913caf 100644 --- a/pymatgen/io/vasp/help.py +++ b/pymatgen/io/vasp/help.py @@ -5,12 +5,18 @@ import re import requests -from bs4 import BeautifulSoup +from monty.dev import requires + +try: + from bs4 import BeautifulSoup +except ImportError: + BeautifulSoup = None class VaspDoc: """A VASP documentation helper.""" + @requires(BeautifulSoup, "BeautifulSoup must be installed to fetch from the VASP wiki.") def __init__(self) -> None: """Init for VaspDoc.""" self.url_template = "http://www.vasp.at/wiki/index.php/%s" diff --git a/requirements-optional.txt b/requirements-optional.txt index b5a29956285..2c5019a6523 100644 --- a/requirements-optional.txt +++ b/requirements-optional.txt @@ -1,4 +1,5 @@ ase>=3.22.1 +beautifulsoup4==4.12.2 BoltzTraP2>=22.3.2 chemview>=0.6 f90nml>=1.4.3 diff --git a/requirements.txt b/requirements.txt index 2794ea355e0..384479945c4 100644 --- a/requirements.txt +++ b/requirements.txt @@ -11,7 +11,6 @@ spglib==2.1.0 pandas==2.1.1 networkx==3.1 plotly==5.17.0 -beautifulsoup4==4.12.2 uncertainties==3.1.7 Cython==3.0.2 pybtex==0.24.0