What I have:
local Python3 files that I want to turn into a module
test_module
test_module
folder containing an empty__init__.py
, asetup.py
file (see below) and subdirectories with several source files
What I want:
continuously work on and improve
test_module
locallyhave an easy way to install
test_module
and all its dependencies locally in my own virtual environment (created usingpython3 -m venv my_environment
)run files that make use of the module via
python myexample.py
, without having to take care of adapting my local PYTHONPATH variable each time i enter or exit themy_environment
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)
learn best practices on how to create my own module
How I'm doing it at the moment:
pip freeze > requirements.txt
andpip install -r requirements.txt
for installing dependenciesadding
export PYTHONPATH="${PYTHONPATH}:."
tomy_environment/bin/activate
, to have my own module in the search path (as found here: How do you set your pythonpath in an already-created virtualenv?)
I'd like to know if there are "cleaner" solutions based on setup.py
, possibly involving something like pip install ./test_module
or similar that takes care of 2.-3. automagically.
My current setup.py
file looks as follows
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
)