title: Load a mathematica package from within a package
body: <p>I have more or less the following setting. In <code>~/path/to/my/packages</code> I have two packages <code>package1.m</code> and <code>package2.m</code>. Each package's outline is, for example, the following:</p>
  
  <pre><code>BeginPackage["package1`"]
  Unprotect@@Names["package1`*"];
  ClearAll@@Names["package1`*"];
  
  Begin["`Private`"]
  
  vecNorm[vec_?VectorQ]:=Module[{},Return[Sqrt[vec.vec]]];
  
  End[]
  Protect@@Names["package1`*"];
  EndPackage[]
  </code></pre>
  
  <p>Now, my problem is that I want to use <code>vecNorm</code> defined in <code>package1.m</code> in <code>package2.m</code>. How can I load (safely) <code>package1</code> from within <code>package2</code>?</p>
  
  <p>At the moment, I load manually both packages as follows:</p>
  
  <pre><code>SetDirectory[StringJoin[NotebookDirectory[], "packages"]];
  Needs["package1`"]
  Needs["package2`"]
  </code></pre>
  
  <p>from a notebook saved in <code>~/path/to/my</code>. I want to load manually <em>only</em> <code>package2</code> which in turn will load automatically and safely <code>package1</code>. In general I want a solution which changes as little as possible paths etc. of mathematica. What should be the best practice to accomplish this?</p>
  
  <p><em>PS</em>: By safely I mean that in the future, when I'll define <code>package3</code> which will be using <code>vecNorm</code> as well and will be loading <code>package1</code> as well no conflicts will happen.</p>