Page 1 of 1

Trying to Build python3-pyqt5 for fd64 using pkg-build.sh

Posted: Sun Dec 06, 2020 9:25 am
by s243a

So I've build qt5-5.15.2 but I'm not sure if it works. I've tried installing python3-pyqt5 from pip but got the error:

Code: Select all

symbol _ZdlPvm version Qt_5 not defined in file libQt5Core.so.5 with link time reference

when trying to run maestral[gui].

I've also tried using fatdog64's native build system (i.e. pkg-build.sh...see instructions) to compile python3-pyqt5.
Source
SRC_URL=https://files.pythonhosted.org/ ... VER.tar.gz
https://pypi.org/project/PyQt5/#modal-close

In this case it fails here:

Code: Select all

export QMAKESPEC=linux-g++-64	
	python3 configure.py --confirm-license --qsci-api

**these lines are from the recipe file.

with the error:

Code: Select all

Querying qmake about your Qt installation...
Determining the details of your Qt installation...
/opt/qt5/bin/qmake -o cfgtest_QtCore.mk cfgtest_QtCore.pro
Could not find qmake spec 'linux-g++-64'.

This error is rather strange to me because I think these specs exist:

Code: Select all

# pwd
/opt/qt-5.15.2/mkspecs/linux-g++-64
# ls
qmake.conf  qplatformdefs.h

qmake.conf has the following:

Code: Select all

# cat qmake.conf
#
# qmake configuration for linux-g++
#
# Written for GNU/Linux platforms that have both lib and lib64 directories,
# like the AMD Opteron.
#

MAKEFILE_GENERATOR      = UNIX
CONFIG                 += incremental
QMAKE_INCREMENTAL_STYLE = sublib

include(../common/linux.conf)

QMAKE_CFLAGS            = -m64
QMAKE_LFLAGS            = -m64

include(../common/gcc-base-unix.conf)
include(../common/g++-unix.conf)


QMAKE_LIBDIR_X11        = /usr/X11R6/lib64
QMAKE_LIBDIR_OPENGL     = /usr/X11R6/lib64

load(qt_config)

qplatformdefs.h has the following:

Code: Select all

...
#include "../linux-g++/qplatformdefs.h

Anyway, I looked a bit at where the configure.py failed. It is trying to compile "cfgtest_QtCore.cpp

Code: Select all

#include <QCoreApplication>
#include <QFile>
#include <QLibraryInfo>
#include <QTextStream>


int main(int argc, char **argv)
{
    QCoreApplication app(argc, argv);
    QFile outf(argv[1]);

    if (!outf.open(QIODevice::WriteOnly|QIODevice::Truncate|QIODevice::Text))
        return 1;

    QTextStream out(&outf);

    // This is not a feature and needs to be handled separately.
#if defined(QT_SHARED) || defined(QT_DLL)
    out << "shared\n";
#else
    out << "static\n";
#endif

    // Determine which features should be disabled.

#if defined(QT_NO_PROCESS)
    out << "PyQt_Process\n";
#endif

#if QT_VERSION < 0x050200
// This is the test used in qglobal.h in Qt prior to v5.2.  In v5.2 and later
// qreal is double unless QT_COORD_TYPE is defined.
#if defined(QT_NO_FPU) || defined(Q_PROCESSOR_ARM) || defined(Q_OS_WINCE)
    out << "PyQt_qreal_double\n";
#endif
#else
    if (sizeof (qreal) != sizeof (double))
        out << "PyQt_qreal_double\n";
#endif

#if !defined(Q_COMPILER_CONSTEXPR) || !defined(Q_COMPILER_UNIFORM_INIT)
    out << "PyQt_CONSTEXPR\n";
#endif

    return 0;
}

on line 709 of configure.py we have:

Code: Select all

        # Compile and run the QtCore test program.
        test = compile_test_program(self, verbose, 'QtCore', debug=debug)
        if test is None:
            error("Failed to determine the detail of your Qt installation. Try again using the --verbose flag to see more detail about the problem.")

Here is the program which compiles the test program (line 2406 of configure.py):

Code: Select all

