Verified Commit de02c603 authored by Sumner Evans's avatar Sumner Evans 💬

Merge branch '218-python3.8-flatpak' into master

parents 23085cbd 2cb964dc
Pipeline #193176824 failed with stages
in 21 minutes and 44 seconds
image: archlinux
packages:
- dbus
- flatpak
- flatpak-builder
- gobject-introspection
- gtk3
- mpv
- python-cairo
- python-gobject
- python-pip
- python-poetry
- xorg-server-xvfb
sources:
- https://git.sr.ht/~sumner/sublime-music
environment:
REPO_NAME: sublime-music
# triggers:
# - action: email
# condition: failure
# to: ~sumner/sublime-music-devel@lists.sr.ht
tasks:
- build-flatpak: |
cd ${REPO_NAME}/flatpak
sudo REPO=repo ./flatpak_build.sh
image: archlinux
packages:
- dbus
- gobject-introspection
- gtk3
- mpv
- python-cairo
- python-gobject
- python-poetry
- xorg-server-xvfb
sources:
- https://git.sr.ht/~sumner/sublime-music
environment:
REPO_NAME: sublime-music
triggers:
- action: email
condition: failure
to: ~sumner/sublime-music-devel@lists.sr.ht
tasks:
- setup: |
cd ${REPO_NAME}
poetry install
echo "cd ${REPO_NAME}" >> ~/.buildenv
echo "source $(poetry env info -p)/bin/activate" >> ~/.buildenv
- lint: |
python setup.py check -mrs
black --check .
flake8
mypy sublime_music tests/**/*.py
cicd/custom_style_check.py
- test: |
Xvfb :119 -screen 0 1024x768x16 &
export DISPLAY=:119
pytest
- build: |
python setup.py sdist
- deploy-pypi: |
./cicd/run_if_tagged_with_version \
"twine upload -r testpypi dist/*" \
"twine upload dist/*"
- verify-pypi: |
./cicd/run_if_tagged_with_version \
"pip install ${REPO_NAME}"
image: alpine/edge
packages:
- curl
- git
- openssh
- py3-docutils
sources:
- https://git.sr.ht/~sumner/sublime-music
secrets:
# README Personal Access Token
- 2fb5fd72-fa96-46c6-ab90-6b7cabebba16
environment:
REPO_NAME: sublime-music
triggers:
- action: email
condition: failure
to: ~sumner/sublime-music-devel@lists.sr.ht
tasks:
- setup: |
echo "cd ${REPO_NAME}" >> ~/.buildenv
# If we are on the master branch, compile the README.rst to HTML and set it
# as the README for the repo.
- readme: |
set +x
git branch --contains | grep master &&
rst2html5 --no-doc-title README.rst | \
curl -H "Content-Type: text/html" \
-H "Authorization: Bearer $(cat ~/.readme-token)" \
-XPUT \
--data-binary @- \
"https://git.sr.ht/api/repos/${REPO_NAME}/readme" &&
echo "README set" || echo "Skipping README set because not on master"
# Run poetry install and activate the virtualenv
poetry install
source .venv/bin/activate
watch_file pyproject.toml
watch_file poetry.lock
watch_file setup.py
flatpak/flatpak_build_dir/
flatpak/sublime-music.flatpak
flatpak/repo
# Created by https://www.gitignore.io/api/python
# Edit at https://www.gitignore.io/?templates=python
......
......@@ -22,11 +22,11 @@ lint:
before_script:
- ./cicd/install-project-deps.sh
script:
- pipenv run python setup.py check -mrs
- pipenv run black --check .
- pipenv run flake8
- pipenv run mypy sublime tests/**/*.py
- pipenv run cicd/custom_style_check.py
- poetry run python setup.py check -mrs
- poetry run black --check .
- poetry run flake8
- poetry run mypy sublime_music tests/**/*.py
- poetry run cicd/custom_style_check.py
test:
stage: test
......@@ -37,7 +37,7 @@ test:
- Xvfb :119 -screen 0 1024x768x16 &
- export DISPLAY=:119
script:
- pipenv run ./cicd/pytest.sh
- poetry run ./cicd/pytest.sh
artifacts:
paths:
- htmlcov
......@@ -47,7 +47,7 @@ build:
before_script:
- ./cicd/install-project-deps.sh
script:
- pipenv run python setup.py sdist
- poetry run python setup.py sdist
artifacts:
paths:
- dist/*
......@@ -55,7 +55,6 @@ build:
build_flatpak:
image: registry.gitlab.com/sublime-music/sublime-music/flatpak-build:latest
allow_failure: true
stage: build
script:
- cd flatpak
......@@ -116,7 +115,7 @@ publish_release:
before_script:
- ./cicd/install-project-deps.sh
script:
- pipenv run ./cicd/publish-gitlab-release.sh
- poetry run ./cicd/publish-gitlab-release.sh
# Scheduled Jobs
# =============================================================================
......
v0.11.9
=======
**The wait is over!** Thanks to help from jlanda_, the **Flatpak** is back! The
Flatpak requires ``org.gnome.SDK//3.38`` and ``org.gnome.Platform//3.38``.
.. _jlanda: https://gitlab.com/jlanda
**Bug Fixes**
* Fixed regressions with Chromecast playback.
**Infrastructure**
* Switched from Pipenv to Poetry because Poetry is so much faster.
* Added a ``.envrc`` file for direnv users.
* Started migrating from GitLab to sr.ht due to usability regressions in GitLab.
* **Package name change:** The package name is now ``sublime_music`` instead of
``sublime``.
v0.11.8
=======
......
......@@ -83,8 +83,8 @@ Building the flatpak
--------------------
- A flatpak-builder environment must be setup on the build machine to do a
flatpak build. This includes ``org.gnome.SDK//3.34`` and
``org.gnome.Platform//3.34``.
flatpak build. This includes ``org.gnome.SDK//3.36`` and
``org.gnome.Platform//3.36``.
- The ``flatpak`` folder contains the required files to build a flatpak package.
- The script ``flatpak_build.sh`` will run the required commands to grab the
remaining dependencies and build the flatpak.
......@@ -117,6 +117,7 @@ before knowing if your code is the correct style.
* ``flake8-importorder`` (with the ``edited`` import style): enforce ordering
of import statements.
* ``flake8-pep3101``: no ``%`` string formatting.
* ``flake8-print``: to prevent using the ``print`` function.
* `mypy`_ is used for type checking. All type errors must be resolved.
......
[[source]]
name = "pypi"
url = "https://pypi.org/simple"
verify_ssl = true
[dev-packages]
black = "*"
docutils = "*"
flake8 = "*"
flake8-annotations = "*"
flake8-bugbear = "*"
flake8-comprehensions = "*"
flake8-import-order = "*"
flake8-pep3101 = "*"
flake8-print = "*"
graphviz = "*"
lxml = "*"
mypy = "*"
pycodestyle = "*"
pytest = "*"
pytest-cov = "*"
rope = "*"
rst2html5 = "*"
sphinx = "*"
sphinx-rtd-theme = "*"
termcolor = "*"
[packages]
sublime-music = {editable = true, extras = ["chromecast", "keyring", "server"], path = "."}
[requires]
python_version = "3.8"
[pipenv]
allow_prereleases = true
This diff is collapsed.
......@@ -47,7 +47,7 @@ def check_file(path: Path) -> bool:
valid = True
for path in Path("sublime").glob("**/*.py"):
for path in Path("sublime_music").glob("**/*.py"):
valid &= check_file(path)
for path in Path("tests").glob("**/*.py"):
......@@ -56,7 +56,7 @@ for path in Path("tests").glob("**/*.py"):
"""
Checks that the version in the CHANGELOG is the same as the version in ``__init__.py``.
"""
with open(Path("sublime/__init__.py")) as f:
with open(Path("sublime_music/__init__.py")) as f:
for line in f:
if line.startswith("__version__"):
version = eval(line.split()[-1])
......
......@@ -11,5 +11,7 @@ RUN dnf -y update && \
RUN flatpak remote-add --if-not-exists flathub https://dl.flathub.org/repo/flathub.flatpakrepo
RUN flatpak install -y org.gnome.Platform//3.34 && \
flatpak install -y org.gnome.Sdk//3.34
RUN flatpak install -y org.gnome.Platform//3.38 && \
flatpak install -y org.gnome.Sdk//3.38
RUN pip3 install requirements-parser
......@@ -3,5 +3,10 @@ export PYENV_ROOT="${HOME}/.pyenv"
export PATH="${PYENV_ROOT}/bin:$PATH"
eval "$(pyenv init -)"
export PIPENV_VENV_IN_PROJECT=1
pipenv install --dev
apt-get install -y python3-venv
pip3 install poetry
mkdir -p ~/.config/pypoetry/
echo "[virtualenvs]" > ~/.config/pypoetry/config.toml
echo "in-project = true" >> ~/.config/pypoetry/config.toml
poetry install
......@@ -3,7 +3,7 @@
set -xe
pushd docs
pipenv run make html
poetry run make html
popd
mv docs/_build/html public
......
......@@ -40,7 +40,7 @@ RUN apt update && \
RUN cd /usr/local/src && \
curl -L https://github.com/pyenv/pyenv-installer/raw/master/bin/pyenv-installer | bash
RUN pip3 install pipenv
RUN pip3 install poetry
# Install the correct Python version with pyenv
COPY install-python.sh /tmp/install-python.sh
......
#! /usr/bin/env python3
import re
import subprocess
import sys
version_tag_re = re.compile(r"v\d+\.\d+\.\d+")
tags = (
subprocess.run(["git", "tag", "--contains", "HEAD"], capture_output=True)
.stdout.decode()
.strip()
.split()
)
# If one of the tags is a version tag, then run the commands specified in the
# parameters.
for tag in tags:
if match := version_tag_re.match(tag):
print(f"VERSION TAG {tag} FOUND")
# Execute the associated commands, raising an exception if the command
# returns a non-zero value.
for arg in sys.argv[1:]:
print(f"+ {' '.join(arg.split())}")
subprocess.run(arg.split()).check_returncode()
# Don't run the else statement of the for loop.
break
else:
print("No version tag found for this commit. Skipping")
......@@ -11,7 +11,7 @@ BUILDDIR = _build
SPHINXDOCBUILD = sphinx-apidoc
SPHINXDOCOPTS = -f -e -T
DOCSSOURCE = ./api/
PROJECTDIR = ../sublime/
PROJECTDIR = ../sublime_music/
# Put it first so that "make" without argument is like "make help".
help:
......
......@@ -8,8 +8,8 @@ server, data on the local filesystem, or even an entirely different service.
This document is designed to help you understand the Adapter API so that you can
create your own custom adapters. This document is best read in conjunction with
the :class:`sublime.adapters.Adapter` documentation. This document is meant as a
guide to tell you a general order in which to implement things.
the :class:`sublime_music.adapters.Adapter` documentation. This document is
meant as a guide to tell you a general order in which to implement things.
Terms
=====
......@@ -35,8 +35,8 @@ Creating Your Adapter Class
An adapter is composed of a single Python module. The adapter module can have
arbitrary code, and as many files/classes/functions/etc. as necessary, however
there must be one and only one class in the module which inherits from the
:class:`sublime.adapters.Adapter` class. Normally, a single file with a single
class should be enough to implement the entire adapter.
:class:`sublime_music.adapters.Adapter` class. Normally, a single file with a
single class should be enough to implement the entire adapter.
.. warning::
......@@ -49,16 +49,16 @@ class should be enough to implement the entire adapter.
After you've created the class, you will want to implement the following
functions and properties first:
* ``get_ui_info``: Returns a :class:`sublime.adapters.UIInfo` with the info for
the adapter.
* ``get_ui_info``: Returns a :class:`sublime_music.adapters.UIInfo` with the
info for the adapter.
* ``__init__``: Used to initialize your adapter. See the
:class:`sublime.adapters.Adapter.__init__` documentation for the function
signature of the ``__init__`` function.
:class:`sublime_music.adapters.Adapter.__init__` documentation for the
function signature of the ``__init__`` function.
* ``ping_status``: Assuming that your adapter requires connection to the
internet, this property needs to be implemented. (If your adapter doesn't
require connection to the internet, set
:class:`sublime.adapters.Adapter.is_networked` to ``False`` and ignore the
rest of this bullet point.)
:class:`sublime_music.adapters.Adapter.is_networked` to ``False`` and ignore
the rest of this bullet point.)
This property will tell the UI whether or not the underlying server can be
pinged.
......@@ -80,12 +80,12 @@ functions and properties first:
If you don't want to implement all of the GTK logic yourself, and just want a
simple form, then you can use the
:class:`sublime.adapters.ConfigureServerForm` class to generate a form in a
declarative manner.
:class:`sublime_music.adapters.ConfigureServerForm` class to generate a form
in a declarative manner.
.. note::
The :class:`sublime.adapters.Adapter` class is an `Abstract Base Class
The :class:`sublime_music.adapters.Adapter` class is an `Abstract Base Class
<abc_>`_ and all required functions are annotated with the
``@abstractmethod`` decorator. This means that your adapter will fail to
instantiate if the abstract methods are not implemented.
......@@ -102,21 +102,21 @@ must do the following:
name must be unique within your adapter.
2. Add a new entry to the return value of your
:class:`sublime.adapters.Adapter.get_config_parameters` function with the key
being the name from (1), and the value being a
:class:`sublime.adapters.ConfigParamDescriptor`. The order of the keys in the
dictionary matters, since the UI uses that to determine the order in which
the configuration parameters will be shown in the UI.
:class:`sublime_music.adapters.Adapter.get_config_parameters` function with
the key being the name from (1), and the value being a
:class:`sublime_music.adapters.ConfigParamDescriptor`. The order of the keys
in the dictionary matters, since the UI uses that to determine the order in
which the configuration parameters will be shown in the UI.
3. Add any verifications that are necessary for your configuration parameter in
your :class:`sublime.adapters.Adapter.verify_configuration` function. If you
parameter descriptor has ``required = True``, then that parameter is
your :class:`sublime_music.adapters.Adapter.verify_configuration` function.
If you parameter descriptor has ``required = True``, then that parameter is
guaranteed to appear in the configuration.
4. The configuration parameter will be passed into your
:class:`sublime.adapters.Adapter.init` function. It is guaranteed that the
``verify_configuration`` will have been called first, so there is no need to
re-verify the config that is passed.
:class:`sublime_music.adapters.Adapter.init` function. It is guaranteed that
the ``verify_configuration`` will have been called first, so there is no need
to re-verify the config that is passed.
Implementing Data Retrieval Methods
-----------------------------------
......
......@@ -26,13 +26,13 @@ author = "Sumner Evans"
gitlab_url = "https://gitlab.com/sublime-music/sublime-music/"
# Get the version from the package.
module_name = "sublime"
init_file = Path(__file__).parent.parent.joinpath("sublime/__init__.py").resolve()
module_name = "sublime_music"
init_file = Path(__file__).parent.parent.joinpath("sublime_music/__init__.py").resolve()
spec = importlib.util.spec_from_file_location(module_name, str(init_file))
sublime = importlib.util.module_from_spec(spec)
spec.loader.exec_module(sublime)
sublime_music = importlib.util.module_from_spec(spec)
spec.loader.exec_module(sublime_music)
version = release = f"v{sublime.__version__}"
version = release = f"v{sublime_music.__version__}"
# -- General configuration ---------------------------------------------------
......
{
"app-id": "app.sublimemusic.SublimeMusic",
"runtime": "org.gnome.Platform",
"runtime-version": "3.34",
"runtime-version": "3.38",
"sdk": "org.gnome.Sdk",
"command": "sublime-music",
"rename-icon": "sublime-music",
......@@ -20,11 +20,12 @@
"--socket=wayland",
"--share=network",
"--socket=pulseaudio",
"--socket=session-bus",
"--talk-name=org.freedesktop.Notifications",
"--own-name=org.mpris.MediaPlayer2.SublimeMusic",
"--filesystem=xdg-config/sublime-music",
"--filesystem=xdg-cache/sublime-music",
"--filesystem=xdg-data/sublime-music"
"--filesystem=xdg-data/sublime-music",
"--env=TMPDIR=/tmp"
],
"modules": [
{
......@@ -66,6 +67,9 @@
"build-commands": [
"pip3 install --prefix=/app ."
],
"build-options": {
"build-args": [ "--share=network" ]
},
"sources": [
{
"type": "dir",
......@@ -101,51 +105,6 @@
}
],
"modules": [
{
"name": "python-3.8",
"sources": [
{
"type": "archive",
"url": "https://www.python.org/ftp/python/3.8.3/Python-3.8.3.tar.xz",
"sha256": "dfab5ec723c218082fe3d5d7ae17ecbdebffa9a1aea4d64aa3a2ecdd2e795864"
}
],
"config-opts": [
"--enable-shared",
"--with-ensurepip=yes",
"--with-system-expat",
"--with-system-ffi",
"--enable-loadable-sqlite-extensions",
"--with-dbmliborder=gdbm",
"--enable-unicode=ucs4"
],
"post-install": [
"chmod 644 $FLATPAK_DEST/lib/libpython3.8.so.1.0"
],
"cleanup": [
"/bin/2to3*",
"/bin/easy_install*",
"/bin/idle*",
"/bin/pydoc*",
"/bin/python*-config",
"/bin/pyvenv*",
"/include",
"/lib/pkgconfig",
"/lib/python*/config",
"/share",
"/lib/python*/test",
"/lib/python*/*/test",
"/lib/python*/*/tests",
"/lib/python*/lib-tk/test",
"/lib/python*/lib-dynload/_*_test.*.so",
"/lib/python*/lib-dynload/_test*.*.so",
"/lib/python*/idlelib",
"/lib/python*/tkinter*",
"/lib/python*/turtle*",
"/lib/python*/lib2to3*",
"/lib/python3.8/config/libpython3.8.a"
]
},
{
"name": "luajit",
"no-autogen": true,
......
bleach==3.2.1
bottle==0.12.18
casttube==0.2.1
certifi==2020.4.5.1
certifi==2020.6.20
chardet==3.0.4
dataclasses-json==0.4.4
deepdiff==4.3.2
dataclasses-json==0.5.
deepdiff==5.0.2
fuzzywuzzy==0.18.0