INP-PM / FEDM

Finite Element Discharge Modelling code
https://inp-pm.github.io/FEDM/
GNU Lesser General Public License v3.0
10 stars 4 forks source link

Implement packaging method to permit pip install #1

Closed LiamPattinson closed 1 year ago

LiamPattinson commented 2 years ago

Hey there, I'll be listing 'TODO' items here while we help you work with your project. Each issue raised will eventually have an associated pull request after we've made some progress. Feel free to add comments, make requests, add your own TODO items etc. And of course, it's your work, so feel free to shoot down any ideas if you think we're going about things in the wrong way! See the GitHub docs for more info on Issues and Pull Requests.

First of all, I think we should implement some packaging utilities so that the program can be installed via pip install. In the examples, there's a pattern of importing FEDM using relative paths:

https://github.com/AleksandarJ1984/FEDM/blob/720e18015a994defab8c44d01b433bc4ddefaf5d/Examples/streamer_discharge/fedm-streamer.py#L14-L17

The disadvantage here is that it requires the user to be sitting in the correct directory in order to run the code, and as we develop things further it would be easier if FEDM functions/classes/modules could be loaded into the user's Python environment using pip and then called from anywhere. We can do this by writing a few short settings files in the main directory: setup.py, setup.cfg, and pyproject.toml. I'd recommend following the guide in the setuptools docs, but Python community has a reputation for rapidly changing their minds regarding what's the 'best practices' for packaging, so it may be a good idea to revisit this after a year or so (though it should continue to function for the foreseeable future). With this done, we'll be able to install the package by calling pip install . from the project's top-level directory, and we'll instead be able to call the following from anywhere on the user's system:

from fedm.physical_constants import *
from fedm.functions import *
from fedm.file_io import *

# Or...

from fedm import *

We'll also need to add an __init__.py file to designate FEDM as a Python package, but it looks like we won't need to do anything fancy there.

These changes will make it easier to implement other features, such as automated testing/documentation.

markus-m-becker commented 1 year ago

Suggested changes where implemented by @LiamPattinson.