Python Forum
How to Translate a python code written in Mac-OS to Windows? - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: How to Translate a python code written in Mac-OS to Windows? (/thread-34436.html)



How to Translate a python code written in Mac-OS to Windows? - alexanderDennisEnviro500 - Jul-31-2021

The code was written last year by a former colleague, and as it only works on Mac, I have to convert it to Windows.

The Python code will serve as a Bluetooth scanner searching for a device and retrieving data from the device.

I noticed one of the imported libraries is "objc".

What is the Windows equivalent of ObjC?

#!/usr/bin/env python
# -*- coding: UTF-8 -*-
import threading
import time
import os  #for Decrypt
[color=#9B59B6]import objc[/color]
from struct import *
import codecs
import numpy as np
import binascii
# my define function
Sorry, the rest of the code is intellectual property, so I cannot share the remaining.


RE: How to Translate a python code written in Mac-OS to Windows? - ndc85430 - Jul-31-2021

You need to say what you're using the library for, because perhaps there are Windows-specific (or cross-platform) libraries that do similar things for the parts you're using. I can't say I know anything about Objective-C or Cocoa.

One thing you'll want to do, if you haven't already is to hide away the uses of this library behind your own abstractions (i.e. classes or function as appropriate), so that the rest of the code only depends on those abstractions. That will allow you to swap out one implementation for another. Perhaps some design patterns like bridge or adapter might also be useful to you.


RE: How to Translate a python code written in Mac-OS to Windows? - Gribouillis - Jul-31-2021

The introduction of PyObjc, the project containing the objc module goes as follows
Quote:The PyObjC project aims to provide a bridge between the Python and Objective-C programming languages on macOS. The bridge is intended to be fully bidirectional, allowing the Python programmer to take full advantage of the power provided by various Objective-C based toolkits and the Objective-C programmer transparent access to Python based functionality.

PyObjC not only includes the basic bridge, but also bindings to most Apple frameworks on macOS.

The most important usage of this is writing Cocoa GUI applications on macOS in pure Python. See our tutorial for an example of this.
With this description of the project, we can assume that it is almost impossible to run the program in a Windows environment.

If however the objc module is used only for the GUI part of the program, you could perhaps rewrite only the GUI part with another GUI framework or even write a console based program with similar functionalities.