I'm using Travis to test Python code on various versions and architectures. I'm trying to throw a 32-bit Linux architecture into the mix.
The .travis.yml below seems to succeed in the sense that I see in the table entry for my arch: x86 job. But I also see the following output in the log, from my introspective Python code:
$ python -c 'import sys,struct,platform;print("{\n%s}"%"".join(" %25r %c %r,\n"%(c,58,eval(c)) for c in """struct.calcsize("P")*8 sys.maxsize platform.machine() platform.architecture()""".split()))'
{
'struct.calcsize("P")*8' : 64,
'sys.maxsize' : 9223372036854775807,
'platform.machine()' : 'x86_64',
'platform.architecture()' : ('64bit', 'ELF'),
}
For a 32-bit build of Python, struct.calcsize("P")*8 should return 32 and sys.maxsize should be 2147483647. The output I'm actually getting implies a 64-bit build. And since I don't believe 64-bit binaries can run on 32-bit machines, something counterintuitive seems to be going on. What am I overlooking?
# Welcome to .travis.yml
os: linux
arch: x64
language: python
install:
- python -c 'import sys,struct,platform;print("{\n%s}"%"".join(" %25r %c %r,\n"%(c,58,eval(c)) for c in """struct.calcsize("P")*8 sys.maxsize platform.machine() platform.architecture()""".split()))'
- python -m pip install --upgrade pip
- python -m pip install pytest
- python -m pip install .
script:
- python -m pytest -v .
matrix:
include:
- python: 2.7
# ...
- python: 3.8
- name: "Python 3.8 on 32-bit Linux"
arch: x86
python: 3.8
Related
I'm using ubuntu 22.04 and python version installed there is '3.10.4' while sqlite version is '3.37.2'. I need to use python '3.9.5' and sqlite '3.31.1' because the server that my code will live uses that.
Using pyenv fixes the problem for python but the sqlite one didn't. So I resort on building the sqlite from the source and try to link on pyenv install.
Basically this is what I tried to do:
~$ mkdir -p ~/usrapps/src
~$ cd ~/usrapps/src/
~/usrapps/src$ wget https://www.sqlite.org/2020/sqlite-autoconf-3310100.tar.gz
~/usrapps/src$ tar xvvf sqlite-autoconf-3310100.tar.gz
~/usrapps/src$ cd sqlite-autoconf-3310100/
~/usrapps/src/sqlite-autoconf-3310100$ mkdir -p ~/usrapps/sqlite3311
~/usrapps/src/sqlite-autoconf-3310100$ ./configure --prefix=/home/paulo/usrapps/sqlite3311
~/usrapps/src/sqlite-autoconf-3310100$ make
~/usrapps/src/sqlite-autoconf-3310100$ make install
~/usrapps/src/sqlite-autoconf-3310100$ cd ~/
Here's the full terminal ouput
Now for installation of python 3.9.5, I do this different scenarios but first, brew-pyenv-i is aliased to CC="$(brew --prefix gcc)/bin/gcc-12" pyenv install the reason is I encounter a issue where installing python result to "BUILD FAILED: Mising OpenSSL" even though I have openssl install. Doing this fixed my issue, here's the reference.
I uninstall first python(installed by pyenv) before each scenarios.
scenario 1 - log:
~$ LDFLAGS="-L/home/paulo/usrapps/sqlite3311/lib" CPPFLAGS="-I/home/paulo/usrapps/sqlite3311/include" brew-pyenv-i 3.9.5
scenario 2 - log:
~$ PYTHON_CONFIGURE_OPTS="LD_RUN_PATH=/home/paulo/usrapps/sqlite3311/lib LDFLAGS=-L/home/paulo/usrapps/sqlite3311/lib" brew-pyenv-i 3.9.5
scenario 3 - log:
~$ PYTHON_CONFIGURE_OPTS="LD_RUN_PATH=/home/paulo/usrapps/sqlite3311/lib LDFLAGS=-L/home/paulo/usrapps/sqlite3311/lib CPPFLAGS=-I/home/paulo/usrapps/sqlite3311/include" brew-pyenv-i 3.9.5
All attempts are successfully installed the python 3.9.5, but when I try check the sqlite version, its still same, not '3.31.1'
~$ pyenv shell 3.9.5
~$ python
Python 3.9.5 (default, Aug 26 2022, 08:45:14)
[GCC 12.1.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import sqlite3
>>> sqlite3.sqlite_version
'3.37.2'
I would like to avoid using pysqlite3, because that's mean I have to rewrite some of my code and my goal is not really to use multiple versions of sqlite in my app.
I'm using CocoTB to test my HDL design, but as I understand, it's possible to use it with python2.7 or python3.
In setup.py config file I can see that both are supported :
[...]
"Programming Language :: Python :: 2.7",
"Programming Language :: Python :: 3",
[...]
In endian_swapper test (examples/endian_swapper/tests/test_endian_swapper.py), if I modify a test script to see which version is used :
#cocotb.test()
def wavedrom_test(dut):
"""
Generate a JSON wavedrom diagram of a trace and save it to wavedrom.json
"""
print("Python version used {}".format(sys.version_info))
I can see that python2.7 is used when I launch test with «make» command :
Python version used sys.version_info(major=2, minor=7, micro=9, releaselevel='final', serial=0)
My python3 executable is named ... python3 in fact (debian). Is there a canonical way to force cocotb to use python3 instead of python2 ?
try updating the PATH variable. worked for me.
when cocotb looks for python, it looks for it at the folders that are listed at the PATH variable.
let say that your python3 full path is at/usr/bin/python3
(you can find python3 full path by which python3)
i also added here link to new place in case both python2 and python3 are at the same folder...
> python -V
Python 2.7.17
> ln -s /usr/bin/python3 /home/$USER/python
> export PATH="/home/$USER:$PATH"
> python -V
Python 3.6.9
I found a proper way to do it.
First download the last version of python on the official website :
$ wget https://www.python.org/ftp/python/3.7.4/Python-3.7.4.tar.xz
Then unflat it and configure it with the option --enable-shared
$ tar -Jxvf Python-3.7.4.tar.xz
$ cd Python-3.7.4
$ ./configure --enable-shared
$ make
$ sudo make install
Once installed go to your cocotb test directory then install virtual environment :
$ export LD_LIBRARY_PATH=/usr/local/lib
$ virtualenv --python=/usr/local/bin/python3.7 envp37
$ source envp37/bin/activate
$ python -m pip install cocotb
Then you can launch your cocotb test environment with traditional make :
$ make
Dectivate the python environment with :
$ deactivate
I found solutions on linuxconfig.org, thanks to themperek. But it's not exactly what I want.
The alias solution doesn't work for me. The update-alternative works but only with «official» python3 installed on debian. I can't use an alternative (3.7) manually installed.
$ sudo update-alternatives --config python
There are 3 choices for the alternative python (providing /usr/bin/python).
Selection Path Priority Status
------------------------------------------------------------
0 /usr/bin/python3.7 2 auto mode
1 /usr/bin/python2.7 0 manual mode
2 /usr/bin/python3.4 1 manual mode
* 3 /usr/bin/python3.7 2 manual mode
Press enter to keep the current choice[*], or type selection number: 3
$ make clean;make
0.00ns INFO Running on Icarus Verilog version 11.0 (devel)
0.00ns INFO Python interpreter initialised and cocotb loaded!
0.00ns INFO Running tests with Cocotb v1.0.1 from /opt/cocotb
0.00ns INFO Seeding Python random module with 1554105931
0.00ns INFO Found test test_ttl.ttl_test
0.00ns INFO Running test 1/1: ttl_test
0.00ns INFO Starting test: "ttl_test"
Description: simple ttl test function
[...]
3.4.2 (default, Feb 7 2019, 06:11:23)
[...]
Base situation:
Platform: ARM Cortex-A9 (32-bit processor)
OS: Ubuntu Mate 16.04.4
gcc version: gcc (Ubuntu/Linaro 5.4.0-6ubuntu1-16.04.4) 5.4.0 201606609
python version: 2.7.12
Question:
I want to install anaconda on ARM Cortex-A9 platform. However, when I execute:
$./Anaconda2-5.0.1-Linux-x86.sh
It return an error:
/root/anaconda2/pkgs/python-2.7.14-h41cc02d_21/bin/python:1: /root/anaconda2/pkgs/python-2.7.14-h41cc02d_21/bin/python:Syntax error:word unexpected (expecting ")")
How I can fit this problem? How I can install anaconda on ARM platform?
Tks.
I think you need to run the command like this:
$ bash Anaconda2-5.0.1-Linux-x86.sh
because it's actually a bash script :)
I am installing Hyperledger Indy (sovrin) self-identity software per these instructions.
I have Python2.7 installed via Anaconda 3. I also have Python3.6.3 installed that I downloaded and installed from here.
I'm trying to install some other software that has a dependency for Python > 3.5.
I've tried several methods to change my default Python:
Per this SO I set it manual in current terminal window:
alias python='python3'
Per same SO I vi .bash_profile and added:
alias python='python3'
then source ~/.bash_profile
Set a link to Python3:
bc-computer:~ momi$ unlink /usr/local/bin/python2
bc-computer:~ momi$ ln -s /usr/local/bin/python3 /usr/local/bin/python
but still continue to get the same error:
bc-computer:~ momi$ pip install indy-node-dev
Collecting indy-node-dev
Using cached indy-node-dev-1.2.227.tar.gz
Complete output from command python setup.py egg_info:
FAIL: Requires Python 3.5 or later, but setup.py was run using 2.7.14
NOTE: Installation failed. Run setup.py using python3
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/3f/sh6dr8wx6w720b1_w38f_fh00000gq/T/pip-build-ecZnYY/indy-node-dev/
I also tried setting up a python3 test environment per this:
python3 setup.py test
And got this error:
> /usr/local/Cellar/python3/3.6.3/Frameworks/Python.framework/Versions/3.6/Resources/Python.app/Contents/MacOS/Python:
> can't open file 'setup.py': [Errno 2] No such file or directory
Please note that I tried this suggestion which seems to be the non-duplicate answer but didn't work for me:
The safest way is to set an alias in ~/.bashrc:
alias python=python3
My environment:
uname -msra
Darwin bc-computer.local 17.2.0 Darwin Kernel Version 17.2.0: Fri Sep 29 18:27:05 PDT 2017; root:xnu-4570.20.62~3/RELEASE_X86_64 x86_64
My OS:
High Sierra 10.13.1
which -a python
/Users/momi/anaconda2/bin/python
/usr/local/bin/python
/usr/bin/python
Thank you
Ok the solution was to use pip3 rather than pip for my install command per Mike Mueller's answer here:
pip3 install indy-node-dev
I assume that pip3 points to python3x rather than 2x.
I have also installed Hyperledger Indy SSI VC using MacOs Python 3.6.3. It is working for for me. I could demo the VON Network. It seems that your machine environment still points to Python 2.7. There are different ways by which we can point to Python 3.6.3 through virtual environment. You can try those options.
I have compiled SQLite3 3.8.6 and installed it to ${HOME}/opt with:
LDFLAGS="-L${HOME}/opt/lib" CFLAGS="-L${HOME}/opt/include" ./configure --prefix=$HOME/opt
make && make install
I am now trying to compile Python 3.4.2 to use this version instead of the version installed for the entire system. I do not have root access on this system. To compile Python, I am using:
LDFLAGS="-L${HOME}/opt/lib" CFLAGS="-L${HOME}/opt/include" ./configure --prefix=$HOME/opt
make && make install
I was able to compile Python 3.3.5 with my newer version if SQLite3, but these same steps don't seem to work for me for 3.4.2.
How can I compile Python 3.4.2 to include my version of SQLite 3.8.6 which is located in ${HOME}/opt?
Thanks.
EDIT: It compiles & installs OK except for the fact that is using the older, system version of sqlite3 instead of the version that I compiled & installed myself.
There is also the option of pre-linking your custom Python build with your own-built sqlite3. (I had the same issue: the custom python was using the system-provided sqlite3, completely ignoring the sqlite3 I built).
Prefix your configure and make commands with:
LD_RUN_PATH=$HOME/opt/lib configure LDFLAGS="-L$HOME/opt/lib" CPPFLAGS="-I$HOME/opt/include" …
LD_RUN_PATH=$HOME/opt/lib make
so that the built python3 by default is linked to your sqlite3.
This worked for me.
import platform,sqlite3
print("Oper Sys : %s %s" % (platform.system(), platform.release()))
print("Platform : %s %s" % (platform.python_implementation(),platform.python_version()))
print("SQLite : %s" % (sqlite3.sqlite_version))
When I run this code, the output contains the system's version of sqlite3:
Oper Sys : Linux 3.2.0-4-amd64
Platform : CPython 3.4.2
SQLite : 3.7.13
After installing sqlite v3.8.6 under ${HOME}/opt{include,lib} and setting this in my .bashrc:
export LD_LIBRARY_PATH="${HOME}/opt/lib"
I get my desired result:
Oper Sys : Linux 3.2.0-4-amd64
Platform : CPython 3.4.2
SQLite : 3.8.6
Notice the SQLite version changes from 3.7.13 to 3.8.6
Hi for me helped this:
cd /tmp
wget https://www.sqlite.org/2019/sqlite-autoconf-3280000.tar.gz
tar xvf sqlite-autoconf-3280000.tar.gz
mv /usr/bin/sqlite3 /usr/bin/sqlite3.7
cp /tmp/sqlite-autoconf-3280000/sqlite3 /usr/bin/sqlite3
cp /tmp/sqlite-autoconf-3280000/.libs/libsqlite3.so.0.8.6 /usr/lib64/libsqlite3.so.0.8.6
cp /tmp/sqlite-autoconf-3280000/.libs/libsqlite3.so.0 /usr/lib64/libsqlite3.so.0