title: Installing my own python module inside a virtual environment
body: <p><strong>What I have:</strong>  </p>
  
  <ul>
  <li><p>local Python3 files that I want to turn into a module <code>test_module</code></p></li>
  <li><p><code>test_module</code> folder containing an empty <code>__init__.py</code>, a <code>setup.py</code> file (see below) and subdirectories with several source
  files</p></li>
  </ul>
  
  <p><strong>What I want:</strong>  </p>
  
  <ol>
  <li><p>continuously work on and improve <code>test_module</code> locally</p></li>
  <li><p>have an easy way to install <code>test_module</code> and all its dependencies locally in my own virtual environment (created using <code>python3 -m venv my_environment</code>)</p></li>
  <li><p>run files that make use of the module via <code>python myexample.py</code>, without having to take care of adapting my local PYTHONPATH variable each time i enter or exit the <code>my_environment</code></p></li>
  <li><p>share my python code with others via git, and allow them to install their code locally on their machines using the same procedure (as simple as possible)</p></li>
  <li><p>learn best practices on how to create my own module</p></li>
  </ol>
  
  <p><strong>How I'm doing it at the moment:</strong>  </p>
  
  <ul>
  <li><p><code>pip freeze &gt; requirements.txt</code> and <code>pip install -r requirements.txt</code> for installing dependencies</p></li>
  <li><p>adding <code>export PYTHONPATH="${PYTHONPATH}:."</code> to <code>my_environment/bin/activate</code>, to have my own module in the search path
  (as found here: <a href="https://stackoverflow.com/questions/4757178/how-do-you-set-your-pythonpath-in-an-already-created-virtualenv">How do you set your pythonpath in an already-created virtualenv?</a>)</p></li>
  </ul>
  
  <p>I'd like to know if there are "cleaner" solutions based on <code>setup.py</code>, possibly involving something like <code>pip install ./test_module</code> or similar that takes care of 2.-3. automagically.</p>
  
  <p>My current <code>setup.py</code> file looks as follows</p>
  
  <pre><code> from setuptools import setup
  
   setup(
      name='test_module',
      version='0.1',
      description='Some really good stuff, that I am still working on',
      author='Bud Spencer',
      author_email='bud.spencer@stackoverflow.com',
      packages=['test_module'],  # same as name
      install_requires=['numpy', 'scipy', 'sklearn', 'argparse'], # external packages as dependencies
    )
  </code></pre>