Jarus
Jarus

Reputation: 62

mypyc not compiling file

I have a project which does not give any checking errors with mypy (Command used: mypy --strict --check-untyped-defs). I have run the file using python3 and it seems to work fine. The project is typed in most parts. When I run mypyc I end up with a "No such file" error. I am a little lost here. I have tried mypyc with smaller projects and it seemed to work fine. I am not sure what is wrong here any help would be great!

Most of the project is typed. The only few lines that is not typed is:

from skimage import io # type: ignore
# Snip
def get_image_vector(name: str) -> npt.NDArray[np.float64]:
    return io.imread(os.path.join("32k/", name), as_gray=True).flatten() # type: ignore

The output of mypyc is as below:

(myenv) [suraj@inspiron3505 Typed]$ mypyc helper_experiments.py 
running build_ext
building 'Typed.helper_experiments__mypyc' extension
creating build/temp.linux-x86_64-cpython-311
creating build/temp.linux-x86_64-cpython-311/build
creating build/temp.linux-x86_64-cpython-311/build/Typed
gcc -DNDEBUG -g -fwrapv -O3 -Wall -march=x86-64 -mtune=generic -O3 -pipe -fno-plt -fexceptions -Wp,-D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security -fstack-clash-protection -fcf-protection -g -ffile-prefix-map=/build/python/src=/usr/src/debug/python -flto=auto -ffat-lto-objects -march=x86-64 -mtune=generic -O3 -pipe -fno-plt -fexceptions -Wp,-D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security -fstack-clash-protection -fcf-protection -g -ffile-prefix-map=/build/python/src=/usr/src/debug/python -flto=auto -march=x86-64 -mtune=generic -O3 -pipe -fno-plt -fexceptions -Wp,-D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security -fstack-clash-protection -fcf-protection -g -ffile-prefix-map=/build/python/src=/usr/src/debug/python -flto=auto -fPIC -I/home/suraj/Code/metric_space/myenv/lib/python3.11/site-packages/mypyc/lib-rt -Ibuild -I/home/suraj/Code/metric_space/myenv/include -I/usr/include/python3.11 -c build/Typed/__native_helper_experiments.c -o build/temp.linux-x86_64-cpython-311/build/Typed/__native_helper_experiments.o -O3 -g1 -Werror -Wno-unused-function -Wno-unused-label -Wno-unreachable-code -Wno-unused-variable -Wno-unused-command-line-argument -Wno-unknown-warning-option -Wno-unused-but-set-variable -Wno-ignored-optimization-argument -Wno-cpp
creating build/lib.linux-x86_64-cpython-311
creating build/lib.linux-x86_64-cpython-311/Typed
gcc -shared -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now -flto=auto -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now -flto=auto build/temp.linux-x86_64-cpython-311/build/Typed/__native_helper_experiments.o -L/usr/lib -o build/lib.linux-x86_64-cpython-311/Typed/helper_experiments__mypyc.cpython-311-x86_64-linux-gnu.so
building 'Typed.helper_experiments' extension
gcc -DNDEBUG -g -fwrapv -O3 -Wall -march=x86-64 -mtune=generic -O3 -pipe -fno-plt -fexceptions -Wp,-D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security -fstack-clash-protection -fcf-protection -g -ffile-prefix-map=/build/python/src=/usr/src/debug/python -flto=auto -ffat-lto-objects -march=x86-64 -mtune=generic -O3 -pipe -fno-plt -fexceptions -Wp,-D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security -fstack-clash-protection -fcf-protection -g -ffile-prefix-map=/build/python/src=/usr/src/debug/python -flto=auto -march=x86-64 -mtune=generic -O3 -pipe -fno-plt -fexceptions -Wp,-D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security -fstack-clash-protection -fcf-protection -g -ffile-prefix-map=/build/python/src=/usr/src/debug/python -flto=auto -fPIC -I/home/suraj/Code/metric_space/myenv/include -I/usr/include/python3.11 -c build/Typed/helper_experiments.c -o build/temp.linux-x86_64-cpython-311/build/Typed/helper_experiments.o -O3 -g1 -Werror -Wno-unused-function -Wno-unused-label -Wno-unreachable-code -Wno-unused-variable -Wno-unused-command-line-argument -Wno-unknown-warning-option -Wno-unused-but-set-variable -Wno-ignored-optimization-argument -Wno-cpp
gcc -shared -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now -flto=auto -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now -flto=auto build/temp.linux-x86_64-cpython-311/build/Typed/helper_experiments.o -L/usr/lib -o build/lib.linux-x86_64-cpython-311/Typed/helper_experiments.cpython-311-x86_64-linux-gnu.so
copying build/lib.linux-x86_64-cpython-311/Typed/helper_experiments__mypyc.cpython-311-x86_64-linux-gnu.so -> Typed
error: could not create 'Typed/helper_experiments__mypyc.cpython-311-x86_64-linux-gnu.so': No such file or directory

