Giter Club home page Giter Club logo

pyarcus's Introduction

pyArcus

This library contains Python bindings, for libArcus, for creating a socket in a thread and using this socket to send and receive messages based on the Protocol Buffers library. It is designed to facilitate the communication between Cura and its backend and similar code.

License

License
pyArcus is released under terms of the LGPLv3 License. Terms of the license can be found in the LICENSE file. Or at http://www.gnu.org/licenses/lgpl.html

But in general it boils down to:
You need to share the source of any pyArcus modifications if you make an application with pyArcus.

System Requirements

Windows

  • Python 3.6 or higher
  • Ninja 1.10 or higher
  • VS2022 or higher
  • CMake 3.23 or higher
  • nmake
  • sip 6.5.0 or higher
  • Conan 1.56.0

MacOs

  • Python 3.6 or higher
  • Ninja 1.10 or higher
  • apply clang 11 or higher
  • CMake 3.23 or higher
  • make
  • sip 6.5.0 or higher
  • Conan 1.56.0

Linux

  • Python 3.6 or higher
  • Ninja 1.10 or higher
  • gcc 12 or higher
  • CMake 3.23 or higher
  • make
  • sip 6.5.0 or higher
  • Conan 1.56.0

How To Build

Note:
We are currently in the process of switch our builds and pipelines to an approach which uses Conan and pip to manage our dependencies, which are stored on our JFrog Artifactory server and in the pypi.org. At the moment not everything is fully ported yet, so bare with us.

If you want to develop Cura with pyArcus see the Cura Wiki: Running Cura from source

If you have never used Conan read their documentation which is quite extensive and well maintained. Conan is a Python program and can be installed using pip

1. Configure Conan

pip install conan==1.56
conan config install https://github.com/ultimaker/conan-config.git
conan profile new default --detect --force

Community developers would have to remove the Conan cura repository because it requires credentials.

Ultimaker developers need to request an account for our JFrog Artifactory server at IT

conan remote remove cura

2. Clone pyArcus

git clone https://github.com/Ultimaker/pyArcus.git
cd pyArcus

3. Install & Build pyArcus (Release OR Debug)

Release

conan install . --build=missing --update
# optional for a specific version: conan install . pyarcus/<version>@<user>/<channel> --build=missing --update
conan build .
# or
sip-install

Debug

conan install . --build=missing --update build_type=Debug
conan build .
# or
sip-install

Creating a new pyArcus Conan package

To create a new pyArcus Conan package such that it can be used in Cura and Uranium, run the following command:

conan create . pyarcus/<version>@<username>/<channel> --build=missing --update

This package will be stored in the local Conan cache (~/.conan/data or C:\Users\username\.conan\data ) and can be used in downstream projects, such as Cura and Uranium by adding it as a requirement in the conanfile.py or in conandata.yml.

Note: Make sure that the used <version> is present in the conandata.yml in the pyArcus root

You can also specify the override at the commandline, to use the newly created package, when you execute the conan install command in the root of the consuming project, with:

conan install . -build=missing --update --require-override=pyarcus/<version>@<username>/<channel>

Developing pyArcus In Editable Mode

You can use your local development repository downsteam by adding it as an editable mode package. This means you can test this in a consuming project without creating a new package for this project every time.

    conan editable add . pyArcus/<version>@<username>/<channel>

Then in your downsteam projects (Cura) root directory override the package with your editable mode package.

conan install . -build=missing --update --require-override=pyarcus/<version>@<username>/<channel>

pyArcus python module

This repository contains a Python module named pyArcus. To build it sip 6.5.1 needs to be used to generate the C/C++ source code. We created a build tool for this called sipbuildtool which is automatically installed when you run the conan install command. This will set up a temporary virtual Python environment, install sip and generated the C/C++ source code. The virtual Python environment is then removed. Downside of this method is that Conan should be installed with the system Python, not the virtual Python environment.

usage

import pyArcus
socket = pyArcus.Socket()

Using the Socket

The socket assumes a very simple and strict wire protocol: one 32-bit integer with a header, one 32-bit integer with the message size, one 32-bit integer with a type id then a byte array containing the message as serialized by Protobuf. The receiving side checks for these fields and will deserialize the message, after which it can be processed by the application.

To send or receive messages, the message first needs to be registered on both sides with a call to registerMessageType(). You can also register all messages from a Protobuf .proto file with a call to registerAllMessageTypes(). For the Python bindings, this is the only supported way of registering since there are no Python classses for individual message types.

The Python bindings expose the same API as the Public C++ API, except for the missing registerMessageType() and the individual messages. The Python bindings wrap the messages in a class that exposes the message's properties as Python properties, and can thus be set the same way you would set any other Python property.

The exception is repeated fields. Currently, only repeated messages are supported, which can be created through the addRepeatedMessage() method. repeatedMessageCount() will return the number of repeated messages on an object and getRepeatedMessage() will get a certain instance of a repeated message. See python/PythonMessage.h for more details.

Origin of the Name

The name Arcus is from the Roman god Arcus. This god is the roman equivalent of the goddess Iris, who is the personification of the rainbow and the messenger of the gods.

Java

There is a Java port of pyArcus, which can be found here.

pyarcus's People

Contributors

