Skip to content

Commit f2b96b3

Browse files
authored
Dev environment enhancements (#54)
* additional ruff formatting rules * fix release workflow, update pyproject.toml * add editorconfig file
1 parent 0d63d91 commit f2b96b3

19 files changed

Lines changed: 101 additions & 58 deletions

.editorconfig

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# EditorConfig is awesome: https://editorconfig.org
2+
3+
# top-most EditorConfig file
4+
root = true
5+
6+
# Unix-style newlines with a newline ending every file
7+
[*]
8+
end_of_line = lf
9+
insert_final_newline = true
10+
11+
# Rust and Python
12+
[*.{py,rs}]
13+
charset = utf-8
14+
indent_style = space
15+
indent_size = 4
16+
17+
# YAML
18+
[*.yml]
19+
indent_style = space
20+
indent_size = 2
Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,24 @@
1-
name: Release creation
1+
# Release on PyPi if a realease is created
2+
3+
name: Release on PyPi
24

35
on:
4-
push:
5-
# Sequence of patterns matched against refs/tags
6-
tags:
7-
- 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10
6+
release:
7+
types: [created]
88

99
env:
1010
PYTHON_VERSION: "3.12"
1111

1212
jobs:
13-
build-linux:
13+
deploy:
14+
if: github.repository_owner == 'trappitsch'
1415
name: Release on PyPi
1516
runs-on: ubuntu-latest
1617
steps:
1718
- name: Checkout code
1819
uses: actions/checkout@v4
1920
- name: Install the latest version of rye
20-
uses: eifinger/setup-rye@v2
21+
uses: eifinger/setup-rye@v4
2122
with:
2223
github-token: ${{ secrets.GITHUB_TOKEN }}
2324
- name: Sync Rye

pyproject.toml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,27 @@ docs = [
4040
requires = ["hatchling"]
4141
build-backend = "hatchling.build"
4242

43+
[tool.ruff]
44+
target-version = "py38"
45+
46+
[tool.ruff.lint]
47+
select = [
48+
"A", # shadowing built-ins
49+
"E", # style stuff, whitespaces
50+
"F", # pyflakes lints
51+
"I", # sorting
52+
"N", # naming
53+
"T100", # breakpoints
54+
]
55+
56+
[tool.ruff.lint.isort]
57+
known-first-party = ["box-packager", "box"]
58+
59+
[tool.ruff.lint.per-file-ignores]
60+
"src/box/installer_utils/linux_hlp.py" = ["E501"]
61+
"src/box/installer_utils/mac_hlp.py" = ["E501"]
62+
"src/box/installer_utils/windows_hlp.py" = ["E501"]
63+
4364
[tool.rye]
4465
managed = true
4566
dev-dependencies = [

src/box/cleaner.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Clean the project folder
22

3-
from pathlib import Path
43
import shutil
4+
from pathlib import Path
55

66
import box.formatters as fmt
77

src/box/cli.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@
55
import rich_click as click
66

77
import box
8+
import box.formatters as fmt
9+
import box.utils as ut
810
from box import env_vars
911
from box.cleaner import CleanProject
1012
from box.config import uninitialize
1113
from box.initialization import InitializeProject
1214
from box.installer import CreateInstaller
13-
import box.formatters as fmt
1415
from box.packager import PackageApp
15-
import box.utils as ut
1616

1717
CONTEXT_SETTINGS = dict(help_option_names=["-h", "--help"])
1818

@@ -45,7 +45,9 @@ def cli():
4545
"--gui",
4646
is_flag=True,
4747
default=None,
48-
help="Set the project as a GUI project. In quiet mode, this will default to `False`.",
48+
help=(
49+
"Set the project as a GUI project. In quiet mode, this will default to `False`."
50+
),
4951
)
5052
@click.option("-e", "--entry", help="Set the app entry for the project.")
5153
@click.option(

src/box/env_vars.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Deal with setting and getting environmental variables. Getting all at once is handled in the `config.py`
1+
# Deal with environmental variables.
22

33
from enum import Enum
44

src/box/initialization.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44

55
import rich_click as click
66

7-
from box.config import PyProjectParser, pyproject_writer
87
import box.formatters as fmt
9-
from box.packager import PackageApp
108
import box.utils as ut
9+
from box.config import PyProjectParser, pyproject_writer
10+
from box.packager import PackageApp
1111

1212

1313
class InitializeProject:

src/box/installer.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
# Create an OS specific installer for GUI or CLI application.
22

33
import os
4-
from pathlib import Path
54
import shutil
65
import subprocess
76
import sys
7+
from pathlib import Path
88

99
import rich_click as click
1010

11-
from box import RELEASE_DIR_NAME
12-
from box.config import PyProjectParser
1311
import box.formatters as fmt
1412
import box.utils as ut
13+
from box import RELEASE_DIR_NAME
14+
from box.config import PyProjectParser
1515

1616

1717
class CreateInstaller:
@@ -322,11 +322,11 @@ def get_icon(suffix: str = None) -> Path:
322322
):
323323
continue
324324

325-
for dir in dirs:
326-
if dir != "assets":
325+
for my_dir in dirs:
326+
if my_dir != "assets":
327327
continue
328328

329-
icon_file = Path.cwd().joinpath(f"{root}/{dir}/icon")
329+
icon_file = Path.cwd().joinpath(f"{root}/{my_dir}/icon")
330330

331331
if suffix:
332332
suffixes = [suffix] # overwrite exisiting and only check this.

src/box/installer_utils/mac_hlp.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Helper functions to create Mac Installers
22

3-
from pathlib import Path
43
import shutil
4+
from pathlib import Path
55

66

77
def dmgbuild_settings(target_path: Path, name_pkg: str, icon: Path) -> dict:

src/box/packager.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
# Build the project with PyApp
22

33
import os
4-
import sys
5-
from pathlib import Path
64
import shutil
75
import subprocess
6+
import sys
87
import tarfile
9-
from typing import List, Union
108
import urllib.request
9+
from pathlib import Path
10+
from typing import List, Union
1111

1212
import rich_click as click
1313

14-
from box import BUILD_DIR_NAME, RELEASE_DIR_NAME
15-
from box.config import PyProjectParser
1614
import box.formatters as fmt
1715
import box.utils as ut
16+
from box import BUILD_DIR_NAME, RELEASE_DIR_NAME
17+
from box.config import PyProjectParser
1818

1919
PYAPP_SOURCE_URL = "https://github.com/ofek/pyapp/releases/"
2020
PYAPP_SOURCE_NAME = "source.tar.gz"

0 commit comments

Comments
 (0)