Skip to content

Commit d9b9a2c

Browse files
authored
Merge pull request #2 from traverseda/nix-flake
Pyside6 and nix flake development env
2 parents 2f73ea2 + e548e87 commit d9b9a2c

File tree

10 files changed

+1188
-223
lines changed

10 files changed

+1188
-223
lines changed

.devcontainer/Dockerfile

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
FROM python:3.11-bookworm
2+
3+
# Install system dependencies
4+
RUN apt-get update && apt-get install -y \
5+
build-essential \
6+
git \
7+
libgl1-mesa-dev \
8+
libglu1-mesa-dev \
9+
freeglut3-dev \
10+
mesa-common-dev \
11+
xvfb \
12+
&& rm -rf /var/lib/apt/lists/*
13+
14+
# Install Poetry
15+
RUN pip install poetry
16+
17+
# Set up a non-root user
18+
ARG USERNAME=vscode
19+
ARG USER_UID=1000
20+
ARG USER_GID=$USER_UID
21+
RUN groupadd --gid $USER_GID $USERNAME \
22+
&& useradd --uid $USER_UID --gid $USER_GID -m $USERNAME
23+
24+
# Switch to the non-root user
25+
USER $USERNAME

.devcontainer/devcontainer.json

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
"name": "pysdfscad",
3+
"build": {
4+
"dockerfile": "Dockerfile",
5+
"context": ".."
6+
},
7+
"customizations": {
8+
"vscode": {
9+
"extensions": [
10+
"ms-python.python",
11+
"ms-python.vscode-pylance",
12+
"njpwerner.autodocstring",
13+
"ms-python.black-formatter"
14+
],
15+
"settings": {
16+
"python.defaultInterpreterPath": "/home/vscode/.local/bin/poetry",
17+
"python.poetryPath": "/home/vscode/.local/bin/poetry",
18+
"python.testing.pytestEnabled": true,
19+
"editor.formatOnSave": true,
20+
"python.formatting.provider": "black"
21+
}
22+
}
23+
},
24+
"remoteUser": "vscode",
25+
"postCreateCommand": "poetry install --with dev,qtgui --no-root",
26+
"mounts": [
27+
"source=${localWorkspaceFolder},target=/workspace,type=bind,consistency=cached"
28+
],
29+
"workspaceFolder": "/workspace"
30+
}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,3 +158,4 @@ cython_debug/
158158
# and can be added to the global gitignore or merged into this file. For a more nuclear
159159
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
160160
#.idea/
161+
.aider*

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,3 +89,8 @@ it mostly doesn't.
8989

9090
![](docs/Screenshot_0.png)
9191

92+
## Development
93+
94+
I use dev containers and nixos.
95+
96+
`nix-shell -p xorg.xhost --run "xhost +local:docker"`

flake.lock

Lines changed: 61 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
{
2+
description = "Python Qt development environment with UV";
3+
4+
inputs = {
5+
nixpkgs.url = "github:nixos/nixpkgs/nixos-25.05";
6+
flake-utils.url = "github:numtide/flake-utils";
7+
};
8+
9+
outputs = { self, nixpkgs, flake-utils }:
10+
flake-utils.lib.eachDefaultSystem (system:
11+
let
12+
pkgs = nixpkgs.legacyPackages.${system};
13+
in
14+
{
15+
devShells.default = pkgs.mkShell {
16+
buildInputs = with pkgs; [
17+
# Python and UV
18+
python311
19+
uv
20+
21+
# Qt libraries
22+
#qt6.full
23+
qt6.qtbase
24+
#qt6.qttools
25+
26+
# Python Qt bindings (available system-wide for reference)
27+
python311Packages.pyqt6
28+
python311Packages.pyside6
29+
30+
# Development tools
31+
python311Packages.pip
32+
];
33+
34+
shellHook = ''
35+
echo "Qt Python development environment with UV"
36+
echo "Python: $(python --version)"
37+
echo "UV: $(uv --version)"
38+
echo ""
39+
echo "Use 'uv init' to create a new project"
40+
echo "Use 'uv add pyqt6' or 'uv add pyside6' to add Qt bindings"
41+
echo "Use 'uv run python your_app.py' to run your application"
42+
'';
43+
44+
# Required for Qt applications
45+
QT_QPA_PLATFORM_PLUGIN_PATH = "${pkgs.qt6.qtbase}/lib/qt-6/plugins";
46+
LD_LIBRARY_PATH = "${pkgs.lib.makeLibraryPath [ pkgs.qt6.qtbase ]}";
47+
};
48+
}
49+
);
50+
}

pyproject.toml

Lines changed: 30 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,40 @@
1-
[tool.poetry]
1+
[project]
22
name = "pysdfscad"
33
version = "0.1.0"
44
description = ""
5-
authors = ["Alex Davies <[email protected]>"]
5+
authors = [{ name = "Alex Davies", email = "[email protected]" }]
6+
requires-python = ">=3.10,<3.12"
67
readme = "README.md"
7-
8-
packages = [
9-
{ include = "pysdfscad" },
10-
{ include = "pysdfscad_qtgui" },
8+
dependencies = [
9+
"sdf",
10+
"lark>=1.1.5,<2",
11+
"loguru>=0.6.0,<0.7",
12+
"click>=8.1.3,<9",
13+
"appdirs>=1.4.4,<2",
14+
"astor>=0.8.1,<0.9",
1115
]
1216

13-
include = ["pysdfscad/openscad.lark"]
14-
15-
[tool.poetry.dependencies]
16-
#python = "^3.10"
17-
python = ">=3.10,<3.12" #Required for pyinstaller
18-
sdf = {git = "https://github.com/fogleman/sdf.git"}
19-
lark = "^1.1.5"
20-
loguru = "^0.6.0"
21-
click = "^8.1.3"
22-
pyqt5 = {version = "^5.15.7", optional = true}
23-
qscintilla = {version = "^2.13.3", optional = true}
24-
pyqtgraph = {version = "^0.13.1", optional = true}
25-
pyopengl = {version = "^3.1.6", optional=true}
26-
appdirs = "^1.4.4"
27-
astor = "^0.8.1"
28-
mkdocs-macros-plugin = "^0.7.0"
17+
[project.scripts]
18+
pysdfscad = "pysdfscad.main:main"
19+
pysdfscad_qtgui = "pysdfscad_qtgui.main:main"
2920

30-
[tool.poetry.extras]
31-
qtgui = ["PyQt5","qscintilla","pysdfscad_qtgui","pyqtgraph","pyopengl"]
32-
#docs = ["Sphinx", "sphinx-rtd-theme",]
21+
[project.optional-dependencies]
22+
gui = [
23+
"pyside6>=6.9.3",
24+
"qscintilla>=2.13.3,<3",
25+
"pyqtgraph>=0.13.1,<0.14",
26+
"pyopengl>=3.1.6,<4",
27+
]
28+
dev = [
29+
"pytest>=7.2.0,<8",
30+
"black>=22.12.0,<23",
31+
]
3332

34-
[tool.poetry.scripts]
35-
pysdfscad = "pysdfscad.main:main"
36-
pysdfscad_qtgui = { callable = "pysdfscad_qtgui.main:main", extras = ["qtgui"] }
33+
[tool.uv]
34+
package = true
3735

38-
[tool.poetry.group.dev.dependencies]
39-
pytest = "^7.2.0"
40-
black = "^22.12.0"
41-
coverage = "^7.0.5"
42-
nuitka = "^1.4.5"
43-
ordered-set = "^4.1.0"
44-
zstandard = "^0.19.0"
45-
pyinstaller = "^5.8.0"
46-
pyinstaller-hooks-contrib = "^2022.15"
47-
mkdocs = "^1.4.2"
48-
mkdocstrings = {extras = ["python"], version = "^0.20.0"}
49-
mkdocs-material = "^9.0.12"
36+
[tool.uv.sources]
37+
sdf = { git = "https://github.com/fogleman/sdf.git" }
5038

51-
[build-system]
52-
requires = ["poetry-core"]
53-
build-backend = "poetry.core.masonry.api"
39+
[tool.setuptools]
40+
packages = ["pysdfscad", "pysdfscad_qtgui"]

pysdfscad_qtgui/logWidget.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import logging
2-
from PyQt5.QtCore import QObject, pyqtSlot, pyqtSignal
3-
from PyQt5.QtWidgets import QTextEdit
4-
from PyQt5.QtGui import QTextCursor
2+
from PySide6.QtCore import QObject, Slot as pyqtSlot, Signal as pyqtSignal
3+
from PySide6.QtWidgets import QTextEdit
4+
from PySide6.QtGui import QTextCursor
55
import shlex
66
import re
77
import html
@@ -35,7 +35,7 @@ def emit(self, record):
3535
self._text.append(msg)
3636
self._update_signal.emit()
3737

38-
@pyqtSlot(object)
38+
@pyqtSlot()
3939
def update(self):
4040
#ToDO, ideally we wouldn't re-render the entire thing every time
4141
# poor performance for the scroll bars

0 commit comments

Comments
 (0)