Skip to content

Commit 0bee3b0

Browse files
cclaussamilcarlucas
authored andcommitted
Add PEP 723 header to scripts/crawl_ardupilot_wiki.py
OPTIONAL!!! Just an approach that I have found useful for scripts with PyPI dependencies. https://peps.python.org/pep-0723 enables Python files to have a header like: ```python # /// script # requires-python = ">=3.9" # dependencies = [ # "requests", # ] # /// ``` which enables: `pipx run scripts/crawl_ardupilot_wiki.py` or `uv run --script scripts/crawl_ardupilot_wiki.py`. When this command is run, `pipx` or `uv` will import the `dependencies` from PyPI, put them in an isolated `venv`, and then run the script in that `venv`. https://thisdavej.com/share-python-scripts-like-a-pro-uv-and-pep-723-for-easy-deploymentAdd PEP 723 header to scripts/crawl_ardupilot_wiki.py
1 parent c8501c0 commit 0bee3b0

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

scripts/crawl_ardupilot_wiki.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
1-
#!/usr/bin/python3
1+
#!/usr/bin/env -S uv run --script
2+
3+
# /// script
4+
# requires-python = ">=3.9"
5+
# dependencies = [
6+
# "beautifulsoup4",
7+
# "requests",
8+
# ]
9+
# ///
210

311
"""
412
Outputs URLs of ArduPilot documentation pages.
@@ -69,7 +77,7 @@ def get_env_proxies() -> Union[dict[str, str], None]:
6977
# Remove None values
7078
proxies_dict: dict[str, str] = {k: v for k, v in proxies_env.items() if v is not None}
7179
# define as None if no proxies are defined in the OS environment variables
72-
proxies = proxies_dict if proxies_dict else None
80+
proxies = proxies_dict or None
7381
if proxies:
7482
logging.info("Proxies: %s", proxies)
7583
else:

0 commit comments

Comments
 (0)