Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

--sip-dir isn't accepted, contratry to what the INSTALL file says #307

Closed
yurivict opened this issue Mar 9, 2019 · 18 comments
Closed

--sip-dir isn't accepted, contratry to what the INSTALL file says #307

yurivict opened this issue Mar 9, 2019 · 18 comments

Comments

@yurivict
Copy link

yurivict commented Mar 9, 2019

Both configure and build phases fail with this option:

error: option --sip-dir not recognized

Setting the environment variable SIP_DIR also doesn't seem to have any effect.

How to set the sip dir?

On FreeBSD the sip directory is /usr/local/share/PyQt5/3.6/sip, and it can't find it by default.

@jeremysanders
Copy link
Collaborator

Please read the docs carefully. You need a separate build_ext phase with that option (don't blame me - that's how distutils works).

The environment variable also works for me and there is definitely code to read it. Are you sure you specified it correctly?

@yurivict
Copy link
Author

It rejects the --sip-dir= argument:

$ cd /usr/ports/science/py-veusz/work-py36/veusz-veusz-3.0.1 && /usr/bin/env SIP_DIR=/usr/local/share/PyQt5/3.6/sip QT_SELECT=qt5 QMAKEMODULES=/usr/ports/science/py-veusz/work-py36/veusz-veusz-3.0.1/mkspecs/modules:/usr/local/lib/qt5/mkspecs/modules XDG_DATA_HOME=/usr/ports/science/py-veusz/work-py36 XDG_CONFIG_HOME=/usr/ports/science/py-veusz/work-py36 HOME=/usr/ports/science/py-veusz/work-py36 PATH=/usr/ports/science/py-veusz/work-py36/.bin:/home/yuri/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin NO_PIE=yes MK_DEBUG_FILES=no MK_KERNEL_SYMBOLS=no SHELL=/bin/sh NO_LINT=YES LDSHARED=cc -shared PYTHONDONTWRITEBYTECODE= PYTHONOPTIMIZE= PREFIX=/usr/local LOCALBASE=/usr/local CC=cc CFLAGS=-O2 -pipe -fno-omit-frame-pointer  -fstack-protector -fno-strict-aliasing  CPP=cpp CPPFLAGS=-fno-omit-frame-pointer LDFLAGS= -fstack-protector  LIBS= CXX=c++ CXXFLAGS=-O2 -pipe -fno-omit-frame-pointer -fstack-protector -fno-strict-aliasing -fno-omit-frame-pointer   MANPREFIX=/usr/local BSD_INSTALL_PROGRAM=install  -s -m 555 BSD_INSTALL_LIB=install  -s -m 0644 BSD_INSTALL_SCRIPT=install  -m 555 BSD_INSTALL_DATA=install  -m 0644 BSD_INSTALL_MAN=install  -m 444 /usr/local/bin/python3.6 -c import sys; import setuptools;  __file__='setup.py'; sys.argv[0]='setup.py';  exec(compile(open(__file__, 'rb').read().replace(b'\r\n', b'\n'), __file__, 'exec')) --sip-dir=/usr/local/share/PyQt5/3.6/sip build_ext
usage: setup.py [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
   or: setup.py --help [cmd1 cmd2 ...]
   or: setup.py --help-commands
   or: setup.py cmd --help

error: option --sip-dir not recognized

@jeremysanders
Copy link
Collaborator

You need to run the build_ext separately, before the main build if you want to use the command line option. Note that the options come after the command (here build_ext).

$ python3 setup.py build_ext --help
Common commands: (see '--help-commands' for more)

  setup.py build      will build the package underneath 'build/'
  setup.py install    will install the package

Global options:
  --verbose (-v)  run verbosely (default)
  --quiet (-q)    run quietly (turns verbosity off)
  --dry-run (-n)  don't actually do anything
  --help (-h)     show detailed help message
  --no-user-cfg   ignore pydistutils.cfg in your home directory

Options for 'build_ext' command:
  --build-lib (-b)     directory for compiled extension modules
  --build-temp (-t)    directory for temporary files (build by-products)
  --plat-name (-p)     platform name to cross-compile for, if supported
                       (default: linux-x86_64)
  --inplace (-i)       ignore build-lib and put compiled extensions into the
                       source directory alongside your pure Python modules
  --include-dirs (-I)  list of directories to search for header files
                       (separated by ':')
  --define (-D)        C preprocessor macros to define
  --undef (-U)         C preprocessor macros to undefine
  --libraries (-l)     external C libraries to link with
  --library-dirs (-L)  directories to search for external C libraries
                       (separated by ':')
  --rpath (-R)         directories to search for shared C libraries at runtime
  --link-objects (-O)  extra explicit link objects to include in the link
  --debug (-g)         compile/link with debugging information
  --force (-f)         forcibly build everything (ignore file timestamps)
  --compiler (-c)      specify the compiler type
  --parallel (-j)      number of parallel build jobs
  --swig-cpp           make SWIG create C++ files (default is C)
  --swig-opts          list of SWIG command line options
  --swig               path to the SWIG executable
  --user               add user include, library and rpath
  --sip-exe            override sip executable
  --sip-dir            override sip file directory
  --sip-include-dir    override sip include directory
  --qmake-exe          override qmake executable
  --qt-include-dir     override Qt include directory
  --qt-library-dir     override Qt library directory
  --help-compiler      list available compilers

usage: setup.py [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
   or: setup.py --help [cmd1 cmd2 ...]
   or: setup.py --help-commands
   or: setup.py cmd --help


I've also tested SIP_DIR on my computer. I don't know why it's not getting passed to the setup script.

@yurivict
Copy link
Author

yurivict commented Mar 16, 2019

I patched the value in:

--- pyqtdistutils.py.orig       2019-03-16 14:55:57 UTC
+++ pyqtdistutils.py
@@ -73,7 +73,7 @@ class build_ext(distutils.command.build_
     user_options = distutils.command.build_ext.build_ext.user_options + [
         ('sip-exe=', None,
          'override sip executable'),
-        ('sip-dir=', None,
+        ('sip-dir=', '/usr/local/share/PyQt5/3.6/sip',
          'override sip file directory'),
         ('sip-include-dir=', None,
          'override sip include directory'),

and it still fails:

sip: Unable to find file "QtCore/QtCoremod.sip"
error: command '/usr/local/bin/sip-3.6' failed with exit status 1

In the Arch port I see that they don't perform any special steps, they just run 'build': https://aur.archlinux.org/cgit/aur.git/tree/PKGBUILD?h=veusz-git

Do you know why the above patching doesn't solve the problem? I think this is proof-positive that this argument is broken, and doesn't matter. The project just assumes the location /usr/local/bin/sip-3.6 and it can't be overridden.

Could you please tell me where should I patch the Sip location in as a workaround so that I can just fix the port?

@jeremysanders
Copy link
Collaborator

Well, it might be because they support the deprecated (but reliable) method to find sip from the sip configuration through the sipconfig module. I wish the sip/pyqt people hadn't removed this.

What gets printed in the sip command line? If I put a nonsensical --sip-dir option on the command line it is obviously being used:

jss@jss-lenovo:~/code/veusz$ python setup.py build_ext --sip-dir=/foo/bar
running build_ext
building 'veusz.helpers.threed' extension
/usr/bin/sip -c build/temp.linux-x86_64-2.7 -x VendorID -t WS_X11 -t Qt_5_9_5 -x Py_v3 -I /foo/bar/PyQt5 -b build/temp.linux-x86_64-2.7/threed.sbf veusz/helpers/src/threed/threed.sip
sip: Unable to find file "QtCore/QtCoremod.sip"
error: command '/usr/bin/sip' failed with exit status 1

@yurivict
Copy link
Author

Arch doesn't do the build_ext step. Does this mean that the Arch port is buggy? If not, why should BSD do this?

@yurivict
Copy link
Author

When I add build_ext like you recommend, it still fails:

running build_ext
building 'veusz.helpers.threed' extension
/usr/local/bin/sip-3.6 -c build/temp.freebsd-11.2-STABLE-amd64-3.6 -n PyQt5.sip -t WS_X11 -t Qt_5_12_0 -I /x//usr/local/share/PyQt5/3.6/sip/PyQt5 -b build/temp.freebsd-11.2-STABLE-amd64-3.6/threed.sbf veusz/helpers/src/threed/threed.sip
sip: Unable to find file "QtCore/QtCoremod.sip"
error: command '/usr/local/bin/sip-3.6' failed with exit status 1

@jeremysanders
Copy link
Collaborator

Veusz setup uses a number of ways to get the sip location. It will stop when it finds one:

  1. The --sip-dir parameter (to build_ext)
  2. The SIP_DIR environment variable
  3. The sip directory from the deprecated sipconfig module
  4. sip subdirectory of Python data directory (this works on Windows)

Any of these is fine.

Regarding the test you just ran with build_ext, there is a /x/ in front of the path. Is this intended?

@yurivict
Copy link
Author

yurivict commented Mar 16, 2019

there is a /x/ in front of the path. Is this intended?

This is an invalid path, and I've set to --sip-dir= and it didn't use it. It still always runs /usr/local/bin/sip-3.6. It seems to be hard-coded real hard.

@jeremysanders
Copy link
Collaborator

I'm a bit confused. Is that invalid path patched into the source or given as --sip-dir? It does seem to be using the path - it's on the sip command line being run.

@yurivict
Copy link
Author

yurivict commented Mar 16, 2019

I gave /x to --sip-dir in place of /foo/bar and it didn't use it.

@jeremysanders
Copy link
Collaborator

Where does the /x//usr/local/... come from in the sip command above?

@yurivict
Copy link
Author

Now I use /foo/bar, see the complete command and log here:

cd /usr/ports/science/py-veusz/work-py36/veusz-veusz-3.0.1 && /usr/bin/env SIP_DIR=/usr/local/share/PyQt5/3.6/sip QT_SELECT=qt5 QMAKEMODULES=/usr/ports/science/py-veusz/work-py36/veusz-veusz-3.0.1/mkspecs/modules:/usr/local/lib/qt5/mkspecs/modules XDG_DATA_HOME=/usr/ports/science/py-veusz/work-py36 XDG_CONFIG_HOME=/usr/ports/science/py-veusz/work-py36 HOME=/usr/ports/science/py-veusz/work-py36 PATH=/usr/ports/science/py-veusz/work-py36/.bin:/home/yuri/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin NO_PIE=yes MK_DEBUG_FILES=no MK_KERNEL_SYMBOLS=no SHELL=/bin/sh NO_LINT=YES LDSHARED=cc -shared PYTHONDONTWRITEBYTECODE= PYTHONOPTIMIZE= PREFIX=/usr/local LOCALBASE=/usr/local CC=cc CFLAGS=-O2 -pipe -fno-omit-frame-pointer  -fstack-protector -fno-strict-aliasing  CPP=cpp CPPFLAGS=-fno-omit-frame-pointer LDFLAGS= -fstack-protector  LIBS= CXX=c++ CXXFLAGS=-O2 -pipe -fno-omit-frame-pointer -fstack-protector -fno-strict-aliasing -fno-omit-frame-pointer   MANPREFIX=/usr/local BSD_INSTALL_PROGRAM=install  -s -m 555 BSD_INSTALL_LIB=install  -s -m 0644 BSD_INSTALL_SCRIPT=install  -m 555 BSD_INSTALL_DATA=install  -m 0644 BSD_INSTALL_MAN=install  -m 444 /usr/local/bin/python3.6 -c import sys; import setuptools;  __file__='setup.py'; sys.argv[0]='setup.py';  exec(compile(open(__file__, 'rb').read().replace(b'\r\n', b'\n'), __file__, 'exec')) build_ext --sip-dir=/foo/bar
running build_ext
building 'veusz.helpers.threed' extension
/usr/local/bin/sip-3.6 -c build/temp.freebsd-11.2-STABLE-amd64-3.6 -n PyQt5.sip -t WS_X11 -t Qt_5_12_0 -I /foo/bar/PyQt5 -b build/temp.freebsd-11.2-STABLE-amd64-3.6/threed.sbf veusz/helpers/src/threed/threed.sip
sip: Unable to find file "QtCore/QtCoremod.sip"
error: command '/usr/local/bin/sip-3.6' failed with exit status 1

@jeremysanders
Copy link
Collaborator

So it looks like the option is working - the directory is being passed to sip - it's just that the files are not in the correct place. What is the directory structure below /usr/local/share/PyQt5/3.6/sip?

@yurivict
Copy link
Author

$ ls /usr/local/share/PyQt5/3.6/sip
QtCore    QtGui     QtSvg     QtTest    QtWidgets QtXml

@jeremysanders
Copy link
Collaborator

It looks like FreeBSD has a really weird packaging of the sip files. I've never seen that layout before.

Veusz setup assumes that the sip files are in a PyQt5 subdirectory of the sip directory given. They're not in this case. You'll need to patch pyqtdistutils.py line 276:

diff --git a/pyqtdistutils.py b/pyqtdistutils.py
index e0273b20..42e89092 100644
--- a/pyqtdistutils.py
+++ b/pyqtdistutils.py
@@ -272,7 +272,7 @@ class build_ext(distutils.command.build_ext.build_ext):
                 sip_exe,
                 '-c', self.build_temp
             ] + SIP_FLAGS.split() + [
-                '-I', os.path.join(sip_dir, 'PyQt5'),
+                '-I', sip_dir,
                 '-b', sbf,
                 source
             ]

Alternatively, you could setup a temporary symlink to fix the directory structure.

@yurivict
Copy link
Author

This solved the problem.
Thank you for your help!

@jeremysanders
Copy link
Collaborator

Just to note that the next version of Veusz will use sip-5+, so this problem should go away.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants