vddvss / linux-gpib-packaging

RPM specfiles and patches to install linux-gpib on Fedora
5 stars 3 forks source link

Python3? #2

Closed jondoesntgit closed 5 years ago

jondoesntgit commented 5 years ago

I can install python2 bindings using this code:

sudo dnf install dkms-linux-gpib python-linux-gpib

How do I install python3 bindings?

jondoesntgit commented 5 years ago
# dnf install dkms-linux-gpib python3-linux-gpib

Visual Studio Code                                                                          0.0  B/s |   0  B     00:00    
Package dkms-linux-gpib-4.2.0-2.20190107svn1809.el7.noarch is already installed.
No match for argument: python3-linux-gpib
Error: Unable to find a match: python3-linux-gpib
(development) [daq@digonnetlab2 source]$ sudo dnf install dkms-linux-gpib python3-linux-gpib
Visual Studio Code                                                                          0.0  B/s |   0  B     00:00    
Package dkms-linux-gpib-4.2.0-2.20190107svn1809.el7.noarch is already installed.
No match for argument: python3-linux-gpib
Error: Unable to find a match: python3-linux-gpib
jondoesntgit commented 5 years ago

For context, I'm working in CentOS 7.

vddvss commented 5 years ago

The package for CentOS 7 is actually called python34-linux-gpib, so as to be consistent with the other python packages there. Let me know if this works for you.

jondoesntgit commented 5 years ago
# dnf install dkms-linux-gpib python37-linux-gpib

Visual Studio Code                                                                          0.0  B/s |   0  B     00:00    
Package dkms-linux-gpib-4.2.0-2.20190107svn1809.el7.noarch is already installed.
No match for argument: python37-linux-gpib
Error: Unable to find a match: python37-linux-gpib
[daq@digonnetlab2 nivisa]$ sudo dnf install dkms-linux-gpib python34-linux-gpib
Visual Studio Code                                                                          0.0  B/s |   0  B     00:00    
Package dkms-linux-gpib-4.2.0-2.20190107svn1809.el7.noarch is already installed.
Error: 
 Problem: conflicting requests
  - nothing provides libpython3.4m.so.1.0()(64bit) needed by python34-linux-gpib-4.2.0-2.20190107svn1809.el7.x86_64
  - nothing provides python(abi) = 3.4 needed by python34-linux-gpib-4.2.0-2.20190107svn1809.el7.x86_64
jondoesntgit commented 5 years ago

That was done with python 3.7. I tried making a new virtual environment with python 3.4, and that didn't work either.

python --version
Python 3.4.5 :: Continuum Analytics, Inc.
vddvss commented 5 years ago

Ok, I don't think EPEL has a python 3.7 package, so I imagine you are using another repo for python. I don't think I can build that using copr, since it looks like the most recent version in EPEL is 3.6. Can you try using the Fedora 29 version of the package, since that is linked against 3.7?

$ wget https://copr-be.cloud.fedoraproject.org/results/vddvss/linux-gpib/fedora-29-x86_64/00864234-linux-gpib/python3-linux-gpib-4.2.0-2.20190107svn1809.fc29.x86_64.rpm

# dnf install ./python3-linux-gpib-4.2.0-2.20190107svn1809.fc29.x86_64.rpm
jondoesntgit commented 5 years ago
# dnf install ./python3-linux-gpib-4.2.0-2.20190107svn1809.fc29.x86_64.rpm

Visual Studio Code                                                                                         0.0  B/s |   0  B     00:00    
Error: 
 Problem: conflicting requests
  - nothing provides libpython3.7m.so.1.0()(64bit) needed by python3-linux-gpib-4.2.0-2.20190107svn1809.fc29.x86_64
  - nothing provides linux-gpib(x86-64) = 4.2.0-2.20190107svn1809.fc29 needed by python3-linux-gpib-4.2.0-2.20190107svn1809.fc29.x86_64
  - nothing provides python(abi) = 3.7 needed by python3-linux-gpib-4.2.0-2.20190107svn1809.fc29.x86_64
