rdiff python module - python

Is there a python module that has the functionality for computing rdiff signatures and delta differencing?
I need to perform these operations on a cross-platform application so I'll need something that will bundle into py2exe, py2app etc.
I've done a bunch of searching but I can't seem to get anything working. Pysync, rdiff-backup, librsync all come up but I've not been able to get anything working inside of python.

rdiff-backup is written in Python. It appears to be using librsync under the covers and has a Python wrapper for it (look for _librsyncmodule.c in the source tree).
The following page may help to figure out how to build librsync on OS X and Windows: link.

Related

How to find the functions in a source file for an added library to Python

I have recently installed Python and MetaTrader5 library, and I am trying to further understand how this library connects to the MetaTrader terminal and handles my requests. I am pretty new to programming in general and do not have much experience with viewing source code for external libraries.
As an example, there is a function mt5.account_info() that I would like to locate in the library source code yet all I have in my files is the __ init__ that contains only 4 functions that are not even listed when I run print(dir(mt5)). How do I go about finding the code for these functions that the MetaTrader5 library uses?
My overall goal is to be able to use the ObjectGetDouble function that isn't part of the Python integration and I am trying to see if I can add this function myself or if I need to do it in the MQL editor and export the data that way.
I have tried looking through the source code in the installed library folders but have not found the resources. I am not familliar with C++ so I haven't been able to write any MQL5 code in order to extract the ObjectGetDouble information.

Run Python Library as script

Some important background upfront, I am using a computer that does not give me access to pip. In fact I do not have access to the command prompt. This make is it impossible for me to install additional libraries unfortunately (at least the standard way).
My question is whether I can run a python library without formally installing it. Could I download the library, and then store it the same directory as my main script, and then import it like I would with a multi .py script project with functions being defined in other files, almost as if I had written the script natively on my computer?
Specifically, I would like to use pdfminer.six. Apparently it is written completely in python, however, I realize that may not mean what I think it does. It may be similar to numpy which I understand has C++ code associated with it.
You can import any script or lib from your current folder (example). You can find any lib you want by googling 'lib_name github'. Download the zip and unpack it in your folder, it should work.
You can also go to your python Lib folder on another computer and copy libs from there (By default: C:\Users\User\AppData\Local\Programs\Python\Python310\Lib)
Maybe you can use a web-based-interpreter solution like Google Colab and work in your browser.
https://colab.research.google.com

Fully embedded SymPy+Matplotlib+others within a C/C++ application

I've read the Python documentation chapter explaining how to embed the Python interpreter in a C/C++ application. Also, I've read that you can install Python modules either in a system-wide fashion, or locally to a given user.
But let's suppose my C/C++ application will use some Python modules such as SymPy, Matplotlib, and other related modules. And let's suppose end users of my application won't have any kind of Python installation in their machines.
This means that my application needs to ship with "pseudo-installed" modules, inside its data directories (just like the application has a folder for icons and other resources, it will need to have a directory for Python modules).
Another requirement is that the absolute path of my application installation isn't fixed: the user can "drag" the application bundle to another directory and it will run fine there (it already works this way but that's prior to embedding Python in it, and I wish it continues being this way after embedding Python).
I guess my question could be expressed more concisely as "how can I use Python without installing Python, neither system-wide, nor user-wide?"
There are various ways you could attempt to do this, but none of them are general solutions. From the (docs):
5.5. Embedding Python in C++
It is also possible to embed Python in a C++ program; precisely how this is done will depend on the details of the C++ system used; in general you will need to write the main program in C++, and use the C++ compiler to compile and link your program. There is no need to recompile Python itself using C++.
This is the shortest section in the document, and is roughly equivalent to: 'left as an exercise for the reader`. I do not believe you will find any straight forward solutions.
Use pyinstaller to gather the pieces:
This means that my application needs to ship with "pseudo-installed" modules, inside its data directories (just like the application has a folder for icons and other resources, it will need to have a directory for Python modules).
If I needed to tackle this problem, I would use pyinstaller as a base. (Disclosure: I am an occasional contributer). One of the major functions of pyinstaller is to gather up all of the needed resources for a python program. In onedir mode, all of the things needed to let the program run are gathered into one directory.
You could include this tool into your make system, and have it place all of the needed pieces into your python data directory in your build tree.

Python4Delphi-powered program, how to deploy it?

My Delphi program uses Python4Delphi, and the Python script uses some standard libs. When deploying my program I don't want an entire Python installation, and it must work with python27.dll. What are the minimal set of necessary files? The document in Python4Delphi is dated and it's not clear to me...
Thanks for your help.
When I did this, I made the list myself, of what I needed for my embedded python application to work.
I remember this worked with python15.dll:
PythonXX.dll should work, without any other external files other than the Visual C++ Runtime DLLs, which require a side-by-side manifest (see the p4d wiki page) to work.
If you want to IMPORT something, then you need to ship it and anything it depends on. That means, either you pick part of the python standard libraries you want, or you pick all of it. There is no way you need all of Python's standard libraries. But I wouldn't want to live without OS and a a few other key ones. BUt the decision is yours.

Distributing minimal python installation with application

My company is working on an application that is half Qt/C++ for the editor interface and half Django (via QtWebKit browser control) for the runtime. What we want to do is distribute a minimal python installation with our application.
For instance, our Mac app bundle would ideally be structured something like this:
TheApp.app/
Contents/
MacOS/
TheApp
Resources/
MinimalPythonInstallation/
On Windows:
C:\Program Files\TheApp\
TheApp.exe
MinimalPythonInstallation\
I've seen plenty of projects out there for distributing full Python applications such as py2app, py2exe, and PyInstaller. Those seem to have some of the features I'm looking for, but without the ability to just make a minimal python distribution. i.e. the python executable, Django, and the bare minimum of the python standard library needed by Django, our python code, etc.
Is there anything out there that can do what I'm looking for?
You can find the set of modules you need with modulefinder -- indeed, I believe that's a key part of what the systems you mention, like py2exe and PyInstaller, do for you, so I'm not clear why you want to "reinvent the wheel" -- care to clarify? Have you looked at exactly what e.g. PyInstaller puts in the executables it generates, and, if so, why isn't that good enough for you? If you explain this in detail, maybe there's some extra way we can help.
(PyInstaller is cross-platform, so, if you want to support Mac as well as Windows, it's probably the one you'll want, since py2exe is Windows-only).

Categories