vatlab / varianttools

software tool for the manipulation, annotation, selection, and analysis of variants in the context of next-gen sequencing analysis
https://vatlab.github.io/vat-docs/
GNU General Public License v3.0
31 stars 4 forks source link

Cannot be built with Python 3.9 #154

Closed rekado closed 1 year ago

rekado commented 2 years ago

Python 3.9 removed the deprecated field tp_print, which means that the sqlite part of varianttools can no longer be built with Python 3.

Here's an excerpt from the build log:

running build_ext
building 'variant_tools._vt_sqlite3' extension
creating build/temp.linux-x86_64-3.9
creating build/temp.linux-x86_64-3.9/src
creating build/temp.linux-x86_64-3.9/src/sqlite
creating build/temp.linux-x86_64-3.9/src/sqlite/py3
gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fno-semantic-interposition -fPIC -DMODULE_NAME="vt_sqlite3" -DHAVE_USLEEP -Isrc/sqlite -Isrc/sqlite/py3 -I/gnu/store/p5fgysbcnnp8b1d91mrvjvababmczga0-python-3.9.6/include/python3.9 -c src/sqlite/py3/cache.c -o build/temp.linux-x86_64-3.9/src/sqlite/py3/cache.o -w
gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fno-semantic-interposition -fPIC -DMODULE_NAME="vt_sqlite3" -DHAVE_USLEEP -Isrc/sqlite -Isrc/sqlite/py3 -I/gnu/store/p5fgysbcnnp8b1d91mrvjvababmczga0-python-3.9.6/include/python3.9 -c src/sqlite/py3/connection.c -o build/temp.linux-x86_64-3.9/src/sqlite/py3/connection.o -w
gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fno-semantic-interposition -fPIC -DMODULE_NAME="vt_sqlite3" -DHAVE_USLEEP -Isrc/sqlite -Isrc/sqlite/py3 -I/gnu/store/p5fgysbcnnp8b1d91mrvjvababmczga0-python-3.9.6/include/python3.9 -c src/sqlite/py3/cursor.c -o build/temp.linux-x86_64-3.9/src/sqlite/py3/cursor.o -w
gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fno-semantic-interposition -fPIC -DMODULE_NAME="vt_sqlite3" -DHAVE_USLEEP -Isrc/sqlite -Isrc/sqlite/py3 -I/gnu/store/p5fgysbcnnp8b1d91mrvjvababmczga0-python-3.9.6/include/python3.9 -c src/sqlite/py3/microprotocols.c -o build/temp.linux-x86_64-3.9/src/sqlite/py3/microprotocols.o -w
gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fno-semantic-interposition -fPIC -DMODULE_NAME="vt_sqlite3" -DHAVE_USLEEP -Isrc/sqlite -Isrc/sqlite/py3 -I/gnu/store/p5fgysbcnnp8b1d91mrvjvababmczga0-python-3.9.6/include/python3.9 -c src/sqlite/py3/module.c -o build/temp.linux-x86_64-3.9/src/sqlite/py3/module.o -w
gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fno-semantic-interposition -fPIC -DMODULE_NAME="vt_sqlite3" -DHAVE_USLEEP -Isrc/sqlite -Isrc/sqlite/py3 -I/gnu/store/p5fgysbcnnp8b1d91mrvjvababmczga0-python-3.9.6/include/python3.9 -c src/sqlite/py3/prepare_protocol.c -o build/temp.linux-x86_64-3.9/src/sqlite/py3/prepare_protocol.o -w
gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fno-semantic-interposition -fPIC -DMODULE_NAME="vt_sqlite3" -DHAVE_USLEEP -Isrc/sqlite -Isrc/sqlite/py3 -I/gnu/store/p5fgysbcnnp8b1d91mrvjvababmczga0-python-3.9.6/include/python3.9 -c src/sqlite/py3/row.c -o build/temp.linux-x86_64-3.9/src/sqlite/py3/row.o -w
src/sqlite/py3/row.c: In function ‘pysqlite_row_print’:
src/sqlite/py3/row.c:161:27: error: ‘PyTypeObject’ {aka ‘struct _typeobject’} has no member named ‘tp_print’
  161 |     return (&PyTuple_Type)->tp_print(self->data, fp, flags);
      |                           ^~
error: command '/gnu/store/vakvgvrb839igv16jkif4lmx11d25jqb-gcc-10.3.0/bin/gcc' failed with exit code 1
BoPeng commented 2 years ago

Thanks for your report and I will have a look as soon as I can.

rekado commented 2 years ago

Thank you. If you've got something you'd like me to test, please let me know.

BoPeng commented 2 years ago

@jenningsje I will let you handle this one. Basically, you will need to

  1. Install anaconda.
  2. I am not sure if python 3.9 is the default version of the Python interpreter, but you should create a conda environment for variant tools anyway, so please do
conda create --name vtools3.9 python=3.9
conda activate vtools3.9

This will create a conda environment with Python 3.9 as the Python interpreter.

  1. On your Mac, install xcode and its command line tools (goolge if needed)

  2. Clone this repository (git clone https://github.com/vatlab/varianttools)

  3. Try to reproduce the problem that the user reported.

  4. Install vs code if you have not, install Python plugin etc (learn to use vscode!)

  5. Locate the offending line of code in src/sqlite/py3/row.c, .

Wap the following line with

https://github.com/vatlab/varianttools/blob/de30e3ef1da424724abd96defbbcb67d211810ac/src/sqlite/py3/row.c#L169-L172

https://github.com/vatlab/varianttools/blob/de30e3ef1da424724abd96defbbcb67d211810ac/src/sqlite/py3/row.c#L220

with

#if PY_VERSION_HEX >= 0x03000000. <- Figure out how to specify version 3.6
0,
#else
(hashfunc)pysqlite_row_hash,
#endif <- cannot remember if it is end or endif. figure out.

You will wrap both pieces of code so that for Python version <= 3.6, we keep the original implementation, for Python version > 3.6, we assign 0 to that field, and we also do not define function pysqlite_row_hash.

  1. Re-compile and see if you can install variant tools for Python 3.9

  2. Create a branch called issue154 using git co -b issue154

  3. Commit and push the changes (figure out how to do this by yourself)

  4. Create a pull request and assign me (@BoPeng ) as reviewer.

BoPeng commented 2 years ago

@jenningsje https://github.com/vatlab/varianttools/commit/7f4f5fcc71c5f48f341255794ed4bc5d878cfc2c is clearly wrong with 400+ affected files.