Coder Social home page Coder Social logo

Comments (15)

mbarkhau avatar mbarkhau commented on July 28, 2024 2

Here's the package markdown-svgbob on pypi.

This library uses the "Solution 1" approach suggested by @tychota.

from svgbob.

yvt avatar yvt commented on July 28, 2024 2

FYI, in Foremark, I successfully took Solution 2 to render diagrams on web browsers (example). It works by compiling a facade crate (which is linked to Svgbob) into WebAssembly and hooking things up using wasm-bindgen. The compiled module weighs roughly 200 kilobytes.

When the host application runs in a JavaScript environment, it seems like the most seamless, streamlined option because WebAssembly is architecture/platform-independent and doesnโ€™t require IPC and subprocess management. It could be made into a single, standalone NPM package like they did with source-map and I did with hyper3d-envmapgen.

from svgbob.

mbarkhau avatar mbarkhau commented on July 28, 2024 1

Binaries are available here if anybody is brave enough to try:

https://gitlab.com/mbarkhau/markdown-svgbob/tree/master/src/markdown_svgbob/bin

from svgbob.

mbarkhau avatar mbarkhau commented on July 28, 2024

I'd like to do something similar and create an extension for Python Markdown, which would simply spawn svgbob in a subprocess.

I think the easiest thing to do would be to package the binaries together with the python distribution. If those were available to download for the various platforms then I could use those. Alternatively I might look into cross compilation.

In the meantime I'll just try and work with my local file ~/.cargo/bin/svgbob.

from svgbob.

mbarkhau avatar mbarkhau commented on July 28, 2024

I took a short look at cross compiling, but I'm really new to the rust ecosystem and feel like I'm wasting my time. If there are any Rustaceans out there who already know how to produce static binaries for these targets, I would greatly appreciate some pointers.

x86_64-apple-darwin
x86_64-pc-windows-gnu
x86_64-unknown-linux-gnu

from svgbob.

ivanceras avatar ivanceras commented on July 28, 2024

@mbarkhau I'm not sure how are you installing svgbob. Right now, you can easily install svgbob using cargo. If you are using a linux machine, the x86_64-unknown-linux-gnu target should not be a problem to compile to. I haven't done any cross compilation myself, but the simple way to do this is use a mac-osx to compile for x86_64-apple-darwin and compiling for windows can also be easily done in windows machine. I didn't include the binary release for each of the platform, since I don't have access to all of these machines as well, aside from the extra step in maintenance.

from svgbob.

mbarkhau avatar mbarkhau commented on July 28, 2024

@ivanceras I did cargo install svgbob_cli. Installing locally is not the problem, I'm just trying to find out where to get statically linked binaries for other platforms from, as I'm in a similar situation to you and only have access to a linux machine. I'd rather not impose on the users of a python library the requirement to have cargo installed on their machine.

from svgbob.

bjorn3 avatar bjorn3 commented on July 28, 2024

Apart from libc and possibly some other system libraries all executables created hy rustc don't link to any library. Because of this it is enough to copy executables to another machine to be able to run them. If you want to create a completely statically linked executable you can compile for x86_64-unknown-linux-musl. After cargo install you can find the executable in ~/.cargo/bin.

from svgbob.

mbarkhau avatar mbarkhau commented on July 28, 2024

all executables created hy rustc don't link to any library. Because of this it is enough to copy executables to another machine to be able to run them.

That's good to know.

from svgbob.

mbarkhau avatar mbarkhau commented on July 28, 2024

I was able to cross compile for windows at least.

I initially ran cross build --verbose which failed, but it seems that cross only invokes docker and I was able to modify the invocation so that the /svgbob directory was added as a volume, not just the /svgbob_cli.

$ cd svgbob/;
$ docker run --userns host \
    --rm \
    --user 1000:1000 \
    -e CARGO_HOME=/cargo \
    -e CARGO_TARGET_DIR=/target \
    -e USER=$USER \
    -e XARGO_HOME=/xargo \
    -v $HOME/.xargo:/xargo \
    -v $HOME/.cargo:/cargo \
    -v $PWD/svgbob:/svgbob:ro \
    -v $PWD/svgbob_cli:/svgbob_cli:ro \
    -v $HOME/.rustup/toolchains/stable-x86_64-unknown-linux-gnu:/rust:ro \
    -v $PWD/svgbob_cli/target:/target \
    -w /svgbob_cli \
    -it japaric/x86_64-pc-windows-gnu:v0.1.14 \
    sh -c 'PATH=$PATH:/rust/bin "cargo" "build" "--target" "x86_64-pc-windows-gnu" "--release" "--verbose"'

Output from wine

user@host:~/workspace/svgbob/svgbob_cli/target/x86_64-pc-windows-gnu/release (master)
$ ls
build  deps  examples  incremental  native  svgbob.d  svgbob.exe

user@host:~/workspace/svgbob/svgbob_cli/target/x86_64-pc-windows-gnu/release (master)
$ wine cmd.exe

Z:\home\user\workspace\svgbob\svgbob_cli\target\x86_64-pc-windows-gnu\release>svgbob.exe --help
svgbob 0.4.1
SvgBobRus is an ascii to svg converter

USAGE:
    svgbob.exe [FLAGS] [OPTIONS] [input] [SUBCOMMAND]

FLAGS:
    -h, --help       Prints help information
    -s               parse an inline string
    -V, --version    Prints version information

from svgbob.

mbarkhau avatar mbarkhau commented on July 28, 2024

I think I have a binary for x86_64-apple-darwin based on this tutorial but I don't have any way to test it myself.

At least superficially it seems to be the right stuff

$ file src/markdown_svgbob/bin/svgbob_0.4.1_x86_64-Darwin
src/markdown_svgbob/bin/svgbob_0.4.1_x86_64-Darwin: Mach-O 64-bit x86_64 executable, flags:<NOUNDEFS|DYLDLINK|TWOLEVEL|PIE|HAS_TLV_DESCRIPTORS>

from svgbob.

mbarkhau avatar mbarkhau commented on July 28, 2024

I was able to start a MacOS VM and indeed the Darwin binary appears to work.

from svgbob.

breml avatar breml commented on July 28, 2024

@mbarkhau thanks for the binary releases you provide in your repo.

@ivanceras It would be great and highly appreciated, if you could provide statically linked release binaries for the common platforms (e.g. linux, windows, macos).

from svgbob.

mbarkhau avatar mbarkhau commented on July 28, 2024

Since this issue was opened, I think the situation with GitHub actions has become much better. I'm sure a PR would be welcome.

from svgbob.

erasin avatar erasin commented on July 28, 2024

https://github.com/agoose77/svgbob-wasm has make wasm api for javascript, It can be embedded in any web page.

from svgbob.

Related Issues (20)

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.