lucaschessR2 icon indicating copy to clipboard operation
lucaschessR2 copied to clipboard

Install Lucas Chess from PyPI (aka `pip install lucas-chess`)

Open bittner opened this issue 4 months ago • 7 comments

Are there any plans to make Lucas Chess installable from PyPI?

I believe, it would simplify installing Lucas Chess cleanly a lot. That would potentially make the job easier for packagers on the various Linux distributions.

I understand that there are system dependencies, but the application could simply report the missing ones at startup. That should be feasible.

bittner avatar Aug 07 '25 14:08 bittner

PyPi is for developers, and most of the users of the program are not developers, so I hadn't even thought about it. On the other hand, part of the program is in c, and it needs a specific compilation, I guess the pypi system will allow to do it, but it's too much of a mess.

lukasmonk avatar Sep 05 '25 14:09 lukasmonk

Not entirely true.

First, PyPI is an infrastructure to allow you to install Python software with Python mechanics. This is, pip install ... instead of apt install ... or snap install ... or brew install ... or select the application in your system's AppStore if there is any or download the installer manually and double-click on the untrusted thing (with all potentially dangerous security implications). PyPI is "just another App Store" if you will, but yeah, it's more technical than installing things by point and click.

The C-extensions are all compiled to binaries with Python when the Python package is built (as a wheel) before uploading it to PyPI, thus the Python package can later be installed without compilation required. This is a standard process, nothing to be afraid of (aka not "a mess").

Someone, me included, could try to get the Python package building working—with some help. I tried to get the Python code running locally and I failed. I don't know what's going on. The code style and project setup is a bit non-standard, so I'd need some onboarding or at least hints on where to find the necessary information.

bittner avatar Sep 05 '25 16:09 bittner

One reason could be that the FasterCode library isn't generated for the version of Python you're using. There's a script to generate it in the bin/_fastercode folder. The distribution includes the library generated for version 3.8, which is located in the bin/OS/Linux folder, FasterCode.cpython-38-x86_64-linux-gnu.so If this is not the case, please tell me what error you are getting and maybe I can help you.

lukasmonk avatar Sep 05 '25 20:09 lukasmonk

The two PRs #207 and #208 are low-hanging fruit, and they don't require Python code to be changed.

For the actual packaging it will be necessary to refactor the Python code slightly, though:

  • The bin folder needs to be renamed to src (to allow setuptools to find the modules automatically).
  • The LucasR.py module needs a if __name__ == "__main__": guard (so that we can add a [project.gui-scripts] script).
  • All the loading of static artifacts needs to be adjusted, because package data (e.g. the engines) will be on a different place in the file system when installed as a package.

To include the engines in the package we could then add a MANIFEST.in file like this:

graft src/OS/linux/**
graft src/OS/win32/**

Those two directories alone will account for more than 700 MiB, though, and result in a Python package of more than 400 MiB (zipped) shipping the binaries for both target platforms, Windows and Linux.

Instead, to avoid wasting bandwidth and storage, the engines can be packaged separately and defined as a dependency in the lucas-chess package. Which has at least two big advantages:

  1. We can conditionally include only the engines for Windows or Linux (depending on the system we install on).
  2. We can update the lucas-chess package independently from the engines package.

bittner avatar Sep 10 '25 00:09 bittner

I've had this idea in mind for a long time that the engines should be downloaded at the moment they are used, reducing the weight of the distribution. The idea actually stems from a complaint here on GitHub. I probably won't include it until the jump to pyside6 in LucasChessR6, hopefully next year.

lukasmonk avatar Sep 10 '25 17:09 lukasmonk

I can work on that if you want. It's a necessary investment for making the application easier to install, IMHO. There are a few installation issues that would profit from the flexibility and standardization, e.g.

  • #185
  • #113
  • #96
  • #85

I'm not sure if you actually accept contributions. This repository only contains your commits and PRs are never merged.

bittner avatar Sep 10 '25 19:09 bittner

At this time, I am not normally comfortable with code that I have not written myself. For that reason I do not accept contributions referring to code or structure. As for ideas, I'll write them all down. Anyway, my plan right now is to jump to the R6 version in early 26th.

lukasmonk avatar Sep 11 '25 07:09 lukasmonk