Skip to content
This repository has been archived by the owner on Apr 30, 2024. It is now read-only.

Commit

Permalink
Support installing/running with pipx - fixes buildinspace#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
maxwell-k committed Jul 26, 2023
1 parent bc8de02 commit 68fd841
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 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,18 @@
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 68fd841

Please sign in to comment.