forked from pool/python-browsers
Introduce python-browsers
OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-browsers?expand=0&rev=1
This commit is contained in:
23
.gitattributes
vendored
Normal file
23
.gitattributes
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
## Default LFS
|
||||
*.7z filter=lfs diff=lfs merge=lfs -text
|
||||
*.bsp filter=lfs diff=lfs merge=lfs -text
|
||||
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
||||
*.gem filter=lfs diff=lfs merge=lfs -text
|
||||
*.gz filter=lfs diff=lfs merge=lfs -text
|
||||
*.jar filter=lfs diff=lfs merge=lfs -text
|
||||
*.lz filter=lfs diff=lfs merge=lfs -text
|
||||
*.lzma filter=lfs diff=lfs merge=lfs -text
|
||||
*.obscpio filter=lfs diff=lfs merge=lfs -text
|
||||
*.oxt filter=lfs diff=lfs merge=lfs -text
|
||||
*.pdf filter=lfs diff=lfs merge=lfs -text
|
||||
*.png filter=lfs diff=lfs merge=lfs -text
|
||||
*.rpm filter=lfs diff=lfs merge=lfs -text
|
||||
*.tbz filter=lfs diff=lfs merge=lfs -text
|
||||
*.tbz2 filter=lfs diff=lfs merge=lfs -text
|
||||
*.tgz filter=lfs diff=lfs merge=lfs -text
|
||||
*.ttf filter=lfs diff=lfs merge=lfs -text
|
||||
*.txz filter=lfs diff=lfs merge=lfs -text
|
||||
*.whl filter=lfs diff=lfs merge=lfs -text
|
||||
*.xz filter=lfs diff=lfs merge=lfs -text
|
||||
*.zip filter=lfs diff=lfs merge=lfs -text
|
||||
*.zst filter=lfs diff=lfs merge=lfs -text
|
||||
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
.osc
|
||||
3
_multibuild
Normal file
3
_multibuild
Normal file
@@ -0,0 +1,3 @@
|
||||
<multibuild>
|
||||
<package>test</package>
|
||||
</multibuild>
|
||||
10
_service
Normal file
10
_service
Normal file
@@ -0,0 +1,10 @@
|
||||
<services>
|
||||
<service name="obs_scm" mode="disabled">
|
||||
<param name="url">https://github.com/roniemartinez/browsers</param>
|
||||
<param name="scm">git</param>
|
||||
<param name="versionformat">@PARENT_TAG@</param>
|
||||
<param name="revision">refs/tags/0.5.2</param>
|
||||
<param name="changesgenerate">enable</param>
|
||||
</service>
|
||||
<service name="set_version" mode="disabled"/>
|
||||
</services>
|
||||
4
_servicedata
Normal file
4
_servicedata
Normal file
@@ -0,0 +1,4 @@
|
||||
<servicedata>
|
||||
<service name="tar_scm">
|
||||
<param name="url">https://github.com/roniemartinez/browsers</param>
|
||||
<param name="changesrevision">904662c83fdc0397c482dfad9fae670289167bcd</param></service></servicedata>
|
||||
3
browsers-0.5.2.obscpio
Normal file
3
browsers-0.5.2.obscpio
Normal file
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:ae4369a5603ff095b8332605cfe5a4b3a17783f4e56d991fb5e4728c6d7935bd
|
||||
size 80395
|
||||
4
browsers.obsinfo
Normal file
4
browsers.obsinfo
Normal file
@@ -0,0 +1,4 @@
|
||||
name: browsers
|
||||
version: 0.5.2
|
||||
mtime: 1671210338
|
||||
commit: 904662c83fdc0397c482dfad9fae670289167bcd
|
||||
11
chromium.patch
Normal file
11
chromium.patch
Normal file
@@ -0,0 +1,11 @@
|
||||
--- a/browsers/linux.py 2023-04-19 23:19:27.970310924 +0200
|
||||
+++ b/browsers/linux.py 2023-04-20 00:27:12.388333281 +0200
|
||||
@@ -9,7 +9,7 @@
|
||||
LINUX_DESKTOP_ENTRY_LIST = (
|
||||
# desktop entry name can be "firefox.desktop" or "firefox_firefox.desktop"
|
||||
("chrome", ("google-chrome",)),
|
||||
- ("chromium", ("chromium", "chromium_chromium")),
|
||||
+ ("chromium", ("chromium", "chromium-browser")),
|
||||
("firefox", ("firefox", "firefox_firefox")),
|
||||
("msedge", ("microsoft-edge",)),
|
||||
("opera", ("opera_opera",)),
|
||||
4
python-browsers.changes
Normal file
4
python-browsers.changes
Normal file
@@ -0,0 +1,4 @@
|
||||
-------------------------------------------------------------------
|
||||
Wed Apr 19 21:22:36 UTC 2023 - Georg Pfuetzenreuter <georg.pfuetzenreuter@suse.com>
|
||||
|
||||
- Initial package
|
||||
97
python-browsers.spec
Normal file
97
python-browsers.spec
Normal file
@@ -0,0 +1,97 @@
|
||||
#
|
||||
# spec file for package python-browsers
|
||||
#
|
||||
# Copyright (c) 2023 Georg Pfuetzenreuter <mail+rpm@georg-pfuetzenreuter.net>
|
||||
#
|
||||
# All modifications and additions to the file contributed by third parties
|
||||
# remain the property of their copyright owners, unless otherwise agreed
|
||||
# upon. The license for this file, and modifications and additions to the
|
||||
# file, is the same license as for the pristine package itself (unless the
|
||||
# license for the pristine package is not an Open Source License, in which
|
||||
# case the license is the MIT License). An "Open Source License" is a
|
||||
# license that conforms to the Open Source Definition (Version 1.9)
|
||||
# published by the Open Source Initiative.
|
||||
|
||||
# Please submit bugfixes or comments via https://bugs.opensuse.org/
|
||||
#
|
||||
|
||||
|
||||
%global flavor @BUILD_FLAVOR@%{nil}
|
||||
%if "%{flavor}" == "test"
|
||||
%define psuffix -test
|
||||
%bcond_without test
|
||||
%else
|
||||
%define psuffix %{nil}
|
||||
%bcond_with test
|
||||
%endif
|
||||
%define appname browsers
|
||||
Name: python-%{appname}%{psuffix}
|
||||
Version: 0.5.2
|
||||
Release: 0
|
||||
Summary: Library for detecting and launching browsers
|
||||
License: MIT
|
||||
URL: https://github.com/roniemartinez/browsers
|
||||
Source: _service
|
||||
# - test with Chromium instead of unavailable proprietary Chrome
|
||||
# - adjust Firefox .desktop entry name
|
||||
# - add Firefox to launch test
|
||||
Patch0: test.patch
|
||||
# - adjust Chromium .desktop file name
|
||||
Patch1: chromium.patch
|
||||
BuildRequires: %{python_module pip}
|
||||
BuildRequires: %{python_module poetry}
|
||||
BuildRequires: %{pythons}
|
||||
BuildRequires: fdupes
|
||||
BuildRequires: python-rpm-macros
|
||||
Requires: python3-pyxdg
|
||||
Provides: python3-pybrowsers
|
||||
BuildArch: noarch
|
||||
# Browsers like Chromium are not built for other architectures
|
||||
ExclusiveArch: aarch64 riscv64 x86_64
|
||||
%if %{with test}
|
||||
BuildRequires: %{python_module browsers}
|
||||
BuildRequires: %{python_module pytest-cov}
|
||||
BuildRequires: %{python_module pytest}
|
||||
BuildRequires: %{python_module pyxdg}
|
||||
BuildRequires: MozillaFirefox
|
||||
BuildRequires: chromium
|
||||
# Firefox needs /etc/os-release
|
||||
BuildRequires: distribution-release
|
||||
%endif
|
||||
%python_subpackages
|
||||
|
||||
%description
|
||||
Python library for detecting and launching browsers
|
||||
|
||||
%prep
|
||||
%autosetup -p1 -DTn %{_sourcedir}/%{appname}-%{version}
|
||||
sed -i '/pywin32/d' pyproject.toml
|
||||
|
||||
%build
|
||||
%if !%{with test}
|
||||
%pyproject_wheel
|
||||
%endif
|
||||
|
||||
%install
|
||||
%if !%{with test}
|
||||
%pyproject_install
|
||||
%python_expand %fdupes %{buildroot}%{$python_sitelib}/%{appname}
|
||||
%endif
|
||||
|
||||
%if %{with test}
|
||||
%check
|
||||
%python_expand $python -m poetry config --local virtualenvs.in-project true && $python -m poetry run pytest
|
||||
rm -r /home/abuild/.config
|
||||
%endif
|
||||
|
||||
%if !%{with test}
|
||||
%files %{python_files}
|
||||
%license LICENSE
|
||||
%doc README.md
|
||||
%dir %{python_sitelib}/%{appname}
|
||||
%{python_sitelib}/py%{appname}-%{version}*-info
|
||||
%{python_sitelib}/%{appname}/*.py
|
||||
%pycache_only %{python_sitelib}/%{appname}/__pycache__
|
||||
%endif
|
||||
|
||||
%changelog
|
||||
93
test.patch
Normal file
93
test.patch
Normal file
@@ -0,0 +1,93 @@
|
||||
--- a/tests/test_detect.py 2023-04-20 01:43:34.761649487 +0200
|
||||
+++ b/tests/test_detect.py 2023-04-20 01:43:56.461768969 +0200
|
||||
@@ -14,7 +14,7 @@
|
||||
@pytest.mark.parametrize(
|
||||
"browser",
|
||||
(
|
||||
- pytest.param("chrome", id="chrome"),
|
||||
+ pytest.param("chromium", id="chromium"),
|
||||
pytest.param("firefox", id="firefox"),
|
||||
pytest.param("safari", id="safari", marks=pytest.mark.skipif(sys.platform != "darwin", reason="osx-only")),
|
||||
pytest.param(
|
||||
@@ -76,21 +76,21 @@
|
||||
id="msedge-osx",
|
||||
),
|
||||
pytest.param(
|
||||
- "chrome",
|
||||
+ "chromium",
|
||||
{
|
||||
- "browser_type": "chrome",
|
||||
- "display_name": "Google Chrome",
|
||||
- "path": "/usr/bin/google-chrome-stable",
|
||||
+ "browser_type": "chromium",
|
||||
+ "display_name": "Chromium Web Browser",
|
||||
+ "path": "/usr/bin/chromium-browser",
|
||||
"version": ANY,
|
||||
},
|
||||
marks=pytest.mark.skipif(sys.platform != "linux", reason="linux-only"),
|
||||
- id="chrome-linux",
|
||||
+ id="chromium-linux",
|
||||
),
|
||||
pytest.param(
|
||||
"firefox",
|
||||
{
|
||||
"browser_type": "firefox",
|
||||
- "display_name": "Firefox Web Browser",
|
||||
+ "display_name": "Firefox",
|
||||
"path": "firefox",
|
||||
"version": ANY,
|
||||
},
|
||||
--- a/tests/test_launch.py 2023-04-20 01:43:34.761649487 +0200
|
||||
+++ b/tests/test_launch.py 2023-04-20 01:44:34.041975888 +0200
|
||||
@@ -11,30 +11,36 @@
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
- "chrome_path",
|
||||
+ "chromium_path",
|
||||
(
|
||||
pytest.param(
|
||||
- "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome",
|
||||
- id="osx",
|
||||
- marks=pytest.mark.skipif(sys.platform != "darwin", reason="osx-only"),
|
||||
- ),
|
||||
- pytest.param(
|
||||
- "/usr/bin/google-chrome-stable",
|
||||
- id="linux",
|
||||
+ "/usr/bin/chromium-browser",
|
||||
+ id="chromium-linux",
|
||||
marks=pytest.mark.skipif(sys.platform != "linux", reason="linux-only"),
|
||||
),
|
||||
+ ),
|
||||
+)
|
||||
+
|
||||
+@mock.patch.object(browsers, "_launch")
|
||||
+def test_launch_chromium(mock_launch: mock.MagicMock, chromium_path: str) -> None:
|
||||
+ browsers.launch("chromium", url="file:///tmp/dummy.html")
|
||||
+ mock_launch.assert_called_with("chromium", chromium_path, [], "file:///tmp/dummy.html")
|
||||
+
|
||||
+@pytest.mark.parametrize(
|
||||
+ "firefox_path",
|
||||
+ (
|
||||
pytest.param(
|
||||
- r"C:\Program Files\Google\Chrome\Application\chrome.exe",
|
||||
- id="windows",
|
||||
- marks=pytest.mark.skipif(sys.platform != "win32", reason="windows-only"),
|
||||
+ "firefox",
|
||||
+ id="firefox-linux",
|
||||
+ marks=pytest.mark.skipif(sys.platform != "linux", reason="linux-only"),
|
||||
),
|
||||
),
|
||||
)
|
||||
-@mock.patch.object(browsers, "_launch")
|
||||
-def test_launch(mock_launch: mock.MagicMock, chrome_path: str) -> None:
|
||||
- browsers.launch("chrome", url="https://github.com/roniemartinez/browsers")
|
||||
- mock_launch.assert_called_with("chrome", chrome_path, [], "https://github.com/roniemartinez/browsers")
|
||||
|
||||
+@mock.patch.object(browsers, "_launch")
|
||||
+def test_launch_firefox(mock_launch: mock.MagicMock, firefox_path: str) -> None:
|
||||
+ browsers.launch("firefox", url="file:///tmp/dummy.html")
|
||||
+ mock_launch.assert_called_with("firefox", firefox_path, [], "file:///tmp/dummy.html")
|
||||
|
||||
@mock.patch.object(browsers, "_launch")
|
||||
def test_launch_no_browser(mock_launch: mock.MagicMock) -> None:
|
||||
Reference in New Issue
Block a user