vddvss commented 5 years ago

Hmm, what repo are you using for python 3.7?

jondoesntgit commented 5 years ago
conda create --name py37 python=3.7
vddvss commented 5 years ago

Ok, so it looks like conda manages its own python packages, so you will have to build the python part using conda. I think the proper way to do it is here: https://conda.io/projects/conda-build/en/latest/concepts/recipe.html

The quick and dirty way is here: https://conda.io/projects/conda-build/en/latest/user-guide/recipes/build-without-recipe.html

After installing conda-build, you should be able to do the following (disclaimer: I have tested the commands, but I don't have conda installed, so I'm not sure if it will work).

$ svn export -r 1809 https://svn.code.sf.net/p/linux-gpib/code/trunk linux-gpib
$ cd linux-gpib/linux-gpib-user/language/python
$ ed setup.py <<EOF
3a
import distutils.command.bdist_conda
.
7a
    distclass=distutils.command.bdist_conda.CondaDistribution,
    conda_buildnum=1,
.
w
EOF

$ setup.py bdist_conda
jondoesntgit commented 5 years ago

Close

$python setup.py bdist_conda

running bdist_conda
Adding in variants from internal_defaults
INFO:conda_build.variants:Adding in variants from internal_defaults
Adding in variants from config.variant
INFO:conda_build.variants:Adding in variants from config.variant
No numpy version specified in conda_build_config.yaml.  Falling back to default numpy value of 1.11
WARNING:conda_build.metadata:No numpy version specified in conda_build_config.yaml.  Falling back to default numpy value of 1.11
Attempting to finalize metadata for gpib
INFO:conda_build.metadata:Attempting to finalize metadata for gpib
Solving environment: ...working... done
BUILD START: ['gpib-1.0-py37_1.tar.bz2']
Solving environment: ...working... done

## Package Plan ##

  environment location: /home/daq/anaconda3/conda-bld/bdist_conda_1553635128120/_h_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_pl

The following NEW packages will be INSTALLED:

    ca-certificates: 2019.1.23-0            
    certifi:         2019.3.9-py37_0        
    libedit:         3.1.20181209-hc058e9b_0
    libffi:          3.2.1-hd88cf55_4       
    libgcc-ng:       8.2.0-hdf63c60_1       
    libstdcxx-ng:    8.2.0-hdf63c60_1       
    ncurses:         6.1-he6710b0_1         
    openssl:         1.1.1b-h7b6447c_1      
    pip:             19.0.3-py37_0          
    python:          3.7.2-h0371630_0       
    readline:        7.0-h7b6447c_5         
    setuptools:      40.8.0-py37_0          
    sqlite:          3.27.2-h7b6447c_0      
    tk:              8.6.8-hbc83047_0       
    wheel:           0.33.1-py37_0          
    xz:              5.2.4-h14c3975_4       
    zlib:            1.2.11-h7b6447c_3      

Preparing transaction: ...working... done
Verifying transaction: ...working... done
Executing transaction: ...working... done
source tree in: /home/daq/anaconda3/conda-bld/bdist_conda_1553635128120/work
STOPPING BUILD BEFORE POST: gpib-1.0-py37_1
####################################################################################
Resource usage summary:

Total time: 0:00:04.7
CPU usage: sys=0:00:00.0, user=0:00:00.0
Maximum memory usage observed: 0B
Total disk usage observed (not including envs): 0B
running build
running build_py
running build_ext
building 'gpib' extension
gcc -pthread -B /home/daq/anaconda3/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I../../include -I/home/daq/anaconda3/include/python3.7m -c gpibinter.c -o build/temp.linux-x86_64-3.7/gpibinter.o
gcc -pthread -shared -B /home/daq/anaconda3/compiler_compat -L/home/daq/anaconda3/lib -Wl,-rpath=/home/daq/anaconda3/lib -Wl,--no-as-needed -Wl,--sysroot=/ build/temp.linux-x86_64-3.7/gpibinter.o -L../../lib/.libs -lgpib -lpthread -o build/lib.linux-x86_64-3.7/gpib.cpython-37m-x86_64-linux-gnu.so
/home/daq/anaconda3/compiler_compat/ld: cannot find -lgpib
collect2: error: ld returned 1 exit status
error: command 'gcc' failed with exit status 1
vddvss commented 5 years ago