The folder structure of the project is as below:

.
├── abstract_oracle.py
├── algorithms_with_plug_in
│   ├── clarans_with_plug_in.py
│   ├── __init__.py
│   ├── knn_rp_with_plug_in.py
│   ├── kruskal_with_plug_in_new.py
│   ├── kruskal_with_plug_in.py
│   ├── pam_with_plug_in.py
│   ├── prims_with_plug_in.py
│   └── __pycache__
│       ├── clarans_with_plug_in.cpython-311.pyc
│       ├── __init__.cpython-311.pyc
│       ├── knn_rp_with_plug_in.cpython-311.pyc
│       ├── kruskal_with_plug_in_new.cpython-311.pyc
│       ├── pam_with_plug_in.cpython-311.pyc
│       └── prims_with_plug_in.cpython-311.pyc
├── config.py
├── dataset
│   ├── flicker.py
│   ├── __init__.py
│   ├── __pycache__
│   │   ├── flicker.cpython-311.pyc
│   │   ├── __init__.cpython-311.pyc
│   │   └── SFparser.cpython-311.pyc
│   └── SFparser.py
├── dummy.txt
├── helper_experiments.py
├── __init__.py
├── oracles
│   ├── dijkstra.py
│   ├── DSS.py
│   ├── __init__.py
│   ├── IntersectTriSearch.py
│   ├── LAESA.py
│   ├── oracle_helper.py
│   ├── __pycache__
│   │   ├── dijkstra.cpython-311.pyc
│   │   ├── DSS.cpython-311.pyc
│   │   ├── __init__.cpython-311.pyc
│   │   ├── IntersectTriSearch.cpython-311.pyc
│   │   ├── LAESA.cpython-311.pyc
│   │   ├── oracle_helper.cpython-311.pyc
│   │   └── TLAESA.cpython-311.pyc
│   └── TLAESA.py
├── __pycache__
│   ├── abstract_oracle.cpython-311.pyc
│   └── __init__.cpython-311.pyc
└── vanila_algorithms
    ├── clarans.py
    ├── __init__.py
    ├── knn_rp.py
    ├── kruskals.py
    ├── pam.py
    ├── prims.py
    └── __pycache__
        ├── clarans.cpython-311.pyc
        ├── __init__.cpython-311.pyc
        ├── knn_rp.cpython-311.pyc
        ├── kruskals.cpython-311.pyc
        ├── pam.cpython-311.pyc
        └── prims.cpython-311.pyc

In the helper file to handle a few imports I have code of this sort:

import sys
import os

SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
sys.path.append(os.path.dirname(SCRIPT_DIR))

I have tried compiling and running with normal python and it seems to work. This is the first big scale mypyc project that I am trying so I am a little lost here. With smaller projects I did not face similar issues. Any help or inputs here is great.

Upvotes: 1

Views: 494

Answers (0)

Related Questions