Skip Menu |

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the Dist-Zilla-Plugin-OSPrereqs CPAN distribution.

Report information
The Basics
Id: 81522
Status: resolved
Priority: 0/
Queue: Dist-Zilla-Plugin-OSPrereqs

People
Owner: Nobody in particular
Requestors: deeelwy [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: Only works for Windows not Unix.
Date: Wed, 28 Nov 2012 21:43:53 -0500
To: bug-Dist-Zilla-Plugin-OSPrereqs [...] rt.cpan.org
From: David Yingling <deeelwy [...] gmail.com>
Dist::Zilla::Plugin::OSPrereqs uses $^O to determine if the listed prereqs should be prereqs or not. This works OK for Windows, except if you run a perl compiled under Cygwin, because under Cygwin $^O is Cygwin instead of Win32 according to perlport. So that is perhaps a bug as well, because it means adding a prereq of Win32 will fail if you try to install it with a perl compiled under Cygwin, because the perl on Cygwin will have a $^O variable set to Cygwin instead of Win32. Interestingly Perl::OSType has Cygwin mapped to Unix, which is both right and wrong at the same time, and probably not worth changing. Perlport, by the way, lists Cygwin under Dos and derivatives. Similarly, just like Windows most of Unix-like OSes are similar enough that you can treat them the same. However, because Perl::OSType relies on $^O, you can only easily specify prereqs that should only be prereqs on Windows, because nobody is going to do something crazy like I've pasted below to use only a prereq on Unix. [OSPrereqs / Darwin] Privileges::Drop = 0 [OSPrereqs / aix] Privileges::Drop = 0 [OSPrereqs / bsdos] Privileges::Drop = 0 [OSPrereqs / dgux] Privileges::Drop = 0 ...( I got sick of copying and pasting, but you get the idea :) )... ...I have not even gotten to Linux, or any Unix that's still popular. ...And so on for everything listed at http://perldoc.perl.org/perlport.html#PLATFORMS in the Unix section. This seems like a design flaw. Dist::Zilla::Plugin::OSPrereqs was probably mostly written to only make something a requirement on Windows without testing or considering trying to use it to do the same thing on Unix. The easiest fix I can think of is to add Perl::OSType as a dependency. Then instead of relying on $^O. Just make "Windows" magical, and support all $^O values that could be Windows via Perl::OSType or a custom hash table based on perlport if you don't want to add a dependency. And also make "Unix" magical too, and these two strings will be run through Perl::OSType to see if the perl in use is "Windows" or "Unix." Doing it this way would also not change the current behavior regarding using "Win32". Instead of something too simple like: $^O eq $user_input You could do something like: if (grep $user_input eq $_, qw(Windows Unix)) { if (is_os_type($user_input)) { # Add the dependency. } # Add code that handles $^O too. } You could also add a magical one for Cygwin too. Perhaps call it "WindowsORCygwin" that will install the prereq on Windows, and would also install it if running in the fake Unix environment of Cygwin. Thanks, Dave.
Subject: Re: [rt.cpan.org #81522] Only works for Windows not Unix.
Date: Wed, 28 Nov 2012 21:55:49 -0500
To: bug-Dist-Zilla-Plugin-OSPrereqs [...] rt.cpan.org
From: David Golden <dagolden [...] cpan.org>
On Wed, Nov 28, 2012 at 9:44 PM, David Yingling via RT <bug-Dist-Zilla-Plugin-OSPrereqs@rt.cpan.org> wrote: Show quoted text
> This seems like a design flaw. Dist::Zilla::Plugin::OSPrereqs was probably mostly written to only make something a requirement on Windows without testing or considering trying to use it to do the same thing on Unix.
Dist::Zilla generally speaking is not designed to handle dynamic prerequisites and this plugin was quick hack to do something sensible for the common case of needing something extra on a "not unix" platform (Windows or Darwin, typically). The reality of "OS Typing" in Perl is that they don't really map cleanly. Darwin is Unix like but only to an extent. Ditto Cygwin with respect to *both* Unix and Windows. If you have advanced prerequisite needs, you need to look at MakeMaker plugin alternatives. I'd also welcome patches to do something sensible with Perl::OSType. FWIW, I would rather see Cygwin dependencies listed separate from Win32 (even if duplicated) because it's so peculiar. David -- David Golden <dagolden@cpan.org> Take back your inbox! → http://www.bunchmail.com/ Twitter/IRC: @xdg
Subject: Re: [rt.cpan.org #81522] Only works for Windows not Unix.
Date: Fri, 30 Nov 2012 19:29:41 -0500
To: bug-Dist-Zilla-Plugin-OSPrereqs [...] rt.cpan.org
From: David Yingling <deeelwy [...] gmail.com>
On Wed, 28 Nov 2012 21:56:30 -0500 "David Golden via RT" <bug-Dist-Zilla-Plugin-OSPrereqs@rt.cpan.org> wrote: Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=81522 > > > On Wed, Nov 28, 2012 at 9:44 PM, David Yingling via RT > <bug-Dist-Zilla-Plugin-OSPrereqs@rt.cpan.org> wrote:
> > This seems like a design flaw. Dist::Zilla::Plugin::OSPrereqs was probably mostly written to only make something a requirement on Windows without testing or considering trying to use it to do the same thing on Unix.
> > Dist::Zilla generally speaking is not designed to handle dynamic > prerequisites and this plugin was quick hack to do something sensible > for the common case of needing something extra on a "not unix" > platform (Windows or Darwin, typically). >
Yeah, I'm using it right now for a Windows only prereq. But I've recently added a Unix only prereq (Privileges::Drop), and I figured I'd just use the same plugin for it, but you can't check $^O for 'Unix.' I ended up just making if a full prereq, because according to CPANTesters Privileges::Drop passes its test suite on Win32 it just doesn't do anything that makes sense on Windows like changing $HOME environment variable. So, I just use a: use if is_os_type('Unix'), 'Privileges::Drop'; To only load it on Unix. And then put the call for drop_privileges(...); inside an if (is_os_type('Unix') { } block. Show quoted text
> The reality of "OS Typing" in Perl is that they don't really map > cleanly. Darwin is Unix like but only to an extent. Ditto Cygwin > with respect to *both* Unix and Windows. > > If you have advanced prerequisite needs, you need to look at MakeMaker > plugin alternatives. >
Wow, MakeMaker::Awesome is awesome! It lets you really customize MakeMaker. http://search.cpan.org/~avar/Dist-Zilla-Plugin-MakeMaker-Awesome-0.12/lib/Dist/Zilla/Plugin/MakeMaker/Awesome.pm I don't need anything that fancy, but it's nice to know you can really customize it if you want to. Show quoted text
> I'd also welcome patches to do something sensible with Perl::OSType. > > FWIW, I would rather see Cygwin dependencies listed separate from > Win32 (even if duplicated) because it's so peculiar. > > David > > -- > David Golden <dagolden@cpan.org> > Take back your inbox! → http://www.bunchmail.com/ > Twitter/IRC: @xdg >
Next release will allow negations and regex matches, so that will address "everything not Windows" prereqs. I'm going to close this ticket as I don't see it going beyond that.