def compile_test_program(target_config, verbose, mname, source=None, debug=None):
    """ Compile the source of a Qt program and return the name of the
    executable or None if it couldn't be created.  target_config is the target
    configuration.  verbose is set if the output is to be displayed.  mname is
    the name of the PyQt module being tested.  source is the C++ source of the
    program.  If it is None then the source is expected to be found in the
    config-tests directory.  debug is set if debug, rather than release, mode
    is to be used.  If it is None then the mode is taken from the target
    configuration.
    """

    metadata = MODULE_METADATA[mname]

    # The derived file names.
    name = 'cfgtest_' + mname
    name_pro = name + '.pro'
    name_makefile = name + '.mk'
    name_source = name + '.cpp'

    # Create the source file if necessary.
    if source is None:
        name_source = source_path('config-tests', name_source)
    else:
        f = open_for_writing(name_source)
        f.write(source)
        f.close()

    # Create the .pro file.
    pro_lines = []
    pro_add_qt_dependencies(target_config, metadata, pro_lines, debug)
    pro_lines.append('TARGET = %s' % name)

    pro_lines.append('SOURCES = %s' % qmake_quote(name_source))

    f = open_for_writing(name_pro)
    f.write('\n'.join(pro_lines))
    f.close()

    if not run_qmake(target_config, verbose, name_pro, name_makefile, fatal=False):
        return None

    return run_make(target_config, verbose, name, name_makefile)
 

on line 2078 we have:

Code: Select all

def run_qmake(target_config, verbose, pro_name, makefile_name='', fatal=True, recursive=False):
    """ Run qmake against a .pro file.  target_config is the target
    configuration.  verbose is set if the output is to be displayed.  pro_name
    is the name of the .pro file.  makefile_name is the name of the makefile
    to generate (and defaults to Makefile).  fatal is set if a qmake failure is
    considered a fatal error, otherwise False is returned if qmake fails.
    recursive is set to use the -recursive flag.
    """

    # qmake doesn't behave consistently if it is not run from the directory
    # containing the .pro file - so make sure it is.
    pro_dir, pro_file = os.path.split(pro_name)
    if pro_dir != '':
        cwd = os.getcwd()
        os.chdir(pro_dir)
    else:
        cwd = None

    mf = makefile_name if makefile_name != '' else 'Makefile'

    remove_file(mf)

    args = [quote(target_config.qmake)]

    if target_config.qmake_spec != target_config.qmake_spec_default:
        args.append('-spec')
        args.append(target_config.qmake_spec)

    if makefile_name != '':
        args.append('-o')
        args.append(makefile_name)

    if recursive:
        args.append('-recursive')

    args.append(pro_file)

    run_command(' '.join(args), verbose)

    if not os.access(mf, os.F_OK):
        if fatal:
            error(
                    "%s failed to create a makefile from %s." %
                            (target_config.qmake, pro_name))

        return False

    # Restore the current directory.
    if cwd is not None:
        os.chdir(cwd)

    return True
    

So anyway, all this python code is meant to run the following shell command:

Code: Select all

/opt/qt5/bin/qmake -o cfgtest_QtCore.mk cfgtest_QtCore.pro

but none of these files are actually in the config-tests directory, and so if you try running this command directly in this directory you get the error:

Code: Select all

Cannot find file: cfgtest_QtCore.pro.

So we see that cfgtest_QtCore.mk is supposed to be generated from cfgtest_QtCore.cpp before the qmake command is called but I'm not sure where/when it is generated.


Re: Trying to Build python3-pyqt5 for fd64 using pkg-build.sh

Posted: Sun Dec 06, 2020 9:43 am
by s243a

So according to the following tutorial:
https://doc.qt.io/qt-5/qmake-tutorial.html

The command to generate the makefile is like this:

Code: Select all

qmake -o Makefile hello.pro

Where Makefile is the name of the output file, and hello.pro specifies how this file is made as per the above tutial. In this case the file should be included with the qt distribution under "examples/qmake/tutorial" and hello.pro should look like this:

Code: Select all

HEADERS += hello.h
SOURCES += hello.cpp
SOURCES += main.cpp

In our case I think we what a file called "cfgtest_QtCore.pro" with the following info:

Code: Select all

SOURCES += cfgtest_QtCore.cpp

from line 2419 of config.py (within compile_test_program)

Code: Select all

     name = 'cfgtest_' + mname
    name_pro = name + '.pro'
    name_makefile = name + '.mk'
    name_source = name + '.cpp'

