Giter Club home page Giter Club logo

Comments (14)

toy avatar toy commented on June 12, 2024

The idea of this gem is to make nearly all binaries required for image_optim available without compiling anything as otherwise it is possible to compile everything manually (instructions for some platforms in image_optim#README).

Do you suggest it for making binaries available on more platforms or for other reasons?

from image_optim_pack.

ignisf avatar ignisf commented on June 12, 2024

Do you suggest it for making binaries available on more platforms or for other reasons?

The benefits would be the following:

  1. One could download a source distribution that can be compiled on the system if one wishes to or if there is no binary gem version for her platform.
  2. There won't be any need to have any logic that does architecture detection on runtime, as rubygems will handle this on install of the gem.

As a side note, I'm scratching my own itch here: https://github.com/ignisf/crunch https://github.com/ignisf/image_compressor_pack but just wanted to bring it up to your attention.

from image_optim_pack.

toy avatar toy commented on June 12, 2024
  1. One can checkout image_optim_pack and run make download
  2. This should not be a problem for platforms on which image_optim_pack will work, the bigger issue is that for those platforms there is a need to download much more than needed, but I will try an idea how to fix this

from image_optim_pack.

ignisf avatar ignisf commented on June 12, 2024

OK, I now have all the tools except pngout which does not seem to be open-source and svgo. I consider my issue resolved

from image_optim_pack.

toy avatar toy commented on June 12, 2024

I've tried crunch on a fresh ubuntu64, interesting, but it still requires to install nasm, lippng-dev and libjpeg*-dev

from image_optim_pack.

ignisf avatar ignisf commented on June 12, 2024

Yes. (I've added this to the README, thanks for reminding me). That's not unlike Nokogiri's deps on libxml2-dev and libxslt-dev, however those can be easily added to the gem itself in order to have 0 external dependencies.

from image_optim_pack.

aried3r avatar aried3r commented on June 12, 2024

I'd love to have an official option to compile from source for image_optim_pack. It seems to have more visibility than crunch at this point and maintaining one repo seems easier.

Of course I can't speak for @ignisf, but he seems interested enough that he'd at least send PRs? Just a thought, I don't want to force anyone to do anything here. :)

from image_optim_pack.

ignisf avatar ignisf commented on June 12, 2024

If there's will to distribute a source version of image_optim_pack, I'd probably find some time to assist if needed.

@aried3r, keep in mind that I've chosen not to publish ignisf/crunch ignisf/image_compressor_pack to rubygems as I don't consider it to be well enough written to be distributed. It's purpose at this point is to scratch a single itch I have in a single project. I could be persuaded to work a bit more on it if I see there's demand but I'd much rather see image_optim_pack get a source-only distribution instead of releasing yet another gem in the wild.

from image_optim_pack.

toy avatar toy commented on June 12, 2024

Could you please describe your idea in a more detail? Should it be a gem which downloads and compiles everything during installation like gpgme or something more like passenger? Should it contain sources or only urls? …

from image_optim_pack.

ignisf avatar ignisf commented on June 12, 2024

Hey, so I'll use https://rubygems.org/gems/libv8/versions as an example. If you're unfamiliar, v8 is a large library with a nasty build system. Its build takes about 20 minutes if you're lucky and aren't running an underpowered ARM device. The libv8 gem packages this library.

First of all, notice how there are binary versions of the gem for each supported platform and a source version for the platforms that there's no binary for.

Whenever you install a source version (https://rubygems.org/gems/libv8/versions/5.0.71.48.3 for example), ext/libv8/extconf.rb gets executed which pulls V8's source and compiles it.

Whenever you install a binary version, which rubygems does by default if there's a binary for the current platform (see for example https://rubygems.org/gems/libv8/versions/5.0.71.48.3-x86_64-linux) nothing is compiled. This version of the gem contains only the necessary binaries and no extconf.rb.

The way this is done with the libv8 gem is via two rake tasks:

  • rake build compress the gem source and produces a plain source version from the libv8.gemspec (the default behaviour of this task)
  • rake binary first compiles everything, then cherry-picks which files are needed for the binary version and replaces the file listing in the gemspec, and sets the platform for which the gem is meant, before producing a binary version of the gem (see https://github.com/cowboyd/libv8/blob/master/Rakefile#L26-L51).

You could take a look inside the .gem files themselves if I didn't manage to explain well enough.

I was planning to implement a proper rake binary task for crunch image_compressor_pack the other day but got stuck on having all ports produce statically-linked binaries which I wanted to have before stuffing them in an archive to be run on various distros.

from image_optim_pack.

ignisf avatar ignisf commented on June 12, 2024

As a side note, V8 needs additional arch detection (on top of the one of rubygems) which I expect won't be necessary in this case.

Also, introducing a dependency on mini_portile2 might not be necessary (and in fact, might be a bad idea) if you have already automated the download and compilation (I only took a quick look at the Makefile). The only benefit of it might be the source archive checksum verification.

from image_optim_pack.

ignisf avatar ignisf commented on June 12, 2024

Basically the issues one would meet with compiling from source are as you mentioned, the dependencies on libpng-dev, libjpeg-dev, zlib and nasm. With the latest few commits in crunch image_compressor_pack I wanted to make the build self-sufficient and dependent only on the standard library and I also wanted to have the build produce statically-linked executables.

I couldn't quite manage to eliminate the deps yet because of pngquant's ad-hoc build script. I have to rework its "library detection" functions to actually use the paths from the proper environment variables instead of doing ... whatever it is they are doing now. The developer seems keen on not using autotools for it and I try not to go crazy with patches.

I haven't started looking at what needs to happen to have the builds produce static executables (and as a matter of fact I'm not sure if it's really necessary if all their deps are available in the binary gem).

from image_optim_pack.

toy avatar toy commented on June 12, 2024

I wanted to have per platform gems in the beginning of creating this gem, but I've found some problems with handling platforms specific gems at that time.
Also I was not sure how to handle jruby, as current solution will work for it, but if using per platform gems, even when on a supported platform, only ruby and jruby platform specific gems will be chosen. Maybe putting all binaries in jruby platform gem can work.
Another also related to jruby problem can be caused by bundler as it doesn't allow to choose which platform specific gem to use.

When checking today, rubygems seemed to work fine with platform specific gems, but problems with jruby and bundler remain, still it may be worth a try. I'll see how to go with this, as there are few things to do with the gem: cleaning up scripts/make tasks, maybe switching to rake (still not sure).
Also related – there was a PR about adding docker image.

from image_optim_pack.

ignisf avatar ignisf commented on June 12, 2024

Just FYI, crunch's image_compressor_pack's build should now have no external library dependencies and binary gems can be produced with the rake binary task.

from image_optim_pack.

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.