Search code examples
pythoncythonsfml

Unable to build pySFML - 'Time' is not a type identifier


I'm unsuccessfully trying to build pySFML from https://github.com/intjelic/python-sfml on my Windows machine with Python 3.12 (aswell as 3.11, 3.10, 3.9).

I have downloaded SFML 2.3.2 from https://www.sfml-dev.org/download/sfml/2.3.2/ and have Visual Studio 22 installed.

After extracting SFML-2.3.2 to C:\libraries, i have set the Environment-Variables:

SFML_DIR       = C:\libraries\SFML-2.3.2
SFML_HEADERS   = C:\libraries\SFML-2.3.2\include
SFML_LIBRARIES = C:\libraries\SFML-2.3.2\lib

and added to Path:

C:\libraries\SFML-2.3.2\bin

I then git-cloned the repo https://github.com/intjelic/python-sfml.git into a Python 3.12 venv.

And installed the requirements:

pip install -r requirements.txt

(which installed Cython-Version 3.0.10)

after that I did:

pip install --upgrade setuptools wheel

When I then at first tried:

pip install .

I got:

Error compiling Cython file:
      ------------------------------------------------------------
      ...

      from libcpp.string cimport string

      cimport time
              ^
      ------------------------------------------------------------

      include\Includes\sfml\sfml.pxd:9:8: 'time.pxd' not found

but the file is in the directory and there is also a empty init.py file, but anyways I changed it to:

from . cimport Time

It now finds the file but I get:

Error compiling Cython file:
      ------------------------------------------------------------
      ...

      from sfml cimport Time

      cdef extern from "SFML/System.hpp" namespace "sf::Time":
          cdef Time Zero
               ^
      ------------------------------------------------------------

      include\Includes\sfml\Time.pxd:10:9: 'Time' is not a type identifier

The actual traceback is much longer (the same as above for every other class) and can be seen here: https://raw.githubusercontent.com/ai-cr/pySFML-traceback/main/pySFML_traceback.txt

I understand that the project is no longer maintainend, but shouldn't a specific release with a specific python/cython version work, as it worked in the past?

Did anyone manage to install pySFML? Help would be much appreciated..!


Solution

  • Many thanks to @DavidW for figuring this out.

    I was able to install pySFML on Windows with Python 3.7 and Cython 0.29.

    see: https://github.com/intjelic/python-sfml/blob/master/.github/workflows/python-package-windows.yml