Python distutils gcc path

2024/10/3 0:29:23

I'm trying to cross-compile the pycrypto package, and I'm getting closer and closer however, I've hit an issue I just can't figure out.

I want distutils to use the cross-compile specific gcc- so I set the CC env var and it seems to respect the setting for the first invocation of the compiler, but thats it.

export CC="/opt/teeos/buildroot/output/host/usr/bin/i586-linux-gcc"
/opt/teeos/buildroot/output/host/usr/bin/i586-linux-gcc -fno-strict-aliasing -fwrapv -Wall -Wstrict-prototypes -fPIC -std=c99 --sysroot=/opt/teeos/buildroot/output/staging -I/opt/teeos/buildroot/output/staging/usr/include/python2.7 -O3 -fomit-frame-pointer -Isrc/ -I/usr/include/python2.7 -c src/_fastmath.c -o build/temp.linux-i686-2.7/src/_fastmath.o
gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions build/temp.linux-i686-2.7/src/_fastmath.o -lgmp -o build/lib.linux-i686-2.7/Crypto/PublicKey/_fastmath.so
unable to execute gcc: No such file or directory

I temporarily moved my systems gcc so it can't be found.

How do I make distutils respect the CC=/opt/buildroot... option for every invocation of the compiler / set the path to the GCC / LD I want distutils to use?

Answer

This sounds similar to another answer I recently gave for customizing the distutils compiler. You'll also need to define LDSHARED which is the command used to produce the final shared object. See if this works:

>>> from distutils import sysconfig
>>> sysconfig.get_config_var('LDSHARED')
'gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions'
>>> sysconfig.get_config_var('CC')
'gcc -pthread'

Then replace gcc with your desired compiler and options in the CC and LDSHARED environment variables:

% LDSHARED="i586-linux-gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions" \CC="i586-linux-gcc -pthread" python setup.py build
https://en.xdnf.cn/q/70785.html

Related Q&A

TypeError: builtin_function_or_method object has no attribute __getitem__

Ive got simple python functions.def readMainTemplate(templateFile):template = open(templateFile, r)data = template.read()index1 = data.index[[] #originally I passed it into data[]index2 = data.index[]]…

Extract currency amount from string in Python

Im making a program that takes currency from a string and converts it in to other currencies. For example, if the string was the car cost me $13,250 I would need to get $ and 13250. I have this regex a…

Error: The elasticsearch backend requires the installation of requests. How do I fix it?

Im having a issue when I ran "python manage.py rebuild_index" in my app supported by haystack and elasticsearch.Python 2.7 Django version 1.6.2 Haystack 2.1.0 Elasticsearch 1.0Please see the …

numpy: applying argsort to an array

The argsort() function returns a matrix of indices that can be used to index the original array so that the result would match the sort() result.Is there a way to apply those indices? I have two array…

Jinja2 for word templating

I would like to use jinja2 for word templating like mentioned is this short article. The problem Im facing is as follows, if I put {{title}} in my word-file the resulting xml can look like this:<w:r…

API capture all paginated data? (python)

Im using the requests package to hit an API (greenhouse.io). The API is paginated so I need to loop through the pages to get all the data I want. Using something like:results = [] for i in range(1,326+…

How to convert latitude longitude to decimal in python?

Assuming I have the following:latitude = "20-55-70.010N" longitude = "32-11-50.000W"What is the easiest way to convert to decimal form? Is there some library?Would converting from…

No module named main, wkhtmltopdf issue

Im new in python, but all search results i found was useless for me.C:\Users\Aero>pip install wkhtmltopdf Collecting wkhtmltopdfUsing cached wkhtmltopdf-0.2.tar.gz Installing collected packages: wkh…

Is there a Python shortcut for variable checking and assignment?

Im finding myself typing the following a lot (developing for Django, if thats relevant):if testVariable then:myVariable = testVariable else:# something elseAlternatively, and more commonly (i.e. buildi…

python scipy Delaunay plotting point cloud

I have a pointlist=[p1,p2,p3...] where p1 = [x1,y1],p2=[x2,y2] ...I want to use scipy.spatial.Delaunay to do trianglation on these point clouds and then plot itHow can i do this ?The documentation for…