Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make compatible with arm64 brew, test on older and latest macos, strip away no longer needed windows test env exclusion #197

Merged
merged 5 commits into from
Apr 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ jobs:
fail-fast: false
matrix:
os:
- macos-12
- macos-latest
- windows-latest
- ubuntu-latest
Expand All @@ -37,18 +38,25 @@ jobs:
- 'pypy-3.9'
- 'pypy-3.10'
toxenv: [py]
exclude:
# No older Pythons on arm64 macos-latest
- python-version: '3.7'
os: macos-latest
- python-version: '3.8'
os: macos-latest
- python-version: '3.9'
os: macos-latest
- python-version: 'pypy-3.8'
os: macos-latest
- python-version: 'pypy-3.9'
os: macos-latest
include:
- python-version: '3.7'
toxenv: lint
os: ubuntu-latest
- python-version: '3.7'
toxenv: typing
os: ubuntu-latest
exclude:
# venv seems to be broken on pypy3 under Windows.
- python-version: 'pypy-3.7'
toxenv: py
os: windows-latest
steps:
- name: Check out repository
uses: actions/checkout@v4
Expand Down
12 changes: 9 additions & 3 deletions src/datalad_installer.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
from email import policy
from email.headerregistry import ContentTypeHeader
from enum import Enum
from functools import total_ordering
from functools import lru_cache, total_ordering
from getopt import GetoptError, getopt
from html.parser import HTMLParser
from http.client import HTTPMessage
Expand Down Expand Up @@ -1612,8 +1612,9 @@ def install_package(
runcmd("brew", "doctor")
raise
### TODO: Handle variations in this path (Is it "$(brew --prefix)/bin"?)
log.debug("Installed program directory: /usr/local/bin")
return Path("/usr/local/bin")
bin_dir = get_brew_bin_dir()
log.debug("Installed program directory: %s", bin_dir)
return bin_dir

def assert_supported_system(self, **_kwargs: Any) -> None:
if shutil.which("brew") is None:
Expand Down Expand Up @@ -2961,6 +2962,11 @@ def check_exists(path: Path) -> bool:
return os.path.exists(path)


@lru_cache()
def get_brew_bin_dir() -> Path:
return Path(readcmd("brew", "--prefix").rstrip(os.linesep)) / "bin"


def parse_links(html: str, base_url: Optional[str] = None) -> list[Link]:
"""
Parse the source of an HTML page and return a list of all hyperlinks found
Expand Down
12 changes: 11 additions & 1 deletion test/test_install.py
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,17 @@ def test_install_git_annex_brew(mocker: MockerFixture) -> None:
spy = mocker.spy(datalad_installer, "runcmd")
r = main(["datalad_installer.py", "git-annex", "-m", "brew"])
assert r == 0
assert spy.call_args_list[-1] == mocker.call("brew", "install", "git-annex")

# where to look for the "brew install" invocation
target_index = -1
# we might have checked also for the brew --prefix
if spy.call_args_list[-1] == mocker.call(
"brew", "--prefix", stdout=-1, universal_newlines=True
):
target_index -= 1
assert spy.call_args_list[target_index] == mocker.call(
"brew", "install", "git-annex"
)
assert shutil.which("git-annex") is not None


Expand Down
Loading