I have Python 2.7 on my Fedora VM and I want to upgrade to Python 3.3.2. I did this:
wget http://python.org/ftp/python/3.3.2/Python-3.3.2.tar.bz2
tar xf Python-3.3.2.tar.bz2
cd Python-3.3.2
./configure --prefix=/usr/local
And then tried
make
Only to get this error:
Objects/abstract.c:2281:20: error: variable 'countva' is uninitialized when
used here [-Werror,-Wuninitialized]
Py_VA_COPY(countva, va);
~~~~~~~~~~~^~~~~~~~~~~~
Include/pyport.h:875:37: note: expanded from:
#define Py_VA_COPY(x, y) Py_MEMCPY((x), (y), sizeof(va_list))
^
Objects/abstract.c:2278:20: note: initialize the variable 'countva' to
silence this warning
va_list countva;
^
= NULL
1 error generated.
make: *** [Objects/abstract.o] Error 1
...what? How do I fix this? There shouldn't be something wrong with the Python installation file, should there?
There is nothing wrong with the Python archive, it must be your environment.
I reproduced your exact steps on my system and it runs on my system. I think the -Werror switch is to blame. It will turn warnings into errors. What your compiler actually encounters is merely a warning.
Can you type in the same terminal echo $CFLAGS and post the output? On my system, this command will produce an empty line. Maybe you have some CFLAGS set in your ~/.bashrc? Or maybe you do source a file in your ~/.bashrc which sets CFLAGS?
Related
I want to build pyobjc-7.3, because it has fix for send2trash.
Classic building on BigSur 20.5.0 is strait forward.
cd pyobjc-7.3/pyobjc-framework-Cocoa
python3 setup.py build
though once I run same build inside nix-shell magic happens.
nix-shell -p pkgs.python39Packages.setuptools
python3 setup.py build
clang-7: error: argument unused during compilation:
'-fno-strict-overflow' [-Werror,-Wunused-command-lin\ e-argument]
ok. no big deal. let's disable warning.
CFLAGS="-Wno-unused-argument" python3 setup.py build
what? now clang is like a blind kitten.
Modules/pyobjc-api.h:19:10: fatal error: 'objc/objc.h' file not found
#include <objc/objc.h>
-isysroot option and -I has no effect.
-isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX11.3.sdk
I noticed lots additions to -I flag in clang such as:
-iwithprefix /Library/Developer/CommandLineTools/SDKs/MacOSX11.3.sdk/usr/include
it helps clang to find objc header file, though this is not the end of the story.
Modules/pyobjc-api.h:21:9: fatal error: 'Foundation/Foundation.h' file
not found
how come?!
oh there is another header files of special kind - frameworks. Wheel reinvention...
clang, take another argument
-iframeworkwithsysroot /System/Library/Frameworks
Here I get tons of type errors and I run out of ideas what could I try next:
/Library/Developer/CommandLineTools/SDKs/MacOSX11.3.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSString.h:138:1:
error:
function cannot return function type 'NSComparisonResult' (aka 'int (int)')
(NSComparisonResult)compare:(NSString *)string options:(NSStringCompareOptions)mask range:(NSR...
After days of trying I've found solution.
There are a few bugs are causing the problems:
First is nix provides older (10.12) sdk while setup.py thinks is 10.15.
This enables CPP sections for unsupported SDK API therefore type errors.
Following hack makes pyobjc to think that SDK is older that it is.
with pkgs;
with pkgs.lib;
with pkgs.python39Packages;
let
pyobjc-core = buildPythonPackage rec {
pname = "pyobjc-core";
version = "7.3";
name = "${pname}-${version}";
src = pkgs.python39Packages.fetchPypi {
pname = "pyobjc-core";
inherit version;
sha256 = "0x3msrzvcszlmladdpl64s48l52fwk4xlnnri8daq2mliggsx0ah";
};
preBuild=''
export SDKROOT="/Library/Developer/CommandLineTools/SDKs/MacOSX10.12.sdk"
Second problem is with header discovery and overstrict lint from python nix
CFLAGS = "-iwithsysroot /usr/include -Wno-unused-argument";
Third problem big sur linkder is dynamic and ffi libray is not found.
Providing through nix derivation
buildInputs = [ pkgs.libffi ];
Forth problem is tests are broken
doCheck = false;
The following procedure fails. Am I missing something?
Install various Ubuntu packages (prerequisites for compilation)
Get http://downloads.sourceforge.net/wxpython/wxPython-src-3.0.1.1.tar.bz2
Uncompress to wxPython-src-3.0.1.1/
Create new virtualenv called test
Activate test virtualenv
In terminal, from wxPython-src-3.0.1.1/:
./configure --prefix=/home/username/.virtualenvs/test --with-gtk2 --enable-unicode --with-opengl
#lots of output, confirms "Configured wxWidgets 3.0.1 for `x86_64-unknown-linux-gnu'"
make install
#lots of output, confirms:
# The installation of wxWidgets is finished. On certain
# platforms (e.g. Linux) you'll now have to run ldconfig
# if you installed a shared library and also modify the
# LD_LIBRARY_PATH (or equivalent) environment variable.
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:~/.virtualenvs/test/lib
# don't run ldconfig since that is a system tool, not appropriate for virtualenv?
cd wxPython
python setup.py install
# lots of output, starting:
# WARNING: WXWIN not set in environment. Assuming '..'
# Found wx-config: /home/username/.virtualenvs/test/bin/wx-config
# Using flags: --toolkit=gtk2 --unicode=yes --version=3.0
# Preparing CORE...
# Preparing STC...
# Preparing GLCANVAS...
# Preparing GIZMOS...
# running install
# etc
The final command fails with:
src/gtk/_core_wrap.cpp:20407:7: note: ‘arg3’ was declared here
int arg3 ;
^
src/gtk/_core_wrap.cpp: In function ‘PyObject* _wrap_Image_SetAlphaBuffer(PyObject*, PyObject*, PyObject*)’:
src/gtk/_core_wrap.cpp:3747:13: warning: ‘arg3’ may be used uninitialized in this function [-Wmaybe-uninitialized]
if (ALPHASIZE != self->GetWidth() * self->GetHeight()) {
^
src/gtk/_core_wrap.cpp:20474:7: note: ‘arg3’ was declared here
int arg3 ;
^
cc1plus: some warnings being treated as errors
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
I used python setup.py install &> ~/error.txt to pass on the error messages to knowledgeable colleague who identified that C compilation was using the -Werror=format-security flag. This version of wxPython (and maybe others) cannot compile with that flag.
My $CPPFLAGS and $CFLAGS environment variables were empty. It turns out that this flag is triggered by hardening-wrapper.
So, I overrode the flag by invoking the final step as follows, and wxPython was installed successfully:
CFLAGS=-Wno-error=format-security CPPFLAGS=-Wno-error=format-security python setup.py install
When I want to install the package wxPython-2.8.7.1.spkg from here
in the terminal of Sage it gives me a syntax error. What i write in Sage terminal and the result are as follow:
sage: sage -i wxPython-2.8.7.1.spkg
------------------------------------------------------------
File "<ipython console>", line 1
sage -i wxPython-RealNumber('2.8').gen(7).1.spkg
^
SyntaxError: invalid syntax
I also use the direct address of the package but the result was the same:
sage: sage -i http://www.sagemath.org/packages/experimental/wxPython-2.8.7.1.s>
------------------------------------------------------------
File "<ipython console>", line 1
sage -i http://www.sagemath.org/packages/experimental/wxPython-RealNumber('2.8').gen(7).1.spkg
^
SyntaxError: invalid syntax
I also downloaded the package and used the local address but the result was the same.
You need to do this from the command line before starting Sage. Otherwise you can use
sage: install_package("wxPython")
which is currently downloading for me... and then failed:
checking for GTK+ - version >= 2.0.0... no
*** Could not run GTK+ test program, checking why...
*** The test program failed to compile or link. See the file config.log for the
*** exact error that occured. This usually means GTK+ is incorrectly installed.
configure: error:
The development files for GTK+ were not found. For GTK+ 2, please
ensure that pkg-config is in the path and that gtk+-2.0.pc is
installed. For GTK+ 1.2 please check that gtk-config is in the path,
and that the version is 1.2.3 or above. Also check that the
libraries returned by 'pkg-config gtk+-2.0 --libs' or 'gtk-config
--libs' are in the LD_LIBRARY_PATH or equivalent.
Error configure wx widgets.
real 0m13.972s
user 0m2.791s
sys 0m5.232s
************************************************************************
Error installing package wxPython-2.8.7.1
************************************************************************
Along those lines, here is what it says at the list of experimental spkgs, of which this is one:
These are EXPERIMENTAL! They probably won't work at all for you! Use at your own risk! Many of these have never been successfully built on any platform!
So buyer beware!
That is, following the instructions in zxing/cpp/README, which say 'To build the library only:
- Run "scons lib" in this folder (cpp)'
Well, that is exactly what I did. But I get:
scons lib
scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Building targets ...
o build/core/src/zxing/BarcodeFormat.o -c -O0 -g3 -ggdb -Wall -Ibuild/core/src build/core/src/zxing/BarcodeFormat.cpp
sh: o: command not found
Withs this "O: command not found" repeated many times.
I thought the problem might be gcc not found, so I checked for that: it is installed. I took only a brief look at the python of scons before I gave up on trying to figure ouw why it is looking for a command 'o'. Of course there is none.
BTW: I got my copy of zxing 1.7 using wget only three days ago and the yum installation of 'scons' today. So they are up-to-date.
It is likely that you are correct, and that SCons isn't finding GCC. Your best bet is to add a call to display the contents of some (or all) of the environment. As shown below, you can either pull out specific variable, or show the whole environment. The best place would probably near a call to the builder (SharedLibrary, StaticLibrary or Program). For an environment named 'env':
print env.Dump()
print env['CC']
print env['CXX']
Ensuring that an appropriate default environment is being used initially (probably something like):
env = DefaultEnvironment( ... )
Or that the environment variables on your system (including path) are being propagated through to SCons. One way to do this is by:
import os
# ...
env = Environment( ENV = os.environ, ... )
In extreme cases you can resolve this problem by providing an explicit path to the compiler:
env['CC'] = '/usr/bin/gcc'
Edit:
These changes need to be made in an appropriate SConstruct or SConscript file. Which depends on the exact project, and what you're trying to achieve - in the case of the current version of zxing on google code, it would be reasonable to make the changes on or near line 40 of the SConscript file
I'm trying to install libjpeg on os X to fix a problem with the Python Imaging Library JPEG setup.
I downloaded libjpeg from http://www.ijg.org/files/jpegsrc.v7.tar.gz
I then began to setup the config file
cp /usr/share/libtool/config.sub .
cp /usr/share/libtool/config.guess .
./configure –enable-shared
However, the enable-shared flag didn't seem to work.
$ ./configure –-enable-shared
configure: WARNING: you should use --build, --host, --target
configure: WARNING: invalid host type: –-enable-shared
checking build system type... Invalid configuration `–-enable-shared': machine `–-enable' not recognized
configure: error: /bin/sh ./config.sub –-enable-shared failed
I've done lot's of google searches and I can't figure out where the error is or how to work around this error.
I had copied the code from a blog.
The flag character there was not a hyphem , it just looked like one:
ord("–")
TypeError: ord() expected a character, but string of length 3 found
I changed it to a proper hypen and it works fine.