ueno / ruby-gpgme

a ruby interface to GnuPG Made Easy (GPGME).
GNU Lesser General Public License v2.1
232 stars 99 forks source link

Huge Installation Footprint #188

Closed ksylvest closed 2 months ago

ksylvest commented 5 months ago

The install size for gpgme-2.0.24 is ~45 MB. This seems pretty huge! A quick spot check:

gem install gpgme
cd $(bundle show gpgme)
du -hs * | sort -h
 24K    examples
 92K    test
800K    lib
7.1M    ports
 38M    ext
du -hs ext/gpgme/* | sort -h
8.0K    ext/gpgme/extconf.rb
 12K    ext/gpgme/Makefile
104K    ext/gpgme/gpgme_n.c
 38M    ext/gpgme/tmp

A few questions / thoughts:

  1. Do the test / examples need to be included in the gemspec files?
  2. The ext/gpgme/tmp folder is part of the bundle and fairly huge (38M) - is it required or just build artifacts?
  3. What is the purpose of the ports exactly (can they also be excluded from the finalized version)?

If this does seem like an issue happy to help opening a PR to address.

kernelsmith commented 2 months ago

@stanhu you might be able to weigh in here. I would think that anything other than maybe a .gitkeep could be gitignored in /tmp?

stanhu commented 2 months ago

@kernelsmith I think that tmp directory can be removed, but I don't think a .gitkeep would do anything here because that temporary directory is created by the Rakefile: https://github.com/ueno/ruby-gpgme/blob/bae97e203246054b9eba69a1b6470a4dcb2e8d21/Rakefile#L11-L16

Do the test / examples need to be included in the gemspec files?

I think they can be excluded, though sometimes it's useful to have the tests to verify the C extension built and installed correctly.

What is the purpose of the ports exactly (can they also be excluded from the finalized version)?

I believe that directory is used to download and build gpgme, libassuan, etc. I believe they can be removed.

I spent a long time working on building precompiled gems and ensuring the gems had a minimal footprint in https://github.com/mudge/re2. We can probably borrow the same ideas from there.

kernelsmith commented 2 months ago

We could make the tmp directory ahead of time and stick a .gitkeep in there and then gitignore the rest of the contents. When rake runs, I assume it won't fail if the dir already exists (depends how mkdir is defined obviously). However, in this case we can just gitignore the entire /tmp so let's just do that ;)

stanhu commented 2 months ago

gpgme v2.0.23 had an issue with cleanup, but I believe this has been fixed in v2.0.24 via #178 and #179:

gem install gpgme -v 2.0.24
cd `dirname $(gem which gpgme)`
cd ..
du -h
 28K    ./test/support
 12K    ./test/files
 96K    ./test
124K    ./ext/gpgme
124K    ./ext
 24K    ./examples
108K    ./lib/gpgme
876K    ./lib
1.1M    .

@ueno I think we can close this issue?

I raised https://github.com/rubygems/rubygems/issues/6956 to discuss how to standardize cleanup, but for now the roundabout way does the job: https://github.com/ueno/ruby-gpgme/blob/bae97e203246054b9eba69a1b6470a4dcb2e8d21/ext/gpgme/extconf.rb#L228