casperlamboo avatar jellespijker avatar joeydelarago avatar nallath avatar rburema avatar wawanbreton avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Forkers

lulzbot3d

pyarcus's Issues

Installation Issues - Wrong Conan Version?

Hi, I am trying to set up pyArcus. I get an error message in step 3 of the “How to build” guide.


C:\…\pyArcus\pyArcus>conan install . --build=missing --update
Configuration (profile_host):
[settings]
arch=x86_64
arch_build=x86_64
build_type=Release
compiler=Visual Studio
compiler.cppstd=17
compiler.runtime=MD
compiler.version=17
os=Windows
os_build=Windows
curaengine:compiler.cppstd=20
curaengine*:compiler.cppstd=20
curaengine_plugin_infill_generate:compiler.cppstd=20
curaengine_plugin_gradual_flow:compiler.cppstd=20
curaengine_grpc_definitions:compiler.cppstd=20
scripta:compiler.cppstd=20
umspatial*:compiler.cppstd=20
dulcificum:compiler.cppstd=20
cura_settings:compiler.cppstd=20
[options]
[build_requires]
[env]
[conf]
tools.cmake.cmaketoolchain:generator=Ninja
tools.env.virtualenv:auto_use=True
tools.gnu:define_libcxx11_abi=True
tools.build:skip_test=False

Configuration (profile_build):
[settings]
arch=x86_64
arch_build=x86_64
build_type=Release
compiler=Visual Studio
compiler.cppstd=17
compiler.runtime=MD
compiler.version=17
os=Windows
os_build=Windows
[options]
[build_requires]
[env]
[conf]
tools.cmake.cmaketoolchain:generator=Ninja
tools.env.virtualenv:auto_use=True
tools.gnu:define_libcxx11_abi=True
tools.build:skip_test=False

ERROR: Error loading conanfile at 'C:\…\pyArcus\pyArcus\[[conanfile.py](http://conanfile.py/)](http://conanfile.py/)': Current Conan version (1.56.0) does not satisfy the defined one (>=1.58.0).


So it seems like i need at least conan 1.58.0 to do the installation properly. But this is weird, since conan 1.56 is a requirement for the installation. But anyway i tried it and at the same point I get now another error:


C:\…\pyArcus>conan install . --build=missing --update
Configuration (profile_host):
[settings]
arch=x86_64
arch_build=x86_64
build_type=Release
compiler=Visual Studio
compiler.cppstd=17
compiler.runtime=MD
compiler.version=17
os=Windows
os_build=Windows
curaengine:compiler.cppstd=20
curaengine*:compiler.cppstd=20
curaengine_plugin_infill_generate:compiler.cppstd=20
curaengine_plugin_gradual_flow:compiler.cppstd=20
curaengine_grpc_definitions:compiler.cppstd=20
scripta:compiler.cppstd=20
umspatial*:compiler.cppstd=20
dulcificum:compiler.cppstd=20
cura_settings:compiler.cppstd=20
[options]
[build_requires]
[env]
[conf]
tools.cmake.cmaketoolchain:generator=Ninja
tools.env.virtualenv:auto_use=True
tools.gnu:define_libcxx11_abi=True
tools.build:skip_test=False

Configuration (profile_build):
[settings]
arch=x86_64
arch_build=x86_64
build_type=Release
compiler=Visual Studio
compiler.cppstd=17
compiler.runtime=MD
compiler.version=17
os=Windows
os_build=Windows
[options]
[build_requires]
[env]
[conf]
tools.cmake.cmaketoolchain:generator=Ninja
tools.env.virtualenv:auto_use=True
tools.gnu:define_libcxx11_abi=True
tools.build:skip_test=False

ERROR: Error loading conanfile at 'C:\…\pyArcus\[[conanfile.py](http://conanfile.py/)](http://conanfile.py/)': Version range '>=0.1.7' from requirement 'pyprojecttoolchain/[>=0.1.7]@ultimaker/stable' required by 'py_require' could not be resolved in local cache

I am confused what exactly is going wrong there. Furthermore I don't have much practice in installing libraries in a way like it is described here.
I just opened a new folder, navigated to it via my terminal and startet to enter the commands. Beforehand I made sure to install all requirements:

I have installed:
Python 3.10.9
ninja 1.12.1
Visual Studio 2022 (nmake should be installed in there aswell (?) )
cmake 3.30.0
sip 6.5.0
conan 1.58 / 1.56

I am glad for every hint or advice i get!

error when running "sip-install"

macos13.2 sip 6.5.1 ,got such an error as following:

These bindings will be built: pyArcus.
Generating the pyArcus bindings...
Generating the pyArcus .pyi file...
Compiling the 'pyArcus' module...
error: invalid argument '-std=c++17' not allowed with 'C'
error: command '/usr/bin/clang' failed with exit code 1

how can I fix it ?

conan build complains about missing CMakePresets.json

Experiencing a cmake build error using:
cmake version 3.25.1
Conan version 1.57.0

The conan build step fails after looking for a CMakePresets.json.
I get a CMakeUserPresets.json generated in the root dir, which points to the path:

pyArcus/build/Release/generators/CMakePresets.json

but that CMakePresets.json isn't generated there (or anywhere I can find) at conan install .
As I understand the docs
this should be called in the generate method, but I'm not sure how to debug the conan install process.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.