Skip to content

Commit

Permalink
[setup] add setup.py; fix 'path' class; change settings file name
Browse files Browse the repository at this point in the history
  • Loading branch information
remico committed Oct 30, 2020
1 parent 22ffa1f commit f47e760
Show file tree
Hide file tree
Showing 26 changed files with 100 additions and 10 deletions.
4 changes: 2 additions & 2 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
"name": "Python: main",
"type": "python",
"request": "launch",
"module": "github_actions",
"module": "actions_gui",
"cwd": "${workspaceFolder}/src",
"env": {
// "QML_IMPORT_TRACE": "1",
// "QML2_IMPORT_PATH": "${workspaceFolder}/src/github_actions",
// "QML2_IMPORT_PATH": "${workspaceFolder}/src/actions-gui",
}
}
]
Expand Down
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"python.languageServer": "Pylance",
"python.linting.pylintEnabled": true,
"python.pythonPath": "/usr/bin/python3.8"
"python.pythonPath": "venv/bin/python"
}
86 changes: 86 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import platform
import setuptools
from pathlib import Path


sources_dir = 'src'

if 'linux' not in platform.system().lower():
raise Exception('The package requires GNU Linux. Aborting installation...')


def version():
return Path(sources_dir, "actions_gui/VERSION").read_text()


def data_files():
files = [str(f) for f in Path(sources_dir, "data").glob("*") if f.is_file()]
return [('actions_gui-data', files)]


def long_description():
return Path("README.md").read_text()


# make the distribution platform dependent
try:
from wheel.bdist_wheel import bdist_wheel as _bdist_wheel
class bdist_wheel(_bdist_wheel):
def finalize_options(self):
_bdist_wheel.finalize_options(self)
self.root_is_pure = False
# self.plat_name_supplied = True
# self.plat_name = "manylinux1_x86_64"
except ImportError:
bdist_wheel = None


setuptools.setup(
name="actions_gui",
version=version(),
author="remico",
author_email="[email protected]",
description="simple ui for a limited set of github actions",
long_description=long_description(),
long_description_content_type="text/markdown",
url="https://github.com/remico/actions",
project_urls={
"Source Code": "https://github.com/remico/actions",
"Documentation": "https://github.com/remico/actions/wiki"
},
packages=setuptools.find_packages(where=sources_dir,
exclude=['sndbx']),
package_dir={
'': sources_dir
},
package_data={
'': ['VERSION',
'ui/*',
'ui/*/*',
'assets/*']
},
data_files=data_files(),
# py_modules=[],
# register executable <command>=<pkg>.<module>:<attr>
entry_points={
'gui_scripts': ['ghactions = actions_gui.main:main']
},
classifiers=[
"Development Status :: 2 - Pre-Alpha",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.8",
"License :: OSI Approved :: MIT License",
"Operating System :: POSIX :: Linux",
],
python_requires='>=3.8',
install_requires=[
# 'PySide2',
# 'requests',
],
license='MIT',
platforms=['POSIX'],
cmdclass={'bdist_wheel': bdist_wheel},
)
1 change: 1 addition & 0 deletions src/actions_gui/VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2020.10.30.dev2301
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes.
6 changes: 2 additions & 4 deletions src/github_actions/main.py → src/actions_gui/main.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import json
import sys

from .path import path
from .pyside2 import *
from .rest import Rest
from .uifactory import UiFactory
from . import webhooklistener
from .worker import WorkerThread


def main():
Expand All @@ -18,8 +16,8 @@ def main():
app_icon = path("assets/icon.svg")
app.setWindowIcon(QIcon(app_icon))

settings_file = path("config.ini")

settings_file = path.home().join(".actions_gui.conf")
print(settings_file)
settings = QSettings(settings_file, QSettings.IniFormat)
(repo_owner := settings.value("owner")) or settings.setValue("owner", "")
(repo_name := settings.value("repo")) or settings.setValue("repo", "")
Expand Down
7 changes: 6 additions & 1 deletion src/github_actions/path.py → src/actions_gui/path.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

from os import getenv
from pathlib import Path

__all__ = ['path']


class path(str):
def __new__(cls, *other):
root = Path(__package__).absolute()
root = Path(__file__).parent.resolve()
return str.__new__(cls, root.joinpath(*other))

def join(self, *other):
return path(Path(self).joinpath(self, *other))

@staticmethod
def home():
return path(getenv('HOME'))
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -84,14 +84,14 @@ def read(self):


def listen_to_webhooks(pipe=None):
settings = QSettings(path("config.ini"), QSettings.IniFormat)
settings = QSettings(path.home().join(".actions_gui.conf"), QSettings.IniFormat)
settings.beginGroup("webhooks")
(domain := settings.value("domain")) or settings.setValue("domain", "")
(local_port := settings.value("local_port")) or settings.setValue("local_port", "")
settings.endGroup()

if not domain or not local_port:
print("@ ERROR: Fill config.ini before running the application")
print("@ ERROR: Bad domain name or port. Adjust config before running the application.")
print("@ Stop http server process.")
sys.exit(1)

Expand Down
File renamed without changes.
File renamed without changes.

0 comments on commit f47e760

Please sign in to comment.