Oh, have you installed linux-gpib-devel?

jondoesntgit commented 5 years ago

No I didn't.

After running

# dnf install dkms-linux-gpib linux-gpib-devel

I was able to build successfully. Let me test now.

jondoesntgit commented 5 years ago

Hmm...

When I try >>> import gpib, I get "module not found"

python setup.py bdist_conda
running bdist_conda
Adding in variants from internal_defaults
INFO:conda_build.variants:Adding in variants from internal_defaults
Adding in variants from config.variant
INFO:conda_build.variants:Adding in variants from config.variant
No numpy version specified in conda_build_config.yaml.  Falling back to default numpy value of 1.11
WARNING:conda_build.metadata:No numpy version specified in conda_build_config.yaml.  Falling back to default numpy value of 1.11
Attempting to finalize metadata for gpib
INFO:conda_build.metadata:Attempting to finalize metadata for gpib
Solving environment: ...working... done
BUILD START: ['gpib-1.0-py37_1.tar.bz2']
Solving environment: ...working... done

## Package Plan ##

  environment location: /home/daq/anaconda3/conda-bld/bdist_conda_1553636348287/_h_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_pl

The following NEW packages will be INSTALLED:

    ca-certificates: 2019.1.23-0            
    certifi:         2019.3.9-py37_0        
    libedit:         3.1.20181209-hc058e9b_0
    libffi:          3.2.1-hd88cf55_4       
    libgcc-ng:       8.2.0-hdf63c60_1       
    libstdcxx-ng:    8.2.0-hdf63c60_1       
    ncurses:         6.1-he6710b0_1         
    openssl:         1.1.1b-h7b6447c_1      
    pip:             19.0.3-py37_0          
    python:          3.7.2-h0371630_0       
    readline:        7.0-h7b6447c_5         
    setuptools:      40.8.0-py37_0          
    sqlite:          3.27.2-h7b6447c_0      
    tk:              8.6.8-hbc83047_0       
    wheel:           0.33.1-py37_0          
    xz:              5.2.4-h14c3975_4       
    zlib:            1.2.11-h7b6447c_3      

Preparing transaction: ...working... done
Verifying transaction: ...working... done
Executing transaction: ...working... done
source tree in: /home/daq/anaconda3/conda-bld/bdist_conda_1553636348287/work
STOPPING BUILD BEFORE POST: gpib-1.0-py37_1
####################################################################################
Resource usage summary:

Total time: 0:00:13.0
CPU usage: sys=0:00:00.0, user=0:00:00.0
Maximum memory usage observed: 0B
Total disk usage observed (not including envs): 0B
running build
running build_py
running build_ext
running install_lib
creating /home/daq/anaconda3/conda-bld/bdist_conda_1553636348287
creating /home/daq/anaconda3/conda-bld/bdist_conda_1553636348287/_h_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_pl
creating /home/daq/anaconda3/conda-bld/bdist_conda_1553636348287/_h_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_pl/lib
creating /home/daq/anaconda3/conda-bld/bdist_conda_1553636348287/_h_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_pl/lib/python3.7
creating /home/daq/anaconda3/conda-bld/bdist_conda_1553636348287/_h_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_pl/lib/python3.7/site-packages
copying build/lib.linux-x86_64-3.7/Gpib.py -> /home/daq/anaconda3/conda-bld/bdist_conda_1553636348287/_h_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_pl/lib/python3.7/site-packages
copying build/lib.linux-x86_64-3.7/gpib.cpython-37m-x86_64-linux-gnu.so -> /home/daq/anaconda3/conda-bld/bdist_conda_1553636348287/_h_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_pl/lib/python3.7/site-packages
byte-compiling /home/daq/anaconda3/conda-bld/bdist_conda_1553636348287/_h_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_pl/lib/python3.7/site-packages/Gpib.py to Gpib.cpython-37.pyc
running install_egg_info
Writing /home/daq/anaconda3/conda-bld/bdist_conda_1553636348287/_h_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_pl/lib/python3.7/site-packages/gpib-1.0-py3.7.egg-info
Packaging gpib
INFO:conda_build.build:Packaging gpib
Solving environment: ...working... done

