lucaschessR2 icon indicating copy to clipboard operation
lucaschessR2 copied to clipboard

Python package setup (initial approach)

Open bittner opened this issue 2 months ago • 1 comments

Adds an initial Python packaging setup.

  • Renames the bin/ folder to src/ (to match the src layout recommended by Python packaging)
  • Renames the LucasR.py module to main.py
  • Adds a __name__ == "__main__"´ name guard to the main.py module (to allow launching the app via an entrypoint script lucas-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-chess will abort with a segmentation fault when executed. This is because the Manager.py module loads the FasterCode library, which is included as a pre-built library (apparently built with Python 3.8). With Python 3.8 a ModuleNotFoundError: 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.

bittner avatar Sep 12 '25 15:09 bittner

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.

lukasmonk avatar Sep 12 '25 16:09 lukasmonk