Skip to content

Commit

Permalink
Make BeautifulSoup optional (#3774)
Browse files Browse the repository at this point in the history
Signed-off-by: Alexander Bonkowski <57258530+ab5424@users.noreply.github.com>
  • Loading branch information
ab5424 committed May 2, 2024
1 parent a9667f7 commit 45de1ae
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 3 deletions.
8 changes: 7 additions & 1 deletion dev_scripts/update_pt_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"


Expand Down Expand Up @@ -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."""

Expand Down
8 changes: 7 additions & 1 deletion pymatgen/io/vasp/help.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 1 addition & 0 deletions requirements-optional.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
ase>=3.22.1
beautifulsoup4==4.12.2
BoltzTraP2>=22.3.2
chemview>=0.6
f90nml>=1.4.3
Expand Down
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 45de1ae

Please sign in to comment.