Skip to content

Commit

Permalink
Support installing/running with pipx - fixes #238
Browse files Browse the repository at this point in the history
The curl plugin for peru uses the following as its shebang line:

    #! /usr/bin/env python3

If the user is using pipx, then the system Python interpreter —
`/usr/bin/env python3` —  likely does not have the peru package
installed.

Before this change the curl plugin always uses a `get_version` function
from the peru package and therefore will error if the Python interpreter
does not have the peru package installed.

After this change the curl plugin can succeed with only standard library
modules available.
  • Loading branch information
keith-maxwell-atl committed Jul 26, 2023
1 parent bc8de02 commit 67a806d
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions peru/resources/plugins/curl/curl_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,19 @@
from urllib.error import HTTPError, URLError
from urllib.parse import urlsplit
from urllib.request import Request
import peru.main
import urllib.request
import zipfile

try:
from peru.main import get_version
except ModuleNotFoundError:
get_version = None



def add_user_agent_to_request(request):
components = [
"peru/%s" % peru.main.get_version(),
"peru/%s" % get_version() if get_version else "peru",
urllib.request.URLopener.version
]
request.add_header("User-agent", " ".join(components))
Expand Down

0 comments on commit 67a806d

Please sign in to comment.