What I have:
local Python3 files that I want to turn into a module
test_moduletest_modulefolder containing an empty__init__.py, asetup.pyfile (see below) and subdirectories with several source files
What I want:
continuously work on and improve
test_modulelocallyhave an easy way to install
test_moduleand 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_environmentshare 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.txtandpip install -r requirements.txtfor 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='[email protected]',
packages=['test_module'], # same as name
install_requires=['numpy', 'scipy', 'sklearn', 'argparse'], # external packages as dependencies
)
pypi? I think thatpip install test_moduleis eases way.pypi, so I didn't even consider it. But as of now, I only want to share the package wit ha couple of collaborators for development, not with everyone. And git seemed to be the natural choice for that, particularly since the project was started on git in the first place.virtualenv. I mean it would be something like this:git clone...+virtualenv env+source env/bin/activate+pip install -r requirements.txt+python run something. Besides, you do not need to do cloning and installing twice. don't understand for what install package intovirtualenv. I mean if you need to share packagepip + virtualenvis good way. But I'm not sure that you need it.test_moduleis my own module, i.e. it only exists locally. As far as I understand, I cannot install such modules usingpip. If there is such a way, I'd like to know how to do it (that is one part of the question). Right now, the way I make it work is to addexport PYTHONPATH...to mybin/activatescript, but this feels a little hacky and I'm thinking there must be a better way, without me having to ask other people to mess with theiractivatescript to run my code in theirvirtualenvvirtualenvusingsetup.py.source env/bin/activate,cd path_to_your_repo,python setup.py install