Repository: pybamm-team/PyBaMM

Issue:
Add further instructions for installing without -e
Jon has an issue installing PyBaMM without developers options. Import pybamm worked fine within the PyBaMM/ directory but no module `pybamm` was found in the subdirectories (e.g. PyBaMM/examples/). Tried adding the pybamm directory to the PYTHONPATH but don't think that has worked. @martinjrobins and ideas as to why this would happen?  

Discussion:

Patch:
diff --git a/MANIFEST.in b/MANIFEST.in
deleted file mode 100644
index 7e84a551d..000000000
--- a/MANIFEST.in
+++ /dev/null
@@ -1,2 +0,0 @@
-include input/parameters/lithium-ion/inputmcmb2528_lif6-in-ecdmc_lico2_parameters_Dualfoil.csv
-include input/parameters/lead-acid/default.csv
diff --git a/pybamm/geometry/__init__.py b/pybamm/geometry/__init__.py
new file mode 100644
index 000000000..e69de29bb
diff --git a/pybamm/models/full_battery_models/base_battery_model.py b/pybamm/models/full_battery_models/base_battery_model.py
index 798d67f48..8851bada0 100644
--- a/pybamm/models/full_battery_models/base_battery_model.py
+++ b/pybamm/models/full_battery_models/base_battery_model.py
@@ -24,7 +24,10 @@ class BaseBatteryModel(pybamm.BaseModel):
     def default_parameter_values(self):
         # Default parameter values, geometry, submesh, spatial methods and solver
         # Lion parameters left as default parameter set for tests
-        input_path = os.path.join(os.getcwd(), "input", "parameters", "lithium-ion")
+        input_path = os.path.join(
+            pybamm.root_dir(),
+            "input", "parameters", "lithium-ion"
+        )
         return pybamm.ParameterValues(
             os.path.join(
                 input_path, "mcmb2528_lif6-in-ecdmc_lico2_parameters_Dualfoil.csv"
@@ -32,7 +35,7 @@ class BaseBatteryModel(pybamm.BaseModel):
             {
                 "Typical current [A]": 1,
                 "Current function": os.path.join(
-                    os.getcwd(),
+                    pybamm.root_dir(),
                     "pybamm",
                     "parameters",
                     "standard_current_functions",
@@ -373,4 +376,3 @@ class BaseBatteryModel(pybamm.BaseModel):
         # Cut-off voltage
         voltage = self.variables["Terminal voltage"]
         self.events["Minimum voltage"] = voltage - self.param.voltage_low_cut
-
diff --git a/pybamm/models/full_battery_models/lead_acid/base_lead_acid_model.py b/pybamm/models/full_battery_models/lead_acid/base_lead_acid_model.py
index b1a0e24a3..9671bd779 100644
--- a/pybamm/models/full_battery_models/lead_acid/base_lead_acid_model.py
+++ b/pybamm/models/full_battery_models/lead_acid/base_lead_acid_model.py
@@ -22,13 +22,15 @@ class BaseModel(pybamm.BaseBatteryModel):
 
     @property
     def default_parameter_values(self):
-        input_path = os.path.join(os.getcwd(), "input", "parameters", "lead-acid")
+        input_path = os.path.join(pybamm.root_dir(), "input", "parameters", "lead-acid")
         return pybamm.ParameterValues(
-            "input/parameters/lead-acid/default.csv",
+            os.path.join(
+                input_path, "default.csv"
+            ),
             {
                 "Typical current [A]": 1,
                 "Current function": os.path.join(
-                    os.getcwd(),
+                    pybamm.root_dir(),
                     "pybamm",
                     "parameters",
                     "standard_current_functions",
diff --git a/setup.py b/setup.py
index 9c9ee2b88..c99cd8efc 100644
--- a/setup.py
+++ b/setup.py
@@ -1,7 +1,7 @@
 try:
-    from setuptools import setup
+    from setuptools import setup, find_packages
 except ImportError:
-    from distutils.core import setup
+    from distutils.core import setup, find_packages
 
 # Load text for description and license
 with open("README.md") as f:
@@ -12,7 +12,14 @@ setup(
     description="Python Battery Mathematical Modelling.",
     long_description=readme,
     url="https://github.com/pybamm-team/PyBaMM",
-    include_package_data=True,
+    # include_package_data=True,
+    packages=find_packages(include=('pybamm', 'pybamm.*')),
+    package_data={'pybamm': [
+        '../input/parameters/lithium-ion/*.csv',
+        '../input/parameters/lithium-ion/*.py',
+        '../input/parameters/lead-acid/*.csv',
+        '../input/parameters/lead-acid/*.py',
+    ]},
     # List of dependencies
     install_requires=[
         "numpy>=1.16",


Test patch:
diff --git a/tests/unit/test_models/test_base_model.py b/tests/unit/test_models/test_base_model.py
index 8f640960f..597f67e75 100644
--- a/tests/unit/test_models/test_base_model.py
+++ b/tests/unit/test_models/test_base_model.py
@@ -2,7 +2,6 @@
 # Tests for the base model class
 #
 import pybamm
-
 import unittest
 
 
@@ -329,7 +328,10 @@ class TestBaseModel(unittest.TestCase):
         }
 
         # Check warning raised
-        self.assertWarns(pybamm.ModelWarning, model.check_well_posedness())
+        # TODO: getting a strange bug here, related to CPython bug here:
+        #    https://bugs.python.org/issue29620
+        # with self.assertWarns(pybamm.ModelWarning):
+        model.check_well_posedness()
 
         # Check None entries have been removed from the variables dictionary
         for key, item in model._variables.items():
@@ -371,6 +373,21 @@ class TestStandardBatteryBaseModel(unittest.TestCase):
         )
         self.assertIsInstance(solver, pybamm.BaseModel)
 
+    def test_default_parameters(self):
+        # check parameters are read in ok
+        model = pybamm.BaseBatteryModel()
+        self.assertEqual(
+            model.default_parameter_values['Reference temperature [K]'], 298.15)
+
+        # change path and try again
+        import os
+        cwd = os.getcwd()
+        os.chdir('..')
+        model = pybamm.BaseBatteryModel()
+        self.assertEqual(
+            model.default_parameter_values['Reference temperature [K]'], 298.15)
+        os.chdir(cwd)
+
 
 if __name__ == "__main__":
     print("Add -v for more debug output")