and further down in this function:

Code: Select all

pro_lines.append('SOURCES = %s' % qmake_quote(name_source))[

    f = open_for_writing(name_pro)
    f.write('\n'.join(pro_lines))
    f.close()

I see that the actual .pro file wasn't created in the config-tests directory but was instead created in the parrent directory and has the following info:

Code: Select all

QT -= gui
CONFIG += release
TARGET = cfgtest_QtCore
SOURCES = /tmp/PyQt5-5.15.2/config-tests/cfgtest_QtCore.cpp

so running the command in the parent directory we get:

Code: Select all

sh-4.4# /opt/qt5/bin/qmake -d -o cfgtest_QtCore.mk cfgtest_QtCore.pro
DEBUG 1: Resetting dir to: /tmp/PyQt5-5.15.2
Could not find qmake spec 'linux-g++-64'.
Error processing project file: cfgtest_QtCore.pro

Re: Trying to Build python3-pyqt5 for fd64 using pkg-build.sh

Posted: Sun Dec 06, 2020 10:04 am
by s243a

So it looks like for the QMAKE_SPEC, rather than specifying an architecture you can specify the path to the config file.

The QMAKESPEC environment variable can contain any of the following:

A complete path to a directory containing a qmake.conf file. In this case qmake will open the qmake.conf file from within that directory. If the file does not exist, qmake will exit with an error.
The name of a platform-compiler combination. In this case, qmake will search in the directory specified by the mkspecs subdirectory of the data path specified when Qt was compiled (see QLibraryInfo::DataPath).
Note: The QMAKESPEC path will be automatically added to the generated Makefile after the contents of the INCLUDEPATH system variable.

https://doc.qt.io/qt-5/qmake-environmen ... #qmakespec

If I do this, it solves my initial problem but then I get a new issue.

Code: Select all

sh-4.4# export QMAKESPEC=/opt/qt/mkspecs/linux-g++-64
sh-4.4# /opt/qt5/bin/qmake -d -o cfgtest_QtCore.mk cfgtest_QtCore.pro
DEBUG 1: Resetting dir to: /tmp/PyQt5-5.15.2
Cannot find feature spec_pre.prf
Error processing project file: cfgtest_QtCore.pro

Re: Trying to Build python3-pyqt5 for fd64 using pkg-build.sh

Posted: Sun Dec 06, 2020 10:10 am
by s243a

I think my prefixes are wrong in my qmake installation (maybe a compile error). I think that QT_INSTALL_REFIX, should be /opt/qt5. However, this isn't what I see:

Code: Select all

sh-4.4# qmake -query
QT_SYSROOT:
QT_INSTALL_PREFIX:/usr
QT_INSTALL_ARCHDATA:/usr
QT_INSTALL_DATA:/usr/lib64
QT_INSTALL_DOCS:/usr/share/doc/qt
QT_INSTALL_HEADERS:/usr/include
QT_INSTALL_LIBS:/usr/lib64
QT_INSTALL_LIBEXECS:/usr/libexec
QT_INSTALL_BINS:/usr/bin
QT_INSTALL_TESTS:/usr/tests
QT_INSTALL_PLUGINS:/usr/lib64/plugins
QT_INSTALL_IMPORTS:/usr/lib64/imports
QT_INSTALL_QML:/usr/qml
QT_INSTALL_TRANSLATIONS:/usr/share/translations
QT_INSTALL_CONFIGURATION:/etc/xdg
QT_INSTALL_EXAMPLES:/usr/share/examples
QT_INSTALL_DEMOS:/usr/share/examples
QT_HOST_PREFIX:/usr
QT_HOST_DATA:/usr
QT_HOST_BINS:/usr/bin
QT_HOST_LIBS:/usr/lib64
QMAKE_SPEC:linux-g++
QMAKE_XSPEC:linux-g++
QMAKE_VERSION:3.1
QT_VERSION:5.15.2

according to the following thread, I have to recompile qt to change the prefix:

https://stackoverflow.com/questions/913 ... qt-library

edit:
I stand corrected. According to the following page:
https://doc.qt.io/qt-5/qmake-environment-reference.html

You can change this as follows:

Code: Select all

qmake set QT_INSTALL_PREFIX /opt/qt5

I'll try this tomorrow.