## Package Plan ##

  environment location: /home/daq/anaconda3/conda-bld/bdist_conda_1553636348287/_h_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_pl

The following NEW packages will be INSTALLED:

    ca-certificates: 2019.1.23-0            
    certifi:         2019.3.9-py37_0        
    libedit:         3.1.20181209-hc058e9b_0
    libffi:          3.2.1-hd88cf55_4       
    libgcc-ng:       8.2.0-hdf63c60_1       
    libstdcxx-ng:    8.2.0-hdf63c60_1       
    ncurses:         6.1-he6710b0_1         
    openssl:         1.1.1b-h7b6447c_1      
    pip:             19.0.3-py37_0          
    python:          3.7.2-h0371630_0       
    readline:        7.0-h7b6447c_5         
    setuptools:      40.8.0-py37_0          
    sqlite:          3.27.2-h7b6447c_0      
    tk:              8.6.8-hbc83047_0       
    wheel:           0.33.1-py37_0          
    xz:              5.2.4-h14c3975_4       
    zlib:            1.2.11-h7b6447c_3      

Preparing transaction: ...working... done
Verifying transaction: ...working... done
Executing transaction: ...working... done
Packaging gpib-1.0-py37_1
INFO:conda_build.build:Packaging gpib-1.0-py37_1
compiling .pyc files...
number of files: 4
Warning: rpath /home/daq/anaconda3/lib is outside prefix /home/daq/anaconda3/conda-bld/bdist_conda_1553636348287/_h_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_pl (removing it)
patchelf: file: /home/daq/anaconda3/conda-bld/bdist_conda_1553636348287/_h_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_pl/lib/python3.7/site-packages/gpib.cpython-37m-x86_64-linux-gnu.so
    setting rpath to: $ORIGIN/../..
WARNING (gpib,lib/python3.7/site-packages/gpib.cpython-37m-x86_64-linux-gnu.so): Needed DSO / not found in any CDT/compiler package, nor the whitelist?!
WARNING (gpib,lib/python3.7/site-packages/gpib.cpython-37m-x86_64-linux-gnu.so): Needed DSO / not found in any CDT/compiler package, nor the whitelist?!
WARNING (gpib,lib/python3.7/site-packages/gpib.cpython-37m-x86_64-linux-gnu.so): Needed DSO / not found in any CDT/compiler package, nor the whitelist?!
Fixing permissions
Compressing to /tmp/tmpo2jynnrw/gpib-1.0-py37_1.tar.bz2
Package verification results:
-----------------------------
/tmp/tmpo2jynnrw/gpib-1.0-py37_1.tar.bz2: C1115 Found invalid license "None" in info/index.json
# Automatic uploading is disabled
# If you want to upload package(s) to anaconda.org later, type:

anaconda upload /home/daq/anaconda3/conda-bld/linux-64/gpib-1.0-py37_1.tar.bz2

# To have conda build upload to anaconda.org automatically, use
# $ conda config --set anaconda_upload yes

anaconda_upload is not set.  Not uploading wheels: []
####################################################################################
Resource usage summary:

