lucaschessR2
lucaschessR2 copied to clipboard
Python package setup (initial approach)
Adds an initial Python packaging setup.
- Renames the
bin/folder tosrc/(to match the src layout recommended by Python packaging) - Renames the
LucasR.pymodule tomain.py - Adds a
__name__ == "__main__"´name guard to themain.pymodule (to allow launching the app via an entrypoint scriptlucas-chess) - Makes the package build pick up all engines, Windows and Linux, to create a giant Python package.
Usage
Build the wheel and source distribution:
uv build
This will create 2 large files (a wheel and a source distribution) as a Python package:
$ ls -l dist/
-rw-r--r-- 1 peter users 407M 14. Sep 17:26 lucas_chess-2.20.0.dev0-py3-none-any.whl
-rw-r--r-- 1 peter users 405M 14. Sep 17:25 lucas_chess-2.20.0.dev0.tar.gz
Both resulting package files can directly be installed (in a virtual environment) via
uv pip install <package-filename>
Alternatively, you can install them from source off the GitHub repository directly via
uv pip install git+https://github.com/<username>/lucaschessR2@<branch>#egg=lucas-chess
Once the package is installed, the application can be run from the terminal via
lucas-chess
Alternatively, the application can still be run from source code like this:
uv run src/main.py
Notes
- This PR is based on the two PRs #207 and #208. (When those two are merged this PR can be rebased and will then be much smaller.)
- The Python package must be installed using Python 3.8, otherwise
lucas-chesswill abort with a segmentation fault when executed. This is because theManager.pymodule loads theFasterCodelibrary, which is included as a pre-built library (apparently built with Python 3.8). With Python 3.8 aModuleNotFoundError: No module named 'FasterCode'stops the startup, reported by the shiboken2 module. - As discussed in https://github.com/lukasmonk/lucaschessR2/issues/203#issuecomment-3272791691 it makes sense to refactor how the engines are loaded. It would also make sense to distribute the engines independently from the Python application.
Thanks for the information, I will see if it is possible when the development of LucasChessR6 starts. In LucasChessR2 I'm not going to make structural changes, first of all for fear of side effects.