Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for Python
  4. Resources text file unable to be opened in Windows, but works fine in Linux

Resources text file unable to be opened in Windows, but works fine in Linux

Scheduled Pinned Locked Moved Solved Qt for Python
15 Posts 6 Posters 1.1k Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Christian EhrlicherC Christian Ehrlicher

    @JonB said in Resources text file unable to be opened in Windows, but works fine in Linux:

    I don't compile the resources file on Windows but compile it on Linux, push it to the repository, and then use that same resources file on Windows.

    Are you sure you push them as binary and not text?

    T Offline
    T Offline
    tranxxenolab
    wrote on last edited by
    #5

    @JonB Unfortunately trying to seek or get the size doesn't work, as the open command fails.

    QFileInfo.size() returns 0 for one file, and -1 for another. It returns the correct size on the smaller JSON file.

    On Linux the correct size is returned for all of the files.

    Right now I am indeed doing the workaround of having the file outside of resources, but it's strange that it would be doing this and I'd like to figure out why :)

    @Christian-Ehrlicher I enabled binary transfer using a .gitattributes and ensured that the file was changed and committed, and pulled. Nothing changed.

    Both files have the same md5sum and are around 12 megabytes.

    I'm stuck.

    I'll try in the next day or two to see if I can make a MRE.

    Thanks for the suggestions!

    1 Reply Last reply
    0
    • T Offline
      T Offline
      tranxxenolab
      wrote on last edited by
      #6

      Hello everyone, I've created a minimum example with my actual data.

      This is a simple example that opens a window and tries to read from three different JSON files in the resources. On Ubuntu 24.04 with Pyside 6.9.2, everything runs properly. On Windows and MacOS, reading fails with the larger 2 JSON files. Any help is appreciated!

      The archive for the example can be downloaded from my Nextcloud (as I don't seem to have the ability to upload files here): https://nebula.tranxxenolab.net/s/Cob9ttPkZ9NmZzJ

      JoeCFDJ 1 Reply Last reply
      0
      • T tranxxenolab

        Hello everyone, I've created a minimum example with my actual data.

        This is a simple example that opens a window and tries to read from three different JSON files in the resources. On Ubuntu 24.04 with Pyside 6.9.2, everything runs properly. On Windows and MacOS, reading fails with the larger 2 JSON files. Any help is appreciated!

        The archive for the example can be downloaded from my Nextcloud (as I don't seem to have the ability to upload files here): https://nebula.tranxxenolab.net/s/Cob9ttPkZ9NmZzJ

        JoeCFDJ Offline
        JoeCFDJ Offline
        JoeCFD
        wrote on last edited by
        #7

        @tranxxenolab You have confirmed no issues when smaller json files are loaded. Can not you split your big json files into smaller ones? Then merge them after they are loaded. You may need to take a look at the source code and see how the loader works.

        1 Reply Last reply
        0
        • hskoglundH Offline
          hskoglundH Offline
          hskoglund
          wrote on last edited by
          #8

          Yeah it might be something with the PySide resource system, I created a C++ Qt 6.9.2 Widget test app and got all 3 resource files to read in correctly both on Ubuntu 24.04 and Windows 11.

          T 1 Reply Last reply
          0
          • F Offline
            F Offline
            friedemannkleint
            wrote on last edited by
            #9

            We had some issues with ARM ( QTBUG-140794 ), but plain Windows should work. The issue might be related though.

            1 Reply Last reply
            2
            • hskoglundH hskoglund

              Yeah it might be something with the PySide resource system, I created a C++ Qt 6.9.2 Widget test app and got all 3 resource files to read in correctly both on Ubuntu 24.04 and Windows 11.

              T Offline
              T Offline
              tranxxenolab
              wrote on last edited by tranxxenolab
              #10

              @hskoglund Yes, I've just confirmed that it does seem to be a difference between the way resources are created for PySide6 on Linux versus Windows. Running rcc -g python resource.qrc -o rc_resource.py (for the correct resource file) on Linux creates a very different file from what is created on Windows. In the particular example here, the files differ by almost 190kb between Windows (the larger file) and Linux. The number of lines is vastly different between the two files as well, by over a factor of 2 (as counted by wc, so it doesn't seem to just be a question of line endings).

              But indeed, when I run rcc on Windows (which creates the larger file), the JSON files in the resources are read correctly on Windows. And, even more strangely, the resource file created on Windows can be properly read on Linux, but not the other way around.

              I have no idea why this might be happening. I've submitted a bug report as it seems like extremely inconsistent behaviour: PYSIDE-3251

              1 Reply Last reply
              0
              • Christian EhrlicherC Offline
                Christian EhrlicherC Offline
                Christian Ehrlicher
                Lifetime Qt Champion
                wrote on last edited by
                #11

                I would guess a different compression is used which is not available on Windows

                Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                Visit the Qt Academy at https://academy.qt.io/catalog

                T 1 Reply Last reply
                0
                • Christian EhrlicherC Christian Ehrlicher

                  I would guess a different compression is used which is not available on Windows

                  T Offline
                  T Offline
                  tranxxenolab
                  wrote on last edited by
                  #12

                  @Christian-Ehrlicher fair enough, but I haven't seen this documented anywhere, which it should be at least.

                  1 Reply Last reply
                  0
                  • Christian EhrlicherC Offline
                    Christian EhrlicherC Offline
                    Christian Ehrlicher
                    Lifetime Qt Champion
                    wrote on last edited by
                    #13

                    You normally don't share resources between different operating systems as they are embedded in an executable. Now the problem is that python is somehwat special wrt this so...

                    Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                    Visit the Qt Academy at https://academy.qt.io/catalog

                    T 1 Reply Last reply
                    1
                    • Christian EhrlicherC Christian Ehrlicher

                      You normally don't share resources between different operating systems as they are embedded in an executable. Now the problem is that python is somehwat special wrt this so...

                      T Offline
                      T Offline
                      tranxxenolab
                      wrote on last edited by
                      #14

                      @Christian-Ehrlicher Sure, although there are certainly use cases for compiling resources on one platform, checking into git, and then using those resources, especially during testing, on another platform. (@friedemannkleint talked about a similar use case.) To have resource files not be cross-platform compatible, but only in certain cases, should be something that is documented.

                      1 Reply Last reply
                      0
                      • T Offline
                        T Offline
                        tranxxenolab
                        wrote on last edited by tranxxenolab
                        #15

                        For anyone else who is having issues similar to mine: I have confirmed that by running pyside6-rcc with --compress-algo zlib allows for the creation of a resources file that works cross-platform, at the cost of a larger resources file size. So, if you need cross-platform compatibility for your resources files that are generated on Linux but pulled on other platforms, be sure to use zlib as the compression algorithm, rather than the default of zstd (which isn't even available on Windows).

                        I'm going to mark this as solved, but will be going through the bug report I mentioned above to hopefully get some documentation written about this inconsistency.

                        1 Reply Last reply
                        5
                        • T tranxxenolab has marked this topic as solved on

                        • Login

                        • Login or register to search.
                        • First post
                          Last post
                        0
                        • Categories
                        • Recent
                        • Tags
                        • Popular
                        • Users
                        • Groups
                        • Search
                        • Get Qt Extensions
                        • Unsolved