Replace main Makefiles with poethepoet

This commit is contained in:
Dan Yeaw 2021-07-18 22:19:00 -04:00
parent ddb167f7e4
commit cf7d10f379
No known key found for this signature in database
GPG Key ID: 42239C515C9B9841
7 changed files with 122 additions and 79 deletions

View File

@ -49,9 +49,9 @@ jobs:
id: meta
run: .github/scripts/metadata.sh
- name: Install Python Dependencies
run: make install
run: poetry install
- name: Test with Pytest
run: xvfb-run make test-all
run: xvfb-run poe test-all
- name: Upload Code Coverage to Code Climate
uses: paambaati/codeclimate-action@v2.7.5
env:
@ -59,7 +59,7 @@ jobs:
with:
coverageCommand: poetry run coverage xml
- name: Create Source Dist and Wheel
run: make dist
run: poe dist
- name: Upload gaphor-${{ steps.meta.outputs.version }}.tar.gz
uses: actions/upload-artifact@v2
with:
@ -72,8 +72,7 @@ jobs:
path: dist/gaphor-${{ steps.meta.outputs.version }}-py3-none-any.whl
- name: Build AppImage
run: |
cd packaging
make all
poe pyinstall
cd appimage
make dist
- name: Upload gaphor-${{ steps.meta.outputs.version }}-x86_64.AppImage
@ -135,19 +134,17 @@ jobs:
- name: Install Python Dependencies
run: |
source .venv/bin/activate
mingw32-make install
poe install
- name: Test with PyTest
run: |
source .venv/bin/activate
mingw32-make test-all
poe test-all
- name: Create Windows Installers
run: |
source .venv/bin/activate
mingw32-make dist
cd packaging
mingw32-make all
cd windows
python build-win-installer.py
poe dist
poe package
poe win-installer
- name: Sign Executables
env:
password: "${{ secrets.CERTPASSWORD }}"
@ -213,9 +210,9 @@ jobs:
key: ${{ runner.os }}-poetry-${{ hashFiles('**/poetry.lock') }}
restore-keys: ${{ runner.os }}-poetry-
- name: Install Python Dependencies
run: make install
run: poetry install
- name: Test with Pytest
run: make test-all
run: poe test-all
- name: Import codesign certificate
uses: apple-actions/import-codesign-certs@v1.0.4
if: env.SECRETS_AVAILABLE != null && env.NOT_PR
@ -224,9 +221,8 @@ jobs:
p12-password: ${{ secrets.CERTPASSWORD_P12 }}
- name: Create macOS Application
run: |
make dist
cd packaging
make all
poetry run poe dist
poetry run poe pyinstall
- name: Notarize app
uses: devbotsxyz/xcode-notarize@v1
if: env.SECRETS_AVAILABLE != null && env.NOT_PR
@ -303,7 +299,7 @@ jobs:
key: ${{ runner.os }}-poetry-${{ hashFiles('**/poetry.lock') }}
restore-keys: ${{ runner.os }}-poetry-
- name: Install Python Dependencies
run: make install
run: poetry install
- name: Test with Pytest for GTK 4
continue-on-error: true
run: make test-all
run: poe test-all

0
packaging/__init__.py Normal file
View File

View File

