How to convert cythonized file to exe in ubuntu

54 Views Asked by At

am having trouble converting my cythonized file to exe in ubuntu.I have created a pyx file converted it to c using cython in ubuntu. here is my setup.py file code


setup.py

from distutils.core import setup

from Cython.Build import cythonize

setup(

    ext_modules=cythonize("qrawler.pyx")

)

Here is my qrawler.pyx file

qrawler.pyx 

from selenium import webdriver

from selenium.webdriver.common.keys import Keys

from selenium.webdriver.common.action_chains import ActionChains

from selenium.webdriver.common.by import By

from selenium.webdriver.support.ui import WebDriverWait

from selenium.webdriver.support import expected_conditions as EC

from webdriver_manager.chrome import ChromeType, ChromeDriverManager

from selenium.webdriver.chrome.options import Options

from selenium.webdriver.chrome.service import Service

from selenium.common.exceptions import WebDriverException, NoSuchElementException, NoSuchWindowException

import requests

import os

import colorama

from datetime import datetime,timedelta, date

from colorama import Fore, Back

import time

import threading

import platform

import random

from art import *

import requests

from packaging import version

import firebase_admin

from firebase_admin import credentials

import time

from firebase_admin import firestore

import calendar

from google.cloud.firestore_v1.base_query import FieldFilter

#init colorama

colorama.init(autoreset=True)

# Initialize Firebase Admin SDK

try:

    cred = credentials.Certificate(service_account)

    firebase_admin.initialize_app(cred, {'storageBucket': bucket_name})

except Exception as e:

    raise

    

class Qrawler:

    def __init__(self):

        self.retry_attempts=10

        self.attempt=1

        self.delay=1

        self.retry_delay = 2


        # Clear the CMD screen

        os.system('cls' if os.name == 'nt' else 'clear')

        print()

        text = text2art(" QRAWLER")

        print(text)

        print(f" DEVELOPED BY {Back.GREEN} DEVME TECHNOLOGIES {Fore.RESET}")

        print("\n")

        print(f" {Fore.MAGENTA}[+]{self.get_timestamp()}->{Fore.RESET}{Fore.BLUE} {self.info()} Initializing qrawler...{Fore.RESET}\n")

        print(f" {Fore.MAGENTA}[+]{self.get_timestamp()}->{Fore.RESET}{Fore.BLUE} {self.info()} Checking internet connectivity...\n")


    def info(self):

        return '\u2139'

    def error(self):

        return '\u274C'

    def success(self):

        return '\u2714'

    def warning(self):

        return '\u26A0'

   

    def get_timestamp(self):

        return datetime.now().strftime('%H:%M:%S')

    

          

    #start keyboard listener

    def start_keyboard_listener(self):

       #start keyboard

        

        

    

    def keyboard_listener(self):

        ##listen keyboard

    

    

    def check_internet_connection(self):

       ##check internet

        

    

    def quit_driver(self, close_chrome=True):

       ##quit driver

   
    

    def get_greeting(self):

        currentTime = datetime.now()

        currentTime.hour

        if currentTime.hour < 12:

            return 'Good morning'

        elif 12 <= currentTime.hour < 18:

            return 'Good afternoon'

        else:

            return 'Good evening'

       

       

    def get_credentials(self,url):

        ##get credentials

     

    

    def get_todays_date(self):

        return date.today()

    

    def init_user(self):

        ##init user

                

          

    

              

    def can_terminate(self):

        # Select the "users" collection and query for the document with ID 1234

        ##terminate user

        

    

    def open_chrome(self):

       ##open chrome

      


      

    def login(self):

       ##login

            

    def update_user_status(self, status):

        # Assuming you have a reference to the users collection

        user_ref = self.db.collection('users').document(self.userId)

        # Update the status field with the provided status

        user_ref.update({'SoftwareStatus': status})

        

        

                    

    def run_operations(self):

        self.start_keyboard_listener()

       

           

qrawler=Qrawler()

qrawler.run_operations
()

After running cython --embed -o qrawler.c qrawler.pyx it generated qrawler.c file and qrawler.cpython-310-x86_64-linux-gnu.so .Am using ubuntu and wsl in windows 10,but when trying now to convert it to qrawler.exe using x86_64-w64-mingw32-gcc -o qrawler.exe qrawler.c $(python3-config --cflags --ldflags) command it gave the following error:

(venv) kevykibbz@DESKTOP-PCVIH53:/mnt/d/kevy/web/bots/testing$ x86_64-w64-mingw32-gcc -o qrawler.exe qrawler.c $(python3-config --cflags --ldflags)
In file included from /usr/include/python3.10/Python.h:8,
                 from qrawler.c:16:
/usr/include/python3.10/pyconfig.h:106:3: error: #error unknown multiarch location for pyconfig.h
  106 | # error unknown multiarch location for pyconfig.h
      |   ^~~~~
In file included from /usr/include/python3.10/pyport.h:4,
                 from /usr/include/python3.10/Python.h:50,
                 from qrawler.c:16:
/usr/include/python3.10/pyconfig.h:106:3: error: #error unknown multiarch location for pyconfig.h
  106 | # error unknown multiarch location for pyconfig.h
      |   ^~~~~
In file included from /usr/include/python3.10/pymath.h:4,
                 from /usr/include/python3.10/Python.h:71,
                 from qrawler.c:16:
/usr/include/python3.10/pyconfig.h:106:3: error: #error unknown multiarch location for pyconfig.h
  106 | # error unknown multiarch location for pyconfig.h
      |   ^~~~~
In file included from /usr/include/python3.10/Python.h:83,
                 from qrawler.c:16:
/usr/include/python3.10/unicodeobject.h:68:2: error: #error Must define SIZEOF_WCHAR_T
   68 | #error Must define SIZEOF_WCHAR_T
      |  ^~~~~
In file included from /usr/include/python3.10/fileutils.h:19,
                 from /usr/include/python3.10/Python.h:144,
                 from qrawler.c:16:
/usr/include/python3.10/cpython/fileutils.h:74:27: warning: ‘struct stat’ declared inside parameter list will not be visible outside of this definition or declaration
   74 | #  define _Py_stat_struct stat
      |                           ^~~~
/usr/include/python3.10/cpython/fileutils.h:79:12: note: in expansion of macro ‘_Py_stat_struct’
   79 |     struct _Py_stat_struct *status);
      |            ^~~~~~~~~~~~~~~
/usr/include/python3.10/cpython/fileutils.h:74:27: warning: ‘struct stat’ declared inside parameter list will not be visible outside of this definition or declaration
   74 | #  define _Py_stat_struct stat
      |                           ^~~~
/usr/include/python3.10/cpython/fileutils.h:83:12: note: in expansion of macro ‘_Py_stat_struct’
   83 |     struct _Py_stat_struct *status);
      |            ^~~~~~~~~~~~~~~
/usr/include/python3.10/cpython/fileutils.h:87:12: warning: ‘struct stat’ declared inside parameter list will not be visible outside of this definition or declaration
   87 |     struct stat *status);
      |            ^~~~
(venv) kevykibbz@DESKTOP-PCVIH53:/mnt/d/kevy/web/bots/testing$

Please help with a way to overcome this problem .My main goal is to convert qrawler.py to qrawler.exe using cython and gcc mingw64 in ubuntu.Am trying creating a distributable qrawler.exe for users from qrawler.py file in ubuntu.

0

There are 0 best solutions below