Skip to content

Commit 45de1ae

Browse files
authored
Make BeautifulSoup optional (#3774)
Signed-off-by: Alexander Bonkowski <57258530+ab5424@users.noreply.github.com>
1 parent a9667f7 commit 45de1ae

File tree

4 files changed

+15
-3
lines changed

4 files changed

+15
-3
lines changed

dev_scripts/update_pt_data.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,17 @@
1111
from itertools import product
1212

1313
import requests
14-
from bs4 import BeautifulSoup
14+
from monty.dev import requires
1515
from monty.serialization import dumpfn, loadfn
1616
from ruamel import yaml
1717

1818
from pymatgen.core import Element, get_el_sp
1919

20+
try:
21+
from bs4 import BeautifulSoup
22+
except ImportError:
23+
BeautifulSoup = None
24+
2025
ptable_yaml_path = "periodic_table.yaml"
2126

2227

@@ -231,6 +236,7 @@ def gen_iupac_ordering():
231236
periodic_table[el]["IUPAC ordering"] = iupac_ordering_dict[get_el_sp(el)]
232237

233238

239+
@requires(BeautifulSoup, "BeautifulSoup must be installed to use this method.")
234240
def add_electron_affinities():
235241
"""Update the periodic table data file with electron affinities."""
236242

pymatgen/io/vasp/help.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,18 @@
55
import re
66

77
import requests
8-
from bs4 import BeautifulSoup
8+
from monty.dev import requires
9+
10+
try:
11+
from bs4 import BeautifulSoup
12+
except ImportError:
13+
BeautifulSoup = None
914

1015

1116
class VaspDoc:
1217
"""A VASP documentation helper."""
1318

19+
@requires(BeautifulSoup, "BeautifulSoup must be installed to fetch from the VASP wiki.")
1420
def __init__(self) -> None:
1521
"""Init for VaspDoc."""
1622
self.url_template = "http://www.vasp.at/wiki/index.php/%s"

requirements-optional.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
ase>=3.22.1
2+
beautifulsoup4==4.12.2
23
BoltzTraP2>=22.3.2
34
chemview>=0.6
45
f90nml>=1.4.3

requirements.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ spglib==2.1.0
1111
pandas==2.1.1
1212
networkx==3.1
1313
plotly==5.17.0
14-
beautifulsoup4==4.12.2
1514
uncertainties==3.1.7
1615
Cython==3.0.2
1716
pybtex==0.24.0

0 commit comments

Comments
 (0)