Total time: 0:00:11.1
CPU usage: sys=0:00:00.0, user=0:00:00.0
Maximum memory usage observed: 0B
Total disk usage observed (not including envs): 0B
TEST START: /home/daq/anaconda3/conda-bld/linux-64/gpib-1.0-py37_1.tar.bz2
Adding in variants from /tmp/tmpbb8x08qb/info/recipe/conda_build_config.yaml
INFO:conda_build.variants:Adding in variants from /tmp/tmpbb8x08qb/info/recipe/conda_build_config.yaml
Renaming work directory,  /home/daq/anaconda3/conda-bld/bdist_conda_1553636348287/work  to  /home/daq/anaconda3/conda-bld/bdist_conda_1553636348287/work_moved_gpib-1.0-py37_1_linux-64
Solving environment: ...working... done

## Package Plan ##

  environment location: /home/daq/anaconda3/conda-bld/bdist_conda_1553636348287/_test_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold

The following NEW packages will be INSTALLED:

    ca-certificates: 2019.1.23-0                  
    certifi:         2019.3.9-py37_0              
    gpib:            1.0-py37_1              local
    libedit:         3.1.20181209-hc058e9b_0      
    libffi:          3.2.1-hd88cf55_4             
    libgcc-ng:       8.2.0-hdf63c60_1             
    libstdcxx-ng:    8.2.0-hdf63c60_1             
    ncurses:         6.1-he6710b0_1               
    openssl:         1.1.1b-h7b6447c_1            
    pip:             19.0.3-py37_0                
    python:          3.7.2-h0371630_0             
    readline:        7.0-h7b6447c_5               
    setuptools:      40.8.0-py37_0                
    sqlite:          3.27.2-h7b6447c_0            
    tk:              8.6.8-hbc83047_0             
    wheel:           0.33.1-py37_0                
    xz:              5.2.4-h14c3975_4             
    zlib:            1.2.11-h7b6447c_3            

Preparing transaction: ...working... done
Verifying transaction: ...working... done
Executing transaction: ...working... done
export PREFIX=/home/daq/anaconda3/conda-bld/bdist_conda_1553636348287/_test_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold
export SRC_DIR=/home/daq/anaconda3/conda-bld/bdist_conda_1553636348287/test_tmp
import: 'Gpib'
import: 'Gpib'

Resource usage statistics from testing gpib:
   Process count: 1
   CPU time: unavailable
   Memory: 1.5M
   Disk usage: 12B
   Time elapsed: 0:00:02.1

TEST END: /home/daq/anaconda3/conda-bld/linux-64/gpib-1.0-py37_1.tar.bz2

Leaving build/test directories:
  Work:
 /home/daq/anaconda3/conda-bld/bdist_conda_1553636348287/work 
  Test:
 /home/daq/anaconda3/conda-bld/bdist_conda_1553636348287/test_tmp 
Leaving build/test environments:
  Test:
source activate  /home/daq/anaconda3/conda-bld/bdist_conda_1553636348287/_test_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold 
  Build:
source activate  /home/daq/anaconda3/conda-bld/bdist_conda_1553636348287/_build_env 

# If you want to upload this package to anaconda.org later, type:
#
# $ anaconda upload /home/daq/anaconda3/conda-bld/linux-64/gpib-1.0-py37_1.tar.bz2
jondoesntgit commented 5 years ago
$ conda install /home/daq/anaconda3/conda-bld/linux-64/gpib-1.0-py37_1.tar.bz2 

Preparing transaction: done
Verifying transaction: done
Executing transaction: done

$ python
Python 3.7.1 (default, Dec 14 2018, 19:28:38) 
[GCC 7.3.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import gpib
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'gpib'
vddvss commented 5 years ago

Does import Gpib work?

jondoesntgit commented 5 years ago

No. However, this works:

>>> import sys
>>> sys.path.append('/home/daq/anaconda3/envs/development/lib/python3.7/site-packages')
>>> import gpib
>>> import Gpib
jondoesntgit commented 5 years ago

Thanks for your heroic support in this!

vddvss commented 5 years ago

Sure thing. I imagine the sys.path.append thing is something to do with how conda loads libraries...

jondoesntgit commented 5 years ago

It’s how Python finds libraries in general.