@ -1,10 +1,25 @@
from PyInstaller.utils.hooks import copy_metadata
import pathlib
from pathlib import Path
from tomlkit import parse
block_cipher = None
glade_files = [(str(p), str(pathlib.Path(*p.parts[1:-1]))) for p in pathlib.Path("../gaphor").rglob("*.glade")]
ui_files = [(str(p), str(pathlib.Path(*p.parts[1:-1]))) for p in pathlib.Path("../gaphor").rglob("*.ui")]
project_dir = Path.cwd()
glade_files = [
(str(p), str(Path(*p.parts[1:-1])))
for p in project_dir.rglob("*.glade")
]
ui_files = [
(str(p), str(Path(*p.parts[1:-1])))
for p in project_dir.rglob("*.ui")
]
def get_version() -> str:
f = project_dir / "pyproject.toml"
return str(parse(f.read_text())["tool"]["poetry"]["version"])
a = Analysis(
["gaphor-script.py"],
@ -60,5 +75,5 @@ app = BUNDLE(
name="Gaphor.app",
icon="macos/gaphor.icns",
bundle_identifier="org.gaphor.gaphor",
version="__version__",
version=get_version(),
)

View File

@ -1,21 +1,42 @@
import sys
import tomlkit
from pathlib import Path
import pyinstaller_versionfile
packaging_path = Path(__file__).resolve().parent
def main(toml_file):
with open(toml_file) as f:
def get_version() -> str:
project_dir = Path(__file__).resolve().parent.parent
f = project_dir / "pyproject.toml"
return str(tomlkit.parse(f.read_text())["tool"]["poetry"]["version"])
def make_gaphor_script():
pyproject_toml = packaging_path.parent / "pyproject.toml"
with open(pyproject_toml) as f:
toml = tomlkit.parse(f.read())
plugins = toml["tool"]["poetry"]["plugins"]
for cat in plugins.values():
for entrypoint in cat.values():
print(f"import {entrypoint.split(':')[0]}")
gaphor_script = packaging_path / "gaphor-script.py"
with open(gaphor_script, "w") as file:
plugins = toml["tool"]["poetry"]["plugins"]
for cat in plugins.values():
for entrypoint in cat.values():
file.write(f"import {entrypoint.split(':')[0]}\n")
print("from gaphor.ui import main")
print("import sys")
print("main(sys.argv)")
file.write("from gaphor.ui import main\n")
file.write("import sys\n")
file.write("main(sys.argv)\n")
if __name__ == "__main__":
main(sys.argv[1])
def make_file_version_info():
win_packaging_path = packaging_path / "windows"
metadata = win_packaging_path / "versionfile_metadata.yml"
file_version_out = win_packaging_path / "file_version_info.txt"
pyinstaller_versionfile.create_versionfile_from_input_file(
output_file=file_version_out,
input_file=metadata,
version=get_version(),
)

View File

@ -1,43 +0,0 @@
# UTF-8
#
# For more details about fixed file info 'ffi' see:
# http://msdn.microsoft.com/en-us/library/ms646997.aspx
VSVersionInfo(
ffi=FixedFileInfo(
# filevers and prodvers should be always a tuple with four items: (1, 2, 3, 4)
# Set not needed items to zero 0.
filevers=(1, 1, 0, 0),
prodvers=(1, 1, 0, 0),
# Contains a bitmask that specifies the valid bits 'flags'r
mask=0x3f,
# Contains a bitmask that specifies the Boolean attributes of the file.
flags=0x0,
# The operating system for which this file was designed.
# 0x4 - NT and there is no need to change it.
OS=0x4,
# The general type of file.
# 0x1 - the file is an application.
fileType=0x1,
# The function of the file.
# 0x0 - the function is not defined for this fileType
subtype=0x0,
# Creation date and time stamp.
date=(0, 0)
),
kids=[
StringFileInfo(
[
StringTable(
u'000004b0',
[StringStruct(u'CompanyName', u'Gaphor'),
StringStruct(u'FileDescription', u'Gaphor'),
StringStruct(u'FileVersion', u'__version__'),
StringStruct(u'InternalName', u'Gaphor'),
StringStruct(u'LegalCopyright', u'Copyright © 2019 Arjan J. Molenaar.'),
StringStruct(u'OriginalFilename', u'gaphor.exe'),
StringStruct(u'ProductName', u'Gaphor'),
StringStruct(u'ProductVersion', u'__version__')])
]),
VarFileInfo([VarStruct(u'Translation', [0, 1200])])
]
)

View File

@ -0,0 +1,6 @@
CompanyName: Gaphor
FileDescription: Gaphor
InternalName: Gaphor
LegalCopyright: Copyright © 2001-2021 Arjan J. Molenaar.
OriginalFilename: gaphor-exe.exe
ProductName: Gaphor

View File

@ -55,16 +55,64 @@ pre-commit = "^2.14"
sphinx = "^4.1"
recommonmark = "^0.7"
sphinx-rtd-theme = "^0.5"
sphinxcontrib-images = "^0.9.3"
babel = "^2.9.1"
babelgladeextractor = "^0.7"
flake8 = "^3.9"
isort = "^5.9"
sphinxcontrib-images = "^0.9.4"
pyinstaller = "^4.3"
pyinstaller-versionfile = "^2.0.0"
poethepoet = "^0.10.0"
[tool.poetry.scripts]
gaphor = 'gaphor.ui:main'
gaphorconvert = 'gaphor.plugins.diagramexport.gaphorconvert:main'
gaphor = "gaphor.ui:main"
gaphorconvert = "gaphor.plugins.diagramexport.gaphorconvert:main"
[tool.poe.tasks]
test = "pytest -m 'not slow'"
test-all = "pytest --cov=gaphor/"
dist = "poetry build"
install = "poetry install"
coremodel = [
{ "cmd" = "gaphor/codegen/codegen.py models/Core.gaphor gaphor/core/modeling/coremodel.py models/Core.override" },
{ "cmd" = "black gaphor/core/modeling/coremodel.py" },
{ "cmd" = "mypy gaphor/core/modeling" },
{ "cmd" = "isort gaphor/core/modeling/coremodel.py" },
]
uml = [
{ "cmd" = "python gaphor/codegen/codegen.py models/UML.gaphor gaphor/UML/uml.py models/UML.override" },
{ "cmd" = "mypy gaphor/UML" },
{ "cmd" = "isort gaphor/UML" },
{ "cmd" = "black gaphor/UML/uml.py" },
]
sysml = [
{ "cmd" = "python gaphor/codegen/codegen.py --uml_profile models/SysML.gaphor gaphor/SysML/sysml.py models/SysML.override" },
{ "cmd" = "black gaphor/SysML/sysml.py" },
{ "cmd" = "isort gaphor/SysML" },
{ "cmd" = "mypy gaphor/SysML" },
]
raaml = [
{ "cmd" = "python gaphor/codegen/codegen.py --sysml_profile models/RAAML.gaphor gaphor/RAAML/raaml.py models/RAAML.override" },
{ "cmd" = "mypy gaphor/RAAML" },
{ "cmd" = "isort gaphor/RAAML" },
{ "cmd" = "black gaphor/RAAML/raaml.py" },
]
c4model = [
{ "cmd" = "python gaphor/codegen/codegen.py --uml_profile models/C4Model.gaphor gaphor/C4Model/raaml.py models/C4Model.override" },
{ "cmd" = "mypy gaphor/C4Model" },
{ "cmd" = "isort gaphor/C4Model" },
{ "cmd" = "black gaphor/C4Model/raaml.py" },
]
lint = "pre-commit run --all-files"
docs = "sphinx-build docs docs/_build/html"
clean = { "shell" = "rm -rf dist build packaging/dist packaging/build packaging/windows/file_version_info.txt packaging/gaphor-script.py docs/_build" }
gaphor-script = { "script" = "packaging.make-script:make_gaphor_script" }
version-file = { "script" = "packaging.make-script:make_file_version_info" }
pyinstall = "pyinstaller -y --distpath packaging/dist --workpath packaging/build packaging/gaphor.spec"
package = ["gaphor-script", "version-file", "pyinstall"]
win-installer = { "script" = "packaging.windows.build-win-installer:main" }
[tool.poetry.plugins."gaphor.appservices"]
"event_manager" = "gaphor.core.eventmanager:EventManager"