Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jeweler should allow management of dependencies in Gemfiles by platform #170

Open
eedrummer opened this issue Feb 10, 2011 · 19 comments
Open
Assignees

Comments

@eedrummer
Copy link

Right now, Jeweler pulls in all dependencies from a Gemfile, regardless of platform dependency. It would be nice if there was a way to restrict the inclusion of dependencies based on their platforms.

@technicalpickles
Copy link
Owner

In general, jeweler just is wrapping gemspecs. As far as I understand it, gemspecs don't allow platform-specific dependencies, so it'd be kinda hard to do.

Just to make sure I understand what you mean, could you point me at an example please?

@eedrummer
Copy link
Author

An example would be this Gemfile:

https://github.com/eedrummer/quality-measure-engine/blob/develop/Gemfile

On line 5, I load the bson_ext gem, but only if running under MRI. Now Jeweler looks at this Gemfile and adds bson_ext as a dependency when building the gemspec. I would like to be able to tell Jeweler to ignore gems that have platform specific requirements (in this case, I want my gem to be able to run under both MRI and JRuby). So I would like to see a mechanism to deal with platform dependencies declared in the Gemfile and how they get added to the gemspec.

@technicalpickles
Copy link
Owner

While bundler has support for this, I'm pretty sure that rubygems itself does not. That is to say, there's no way to tell a gemspec:

gemspec.add_dependency 'cover_me', '>= 1.0.0.rc5', :platforms => :ruby_19

You could conditionally add this to the gemspec, but remember, this is a gemspec generated to eventually become a gem and eventually pushed to rubygems.org. If you do this from ruby 1.9, you'd end up creating the gem with that cover_me depended on everywhere, not just on ruby 1.9.

That's what I mean by rubygems needing to support it directly

@traxanos
Copy link

this is a problem. at the moment jeweler add rmagick and rmagick4r as runtime dependency. it's possible to exclude both gems? it a good workaround. user muss choice self wich version they need, and service like travis-ci use Gemfile and work, too.

@technicalpickles
Copy link
Owner

@traxanos that sounds like a different issue. You're talking about a gem that can use one of 2 possible libraries, yeah? This issue is mostly about that but for platform specific gems.

@aledalgrande
Copy link

Hi guys, ran into the same problem today. What I use in a normal gemspec to do this is:

gem.add_dependency "jruby-openssl" if RUBY_PLATFORM == "java"
gem.add_dependency "openssl" if RUBY_PLATFORM == "ruby"

You can also use it inside a jeweler task. Can this be added to the jeweler automatic translation of the Gemfile?
Cheers.

@traxanos
Copy link

nive idea +1

@RobWu
Copy link

RobWu commented Oct 7, 2011

+1

1 similar comment
@RobertLowe
Copy link

+1

@joelash
Copy link

joelash commented Oct 12, 2012

I noticed this issue is old, but is there any solution to this?

@technicalpickles
Copy link
Owner

To my knowledge, Gem::Specification still doesn't support per-platform dependencies :(

On Oct 12, 2012, at 4:31 PM, Joel Asher Friedman notifications@github.com wrote:

I noticed this issue is old, but is there any solution to this?


Reply to this email directly or view it on GitHub.

@joelash
Copy link

joelash commented Oct 12, 2012

What about the way flori/json does it? It's more complicated, but works. Essentially you have 2 gemspecs, one for each platform. Thus you build and release 2 gems, yet again one for each platform but having the same name.

@technicalpickles
Copy link
Owner

Those are good examples to look at, for sure. It is a pretty complicated work flow though. I have never done a multi platform gem though, so I'm not sure I know that workflow well enough to jewelerify it though.

@redox
Copy link

redox commented Jan 7, 2014

Any news? What about the if RUBY_PLATFORM == "...." test ?

@technicalpickles
Copy link
Owner

@redox that still has the same problem. As long as it's calling 'gem' conditionally, it'd have this problem.

I hadn't heard of any changes in rubygems, but I haven't been looking hard :( I haven't done a multi-platform gem yet either, so haven't had a ton of motivation to implement. I'd be happy to review any PRs to add this though.

@mfazekas
Copy link

Right now you can do it with a terrible monkey patch like this:

Jeweler::Tasks.new do |s|
   ...
   # load non conditional dependencies from Gemfile
   # monkey patch for conditional dependencies
   def s.to_ruby
      # see https://github.com/technicalpickles/jeweler/issues/170
      result = super
      fail "Unexpected gemspec:#{result}" unless result.chomp!("\nend\n")
      result << "\n  s.add_dependency('jruby-pageant', ['>= 1.1.1']) if RUBY_PLATFORM == 'jruby-pageant'"
      result << "\nend\n"
      result
    end
end

@flajann2
Copy link
Collaborator

If this is still a wanted feature, please let me know, otherwise I will be closing this issue shortly.

@redox
Copy link

redox commented Nov 2, 2016

If this is still a wanted feature, please let me know, otherwise I will be closing this issue shortly.

Yes, this is still something I would love to have to easily support jruby and rbx. Thank you for your help @flajann2 👍

@flajann2
Copy link
Collaborator

flajann2 commented Nov 2, 2016

Keeping this on the list.

@flajann2 flajann2 self-assigned this May 19, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

10 participants