[julia-users] Re: conditional dependencies on packages with macros

2015-12-08 Thread Jeffrey Sarnoff
If I understand your question, you need to determine whether or not a 
package (call it "Package") is available to be used via *using* or *import.*
You can know if a package is present before trying to load the package.  

This will evaluate true when the package "Package" is present, and false 
when the package is not present, before trying to load it:
``
 isdir(joinpath(Pkg.dir(),"Package")
```
On Tuesday, December 8, 2015 at 11:02:17 AM UTC-5, Jeffrey Sarnoff wrote:

if isdir(joinpath(Pkg.dir(),"Package"))
  ...
else
  ...
end


On Monday, December 7, 2015 at 10:50:56 AM UTC-5, Seth wrote:
>
> Is there a way to specify a conditional dependency (that is, use package 
> Foo if it's available and define functions that use things from Foo; 
> otherwise, don't define the functions or throw an error message) on 
> packages that contain macros? isdefined(Main, :Package) won't work since 
> the macros from Package are evaluated prior to this conditional, and it 
> will throw an error.
>
> I was using Requires.jl to do this, but one issue I ran into is that an 
> error in the code within the @require block is not propagated as an error; 
> it's presented as a warning, which means that things like unit tests will 
> pass even if the code is incorrect.
>


[julia-users] Re: conditional dependencies on packages with macros

2015-12-08 Thread Seth
Sorry, Jeffrey, I'm not following. Could you explain a bit better how this 
would work? Are you intending that "using Package" goes within the if 
statement?

On Tuesday, December 8, 2015 at 8:02:17 AM UTC-8, Jeffrey Sarnoff wrote:
>
> if isdir(joinpath(Pkg.dir(),"Package"))
>   ...
> else
>   ...
> end
>
>
> On Monday, December 7, 2015 at 10:50:56 AM UTC-5, Seth wrote:
>>
>> Is there a way to specify a conditional dependency (that is, use package 
>> Foo if it's available and define functions that use things from Foo; 
>> otherwise, don't define the functions or throw an error message) on 
>> packages that contain macros? isdefined(Main, :Package) won't work since 
>> the macros from Package are evaluated prior to this conditional, and it 
>> will throw an error.
>>
>> I was using Requires.jl to do this, but one issue I ran into is that an 
>> error in the code within the @require block is not propagated as an error; 
>> it's presented as a warning, which means that things like unit tests will 
>> pass even if the code is incorrect.
>>
>

[julia-users] Re: conditional dependencies on packages with macros

2015-12-08 Thread Jeffrey Sarnoff
if isdir(joinpath(Pkg.dir(),"Package"))
  ...
else
  ...
end


On Monday, December 7, 2015 at 10:50:56 AM UTC-5, Seth wrote:
>
> Is there a way to specify a conditional dependency (that is, use package 
> Foo if it's available and define functions that use things from Foo; 
> otherwise, don't define the functions or throw an error message) on 
> packages that contain macros? isdefined(Main, :Package) won't work since 
> the macros from Package are evaluated prior to this conditional, and it 
> will throw an error.
>
> I was using Requires.jl to do this, but one issue I ran into is that an 
> error in the code within the @require block is not propagated as an error; 
> it's presented as a warning, which means that things like unit tests will 
> pass even if the code is incorrect.
>


[julia-users] Re: conditional dependencies on packages with macros

2015-12-08 Thread Seth
Thanks, Jeffrey. I'll give that a shot.

On Tuesday, December 8, 2015 at 8:43:00 AM UTC-8, Jeffrey Sarnoff wrote:
>
> If I understand your question, you need to determine whether or not a 
> package (call it "Package") is available to be used via *using* or 
> *import.*
> You can know if a package is present before trying to load the package.  
>
> This will evaluate true when the package "Package" is present, and false 
> when the package is not present, before trying to load it:
> ``
>  isdir(joinpath(Pkg.dir(),"Package")
> ```
> On Tuesday, December 8, 2015 at 11:02:17 AM UTC-5, Jeffrey Sarnoff wrote:
>>
>> if isdir(joinpath(Pkg.dir(),"Package"))
>>   ...
>> else
>>   ...
>> end
>>
>>
>> On Monday, December 7, 2015 at 10:50:56 AM UTC-5, Seth wrote:
>>>
>>> Is there a way to specify a conditional dependency (that is, use package 
>>> Foo if it's available and define functions that use things from Foo; 
>>> otherwise, don't define the functions or throw an error message) on 
>>> packages that contain macros? isdefined(Main, :Package) won't work since 
>>> the macros from Package are evaluated prior to this conditional, and it 
>>> will throw an error.
>>>
>>> I was using Requires.jl to do this, but one issue I ran into is that an 
>>> error in the code within the @require block is not propagated as an error; 
>>> it's presented as a warning, which means that things like unit tests will 
>>> pass even if the code is incorrect.
>>>
>>