This is a Python project template with a configuration script that saves the data paths to config.ini
. Publishing to PyPI (so you only have to install this via python3 -m pip install elfin_conjunctions
) is a few extra steps and this article goes into the details.
I found this package format very useful for my data analysis projects so hopefully you will too. Feel free to copy/paste these files into your own repository and rename/delete all of the dummy names and modules.
- To install as a developer run:
or
git clone git@github.com:mshumko/elfin_conjunctions.git cd elfin_conjunctions # Then one of these (see comment in requirement.txt): python3 -m pip install -e .
python3 -m pip install -r requirements.txt
After you install the project using the above commands, run python3 -m elfin_asi_conjunctions config
to add the path to the ELFIN data. It will be saved to elfin_asi_conjunctions/config.ini
.
You'll need to install IRBEM to use the Conjunction
class in conjunction.py
. You'll need to compile the fortran code and then install the Python wrapper.
This folder (project_template
):
- The
project_template
folder contains the auxiliary files required to install theproject
package (a folder).setup.py
: Installsproject
usingsetuptools
. It's formatting is rapidly evolving, but a popular location to save the project metadata insetup.cfg
. Thesetup.cfg
metadata contains external dependencies that are installed viapython3 -m pip install -e .
(don't forget the period).requirements.txt
: the pinned project dependencies installed when you callpython3 -m pip install -r requirements.txt
.
- The
project
folder contains the package source code and the folder's name becomes the package name (imported viaimport project
).__init__.py
: module is executed when you callimport project
. Here, it contains the code to load theconfig.ini
file__main__.py
: module creates theconfig.ini
with the hard-coded paths. You can call it usingpython3 -m project config
. Techincal note:__main__.py
is executed after__init__.py
, so__init__.py
includes anif
statement to prevent a crash.library.py
: A dummy project module that can be imported viaimport project.library
orfrom project import library
. The convention is that package source code contains functions and classes and no scripts. This is to avoid executing scripting code (code outside of any function or class) on import.a_script.py
: A dummy script that shows how to importproject
and call thehello
function inproject/library.py
. Onceproject
is installed, you can runa_scipt.py
anywhere on your computer.