From e25416c236d2ab6621c9f74393956d72881cf081 Mon Sep 17 00:00:00 2001 From: Steinar Foss Date: Mon, 12 Aug 2019 08:36:00 +0200 Subject: [PATCH 1/6] renamed python pkg sunbeam -> opm. setup.py: test_suite -> tests_suite . libsunbeam -> libopmcommon_python. sunbeam -> opm: test_connection ok. test_deck ok. test_group_tree ok. test_grupnet ok. test_parse_deck.py ok. test_parse.py ok. python all tests ok. --- CMakeLists.txt | 14 +++++------ python/cxx/sunbeam.cpp | 2 +- python/python/{sunbeam => opm}/__init__.py | 4 ++-- python/python/{sunbeam => opm}/config.py | 2 +- python/python/opm/deck/__init__.py | 2 ++ python/python/{sunbeam => opm}/parser.py | 2 +- python/python/{sunbeam => opm}/properties.py | 2 +- python/python/{sunbeam => opm}/schedule.py | 2 +- python/python/{sunbeam => opm}/sunbeam.py | 0 .../python/{sunbeam => opm}/tools/__init__.py | 0 .../{sunbeam => opm}/tools/time_vector.py | 12 +++++----- python/python/sunbeam/deck/__init__.py | 2 -- python/setup.py | 12 +++++----- python/tests/test_connection.py | 8 +++---- python/tests/test_deck.py | 6 ++--- python/tests/test_group_tree.py | 6 ++--- python/tests/test_grupnet.py | 4 ++-- python/tests/test_parse.py | 24 +++++++++---------- python/tests/test_parse_deck.py | 16 ++++++------- python/tests/test_props.py | 4 ++-- python/tests/test_schedule.py | 8 +++---- python/tests/test_state.py | 12 +++++----- python/tests/test_time_vector.py | 6 ++--- python/tests/test_wells.py | 22 ++++++++--------- 24 files changed, 86 insertions(+), 86 deletions(-) rename python/python/{sunbeam => opm}/__init__.py (67%) rename python/python/{sunbeam => opm}/config.py (87%) create mode 100644 python/python/opm/deck/__init__.py rename python/python/{sunbeam => opm}/parser.py (99%) rename python/python/{sunbeam => opm}/properties.py (98%) rename python/python/{sunbeam => opm}/schedule.py (98%) rename python/python/{sunbeam => opm}/sunbeam.py (100%) rename python/python/{sunbeam => opm}/tools/__init__.py (100%) rename python/python/{sunbeam => opm}/tools/time_vector.py (97%) delete mode 100644 python/python/sunbeam/deck/__init__.py diff --git a/CMakeLists.txt b/CMakeLists.txt index d6ac429f7..0d0df2ebf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -217,7 +217,7 @@ if (OPM_ENABLE_PYTHON) else() set( PYTHON_PACKAGE_PATH "site-packages") endif() - set(PYTHON_INSTALL_PREFIX "lib/python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}/${PYTHON_PACKAGE_PATH}/sunbeam" CACHE STRING "Subdirectory to install Python modules in") + set(PYTHON_INSTALL_PREFIX "lib/python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}/${PYTHON_PACKAGE_PATH}/opm" CACHE STRING "Subdirectory to install Python modules in") get_target_property(_ecl_include_dirs ecl INTERFACE_INCLUDE_DIRECTORIES) get_target_property(_opmcommon_include_dirs opmcommon INCLUDE_DIRECTORIES) @@ -229,7 +229,7 @@ if (OPM_ENABLE_PYTHON) set(_opmcommon_lib_dirs ${_ecl_lib_dir} ${CMAKE_BINARY_DIR}/lib ${CMAKE_PREFIX_PATH}/lib) string(REPLACE ";" ":" _setup_lib_dirs "${_opmcommon_lib_dirs}") - add_custom_command(OUTPUT python/python/sunbeam/libsunbeam.so + add_custom_command(OUTPUT python/python/opm/libopmcommon_python.so DEPENDS python/cxx/connection.cpp python/cxx/converters.hpp python/cxx/deck.cpp @@ -252,18 +252,18 @@ if (OPM_ENABLE_PYTHON) COMMAND python ${CMAKE_BINARY_DIR}/python/setup.py build build_ext - --build-lib=${CMAKE_BINARY_DIR}/python/python/sunbeam + --build-lib=${CMAKE_BINARY_DIR}/python/python/opm --library-dirs=${_setup_lib_dirs} --include-dirs=${_setup_include_dirs} WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/python COMMENT "Building python bindings") - add_custom_target(sunbeam ALL DEPENDS python/python/sunbeam/libsunbeam.so) - add_dependencies(sunbeam opmcommon) - INSTALL( DIRECTORY ${CMAKE_BINARY_DIR}/python/python/sunbeam/ DESTINATION ${CMAKE_INSTALL_PREFIX}/${PYTHON_INSTALL_PREFIX}) + add_custom_target(opmcommon_python ALL DEPENDS python/python/opm/libopmcommon_python.so) + add_dependencies(opmcommon_python opmcommon) + INSTALL( DIRECTORY ${CMAKE_BINARY_DIR}/python/python/opm/ DESTINATION ${CMAKE_INSTALL_PREFIX}/${PYTHON_INSTALL_PREFIX}) add_test(NAME python_tests WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/python - COMMAND python setup.py build_ext --dry-run --build-lib ${CMAKE_BINARY_DIR}/python/python/sunbeam test + COMMAND python setup.py build_ext --dry-run --build-lib ${CMAKE_BINARY_DIR}/python/python/opm test ) set_target_properties(opmcommon PROPERTIES POSITION_INDEPENDENT_CODE ON) diff --git a/python/cxx/sunbeam.cpp b/python/cxx/sunbeam.cpp index 5c935c6de..4c2678ca5 100644 --- a/python/cxx/sunbeam.cpp +++ b/python/cxx/sunbeam.cpp @@ -2,7 +2,7 @@ #include "sunbeam.hpp" -PYBIND11_MODULE(libsunbeam, module) { +PYBIND11_MODULE(libopmcommon_python, module) { sunbeam::export_Parser(module); sunbeam::export_Deck(module); sunbeam::export_DeckKeyword(module); diff --git a/python/python/sunbeam/__init__.py b/python/python/opm/__init__.py similarity index 67% rename from python/python/sunbeam/__init__.py rename to python/python/opm/__init__.py index d0af60473..052064238 100644 --- a/python/python/sunbeam/__init__.py +++ b/python/python/opm/__init__.py @@ -1,7 +1,7 @@ from __future__ import absolute_import -from .schedule import Well, Connection, Schedule -from .libsunbeam import action +from .schedule import Well, Connection, Schedule +from .libopmcommon_python import action from .config import EclipseConfig from .parser import parse, parse_string diff --git a/python/python/sunbeam/config.py b/python/python/opm/config.py similarity index 87% rename from python/python/sunbeam/config.py rename to python/python/opm/config.py index af9382b1a..4f6544143 100644 --- a/python/python/sunbeam/config.py +++ b/python/python/opm/config.py @@ -1,6 +1,6 @@ from __future__ import absolute_import -from sunbeam import libsunbeam as lib +from opm import libopmcommon_python as lib from .sunbeam import delegate @delegate(lib.SummaryConfig) diff --git a/python/python/opm/deck/__init__.py b/python/python/opm/deck/__init__.py new file mode 100644 index 000000000..e5c96f856 --- /dev/null +++ b/python/python/opm/deck/__init__.py @@ -0,0 +1,2 @@ +from opm.parser import load_deck as parse +from opm.parser import load_deck_string as parse_string diff --git a/python/python/sunbeam/parser.py b/python/python/opm/parser.py similarity index 99% rename from python/python/sunbeam/parser.py rename to python/python/opm/parser.py index 92c81a0e4..17afb5e88 100644 --- a/python/python/sunbeam/parser.py +++ b/python/python/opm/parser.py @@ -2,7 +2,7 @@ from __future__ import absolute_import import os.path import json -from sunbeam import libsunbeam as lib +from opm import libopmcommon_python as lib from .properties import SunbeamState diff --git a/python/python/sunbeam/properties.py b/python/python/opm/properties.py similarity index 98% rename from python/python/sunbeam/properties.py rename to python/python/opm/properties.py index 9eec91716..beba04eff 100644 --- a/python/python/sunbeam/properties.py +++ b/python/python/opm/properties.py @@ -1,7 +1,7 @@ from __future__ import absolute_import from os.path import isfile -from sunbeam import libsunbeam as lib +from opm import libopmcommon_python as lib from .sunbeam import delegate from .schedule import Schedule from .config import EclipseConfig diff --git a/python/python/sunbeam/schedule.py b/python/python/opm/schedule.py similarity index 98% rename from python/python/sunbeam/schedule.py rename to python/python/opm/schedule.py index c6f233189..3e247d615 100644 --- a/python/python/sunbeam/schedule.py +++ b/python/python/opm/schedule.py @@ -1,6 +1,6 @@ from __future__ import absolute_import -from sunbeam import libsunbeam as lib +from opm import libopmcommon_python as lib from .sunbeam import delegate @delegate(lib.Schedule) diff --git a/python/python/sunbeam/sunbeam.py b/python/python/opm/sunbeam.py similarity index 100% rename from python/python/sunbeam/sunbeam.py rename to python/python/opm/sunbeam.py diff --git a/python/python/sunbeam/tools/__init__.py b/python/python/opm/tools/__init__.py similarity index 100% rename from python/python/sunbeam/tools/__init__.py rename to python/python/opm/tools/__init__.py diff --git a/python/python/sunbeam/tools/time_vector.py b/python/python/opm/tools/time_vector.py similarity index 97% rename from python/python/sunbeam/tools/time_vector.py rename to python/python/opm/tools/time_vector.py index 672650095..871ce98d1 100644 --- a/python/python/sunbeam/tools/time_vector.py +++ b/python/python/opm/tools/time_vector.py @@ -6,7 +6,7 @@ except ImportError: from io import StringIO -import sunbeam.deck +import opm.deck # This is from the TimeMap.cpp implementation in opm ecl_month = {"JAN" : 1, @@ -172,7 +172,7 @@ class TimeVector(object): Basic usage example: #!/usr/bin/env python - from sunbeam.tools import TimeVector + from opm.tools import TimeVector # Create vector and load history. tv = TimeVector( start ) @@ -213,11 +213,11 @@ class TimeVector(object): self._add_dates_block(ts) start_dt = datetime.datetime(start_date.year, start_date.month, start_date.day) if base_file: - deck = sunbeam.deck.parse(base_file) + deck = opm.deck.parse(base_file) self._add_deck(deck, start_dt) if base_string: - deck = sunbeam.deck.parse_string(base_string) + deck = opm.deck.parse_string(base_string) self._add_deck(deck, start_dt) @@ -328,7 +328,7 @@ class TimeVector(object): tv.load("well.sch", date = datetime.datetime(2017, 4, 1)) """ - deck = sunbeam.deck.parse(filename) + deck = opm.deck.parse(filename) self._add_deck(deck, date) @@ -336,7 +336,7 @@ class TimeVector(object): """ Like load() - but load from a string literal instead of file. """ - deck = sunbeam.deck.parse_string(deck_string) + deck = opm.deck.parse_string(deck_string) self._add_deck(deck, date) diff --git a/python/python/sunbeam/deck/__init__.py b/python/python/sunbeam/deck/__init__.py deleted file mode 100644 index ae802d22c..000000000 --- a/python/python/sunbeam/deck/__init__.py +++ /dev/null @@ -1,2 +0,0 @@ -from sunbeam.parser import load_deck as parse -from sunbeam.parser import load_deck_string as parse_string diff --git a/python/setup.py b/python/setup.py index fc05afb72..1ebe11dea 100644 --- a/python/setup.py +++ b/python/setup.py @@ -22,7 +22,7 @@ if 'build' in sys.argv: ext_modules = [ Extension( - 'libsunbeam', + 'libopmcommon_python', [ 'cxx/connection.cpp', 'cxx/deck.cpp', @@ -48,16 +48,16 @@ ext_modules = [ ] setup( - name='Sunbeam', + name='Opm', package_dir = {'': 'python'}, packages=[ - 'sunbeam', - 'sunbeam.tools', - 'sunbeam.deck', + 'opm', + 'opm.tools', + 'opm.deck', ], ext_modules=ext_modules, license='Open Source', zip_safe=False, - test_suite='tests', + tests_suite='tests', setup_requires=["pytest-runner", 'setuptools_scm'], ) diff --git a/python/tests/test_connection.py b/python/tests/test_connection.py index 7f70ee400..748b70080 100644 --- a/python/tests/test_connection.py +++ b/python/tests/test_connection.py @@ -1,11 +1,11 @@ import unittest -import sunbeam +import opm class TestWells(unittest.TestCase): @classmethod def setUpClass(cls): - cls.sch = sunbeam.parse('tests/spe3/SPE3CASE1.DATA').schedule + cls.sch = opm.parse('tests/spe3/SPE3CASE1.DATA').schedule cls.timesteps = cls.sch.timesteps def test_connection_pos(self): @@ -26,8 +26,8 @@ class TestWells(unittest.TestCase): self.assertEqual("OPEN", connection.state) def test_filters(self): - flowing = sunbeam.Connection.flowing() - closed = sunbeam.Connection.closed() + flowing = opm.Connection.flowing() + closed = opm.Connection.closed() connections = self.sch.get_wells(0)[0].connections() self.assertEqual(len(list(filter(flowing, connections))), 2) self.assertEqual(len(list(filter(closed, connections))), 0) diff --git a/python/tests/test_deck.py b/python/tests/test_deck.py index a97296ccd..77ded704d 100644 --- a/python/tests/test_deck.py +++ b/python/tests/test_deck.py @@ -1,5 +1,5 @@ import unittest -import sunbeam.deck +import opm.deck class TestParse(unittest.TestCase): @@ -27,7 +27,7 @@ FIPNUM """ def setUp(self): - self.deck = sunbeam.deck.parse_string(self.DECK_STRING) + self.deck = opm.deck.parse_string(self.DECK_STRING) def test_deck_in(self): map(lambda kw: self.assertIn(kw, self.deck), [ @@ -49,7 +49,7 @@ FIPNUM str(self.deck['DX']).split() ) self.assertEqual( - str(sunbeam.deck.parse_string('RUNSPEC\n\nDX\n4*0.5 /')).split(), + str(opm.deck.parse_string('RUNSPEC\n\nDX\n4*0.5 /')).split(), 'RUNSPEC DX 0.5 0.5 0.5 0.5 /'.split() ) diff --git a/python/tests/test_group_tree.py b/python/tests/test_group_tree.py index 3a1e437fb..5f9be1f87 100644 --- a/python/tests/test_group_tree.py +++ b/python/tests/test_group_tree.py @@ -1,12 +1,12 @@ import sys import unittest -import sunbeam +import opm class TestGroupTree(unittest.TestCase): def setUp(self): norne = 'examples/data/norne/NORNE_ATW2013.DATA' - self.sch = sunbeam.parse(norne, [('PARSE_RANDOM_SLASH', sunbeam.action.ignore)]).schedule + self.sch = opm.parse(norne, [('PARSE_RANDOM_SLASH', opm.action.ignore)]).schedule def test_group(self): gr = self.sch.group(timestep=2)['PROD'] @@ -35,7 +35,7 @@ class TestGroupTree(unittest.TestCase): group = self.sch.group(timestep=3)['PROD'] children = ['MANI-B1', 'MANI-B2', 'MANI-D1', 'MANI-D2', 'MANI-E1', 'MANI-E2'] names = [child.name for child in group.children] - self.assertEqual(sunbeam.schedule.Group, type(child)) + self.assertEqual(opm.schedule.Group, type(child)) self.assertEqual(set(children), set(names)) if __name__ == '__main__': diff --git a/python/tests/test_grupnet.py b/python/tests/test_grupnet.py index d713dbb5b..2e4967ca3 100644 --- a/python/tests/test_grupnet.py +++ b/python/tests/test_grupnet.py @@ -1,13 +1,13 @@ import sys import unittest -import sunbeam +import opm class TestGrupnet(unittest.TestCase): @classmethod def setUpClass(cls): norne = 'examples/data/norne/NORNE_ATW2013.DATA' - cls.sch = sunbeam.parse(norne, [('PARSE_RANDOM_SLASH', sunbeam.action.ignore)]).schedule + cls.sch = opm.parse(norne, [('PARSE_RANDOM_SLASH', opm.action.ignore)]).schedule def test_vfp_table(self): self.assertEqual(0, self.sch.group(timestep=0)['PROD'].vfp_table_nr) diff --git a/python/tests/test_parse.py b/python/tests/test_parse.py index 30757f518..3678453fb 100644 --- a/python/tests/test_parse.py +++ b/python/tests/test_parse.py @@ -1,5 +1,5 @@ import unittest -import sunbeam +import opm import os.path import sys @@ -33,36 +33,36 @@ FIPNUM self.norne_fname = os.path.abspath('examples/data/norne/NORNE_ATW2013.DATA') def test_parse(self): - spe3 = sunbeam.parse(self.spe3fn) + spe3 = opm.parse(self.spe3fn) self.assertEqual('SPE 3 - CASE 1', spe3.state.title) def test_parse_with_recovery(self): - recovery = [("PARSE_RANDOM_SLASH", sunbeam.action.ignore)] - spe3 = sunbeam.parse(self.spe3fn, recovery=recovery) + recovery = [("PARSE_RANDOM_SLASH", opm.action.ignore)] + spe3 = opm.parse(self.spe3fn, recovery=recovery) def test_parse_with_multiple_recoveries(self): - recoveries = [ ("PARSE_RANDOM_SLASH", sunbeam.action.ignore), - ("FOO", sunbeam.action.warn), - ("PARSE_RANDOM_TEXT", sunbeam.action.throw) ] + recoveries = [ ("PARSE_RANDOM_SLASH", opm.action.ignore), + ("FOO", opm.action.warn), + ("PARSE_RANDOM_TEXT", opm.action.throw) ] - spe3 = sunbeam.parse(self.spe3fn, recovery=recoveries) + spe3 = opm.parse(self.spe3fn, recovery=recoveries) def test_throw_on_invalid_recovery(self): recoveries = [ ("PARSE_RANDOM_SLASH", 3.14 ) ] with self.assertRaises(TypeError): - sunbeam.parse(self.spe3fn, recovery=recoveries) + opm.parse(self.spe3fn, recovery=recoveries) with self.assertRaises(TypeError): - sunbeam.parse(self.spe3fn, recovery="PARSE_RANDOM_SLASH") + opm.parse(self.spe3fn, recovery="PARSE_RANDOM_SLASH") def test_data(self): pass - #regtest = sunbeam.parse(self.REGIONDATA) + #regtest = opm.parse(self.REGIONDATA) #self.assertEqual([3,3,1,2], regtest.props()['OPERNUM']) def test_parse_norne(self): - state = sunbeam.parse(self.norne_fname, recovery=[('PARSE_RANDOM_SLASH', sunbeam.action.ignore)]) + state = opm.parse(self.norne_fname, recovery=[('PARSE_RANDOM_SLASH', opm.action.ignore)]) es = state.state self.assertEqual(46, es.grid().getNX()) self.assertEqual(112, es.grid().getNY()) diff --git a/python/tests/test_parse_deck.py b/python/tests/test_parse_deck.py index be8b1c006..ed7b43bbf 100644 --- a/python/tests/test_parse_deck.py +++ b/python/tests/test_parse_deck.py @@ -1,6 +1,6 @@ import unittest -import sunbeam -import sunbeam.deck +import opm +import opm.deck import os.path class TestParse(unittest.TestCase): @@ -55,22 +55,22 @@ FIPNUM def test_IOError(self): with self.assertRaises(IOError): - sunbeam.parse("file/not/found") + opm.parse("file/not/found") with self.assertRaises(IOError): - sunbeam.deck.parse("/file/not/found") + opm.deck.parse("/file/not/found") def test_parser_fail_without_extension(self): - error_recovery = [("PARSE_RANDOM_SLASH", sunbeam.action.ignore)] + error_recovery = [("PARSE_RANDOM_SLASH", opm.action.ignore)] with self.assertRaises(ValueError): - sunbeam.deck.parse_string(self.DECK_ADDITIONAL_KEYWORDS, + opm.deck.parse_string(self.DECK_ADDITIONAL_KEYWORDS, recovery=error_recovery ) def test_parser_extension(self): - error_recovery = [("PARSE_RANDOM_SLASH", sunbeam.action.ignore)] - deck = sunbeam.deck.parse_string(self.DECK_ADDITIONAL_KEYWORDS, + error_recovery = [("PARSE_RANDOM_SLASH", opm.action.ignore)] + deck = opm.deck.parse_string(self.DECK_ADDITIONAL_KEYWORDS, keywords=self.KEYWORDS, recovery=error_recovery ) self.assertIn( 'TESTKEY0', deck ) diff --git a/python/tests/test_props.py b/python/tests/test_props.py index efe9bae47..9108a7421 100644 --- a/python/tests/test_props.py +++ b/python/tests/test_props.py @@ -1,5 +1,5 @@ import unittest -import sunbeam +import opm class TestProps(unittest.TestCase): @@ -9,7 +9,7 @@ class TestProps(unittest.TestCase): self.assertTrue(diff <= epsilon, msg=err_msg) def setUp(self): - self.spe3 = sunbeam.parse('tests/spe3/SPE3CASE1.DATA').state + self.spe3 = opm.parse('tests/spe3/SPE3CASE1.DATA').state self.props = self.spe3.props() def test_repr(self): diff --git a/python/tests/test_schedule.py b/python/tests/test_schedule.py index c0fe25ae2..e0b959341 100644 --- a/python/tests/test_schedule.py +++ b/python/tests/test_schedule.py @@ -1,13 +1,13 @@ import unittest import datetime as dt -import sunbeam +import opm class TestSchedule(unittest.TestCase): @classmethod def setUpClass(cls): - cls.sch = sunbeam.parse('tests/spe3/SPE3CASE1.DATA').schedule + cls.sch = opm.parse('tests/spe3/SPE3CASE1.DATA').schedule def testWells(self): self.assertEqual(2, len(self.sch.get_wells(0))) @@ -36,8 +36,8 @@ class TestSchedule(unittest.TestCase): def head(xs): return next(iter(xs)) - inje = head(filter(sunbeam.Well.injector(), g1)) - prod = head(filter(sunbeam.Well.producer(), g1)) + inje = head(filter(opm.Well.injector(), g1)) + prod = head(filter(opm.Well.producer(), g1)) self.assertEqual(self.sch.get_well('INJ', 0).isinjector(), inje.isinjector()) self.assertEqual(self.sch.get_well('PROD', 0).isproducer(), prod.isproducer()) diff --git a/python/tests/test_state.py b/python/tests/test_state.py index 77b5421ef..26ed5fbac 100644 --- a/python/tests/test_state.py +++ b/python/tests/test_state.py @@ -1,5 +1,5 @@ import unittest -import sunbeam +import opm class TestState(unittest.TestCase): FAULTS_DECK = """ @@ -49,8 +49,8 @@ SATNUM @classmethod def setUpClass(cls): - cls.spe3 = sunbeam.parse('tests/spe3/SPE3CASE1.DATA') - cpa = sunbeam.parse('tests/data/CORNERPOINT_ACTNUM.DATA') + cls.spe3 = opm.parse('tests/spe3/SPE3CASE1.DATA') + cpa = opm.parse('tests/data/CORNERPOINT_ACTNUM.DATA') cls.state = cls.spe3.state cls.cp_state = cpa.state @@ -124,7 +124,7 @@ SATNUM def test_faults(self): self.assertEquals([], self.state.faultNames()) self.assertEquals({}, self.state.faults()) - faultdeck = sunbeam.parse_string(self.FAULTS_DECK).state + faultdeck = opm.parse_string(self.FAULTS_DECK).state self.assertEqual(['F1', 'F2'], faultdeck.faultNames()) # 'F2' 5 5 1 4 1 4 'X-' / \n" f2 = faultdeck.faultFaces('F2') @@ -139,7 +139,7 @@ SATNUM # jf["OIL_WATER"] = 21.0 # set in deck # jf["GAS_OIL"] = -1.0 # N/A - js = sunbeam.parse('tests/data/JFUNC.DATA').state + js = opm.parse('tests/data/JFUNC.DATA').state self.assertEqual('JFUNC TEST', js.title) jf = js.jfunc() print(jf) @@ -167,7 +167,7 @@ JFUNC GAS * 13.0 0.6 0.7 Z / PROPS\nREGIONS """ - js_gas = sunbeam.parse_string(jfunc_gas).state + js_gas = opm.parse_string(jfunc_gas).state jf = js_gas.jfunc() self.assertEqual(jf['FLAG'], 'GAS') self.assertEqual(jf['DIRECTION'], 'Z') diff --git a/python/tests/test_time_vector.py b/python/tests/test_time_vector.py index 6acd0f3f6..bac080e35 100644 --- a/python/tests/test_time_vector.py +++ b/python/tests/test_time_vector.py @@ -1,7 +1,7 @@ import unittest import datetime -from sunbeam.tools import * -import sunbeam.deck +from opm.tools import * +import opm.deck from utils import tmp class TestTimeVector(unittest.TestCase): @@ -120,7 +120,7 @@ class TestTimeVector(unittest.TestCase): def test_no_leading_DATES(self): tv = TimeVector(datetime.date(1997, 11, 6), base_file="tests/data/schedule/part1.sch") s = str(tv) - d = sunbeam.deck.parse_string(s) + d = opm.deck.parse_string(s) kw0 = d[0] self.assertEqual(kw0.name, "WELSPECS") diff --git a/python/tests/test_wells.py b/python/tests/test_wells.py index 99c534317..fe0b0a46e 100644 --- a/python/tests/test_wells.py +++ b/python/tests/test_wells.py @@ -1,19 +1,19 @@ import unittest -import sunbeam +import opm class TestWells(unittest.TestCase): @classmethod def setUpClass(cls): - cls.sch = sunbeam.parse('tests/spe3/SPE3CASE1.DATA').schedule + cls.sch = opm.parse('tests/spe3/SPE3CASE1.DATA').schedule cls.timesteps = cls.sch.timesteps # cls.wells = cls.sch.wells def inje(self, wells): - return next(iter(filter(sunbeam.Well.injector(), wells))) + return next(iter(filter(opm.Well.injector(), wells))) def prod(self, wells): - return next(iter(filter(sunbeam.Well.producer(), wells))) + return next(iter(filter(opm.Well.producer(), wells))) def testWellPos0(self): wells = self.sch.get_wells(0) @@ -63,14 +63,14 @@ class TestWells(unittest.TestCase): self.assertTrue(prod.available_gctrl()) def testWellDefinedFilter(self): - defined0 = list(filter(sunbeam.Well.defined(0), self.sch.get_wells(0) )) - defined1 = list(filter(sunbeam.Well.defined(1), self.sch.get_wells(1) )) + defined0 = list(filter(opm.Well.defined(0), self.sch.get_wells(0) )) + defined1 = list(filter(opm.Well.defined(1), self.sch.get_wells(1) )) self.assertEqual(len(list(defined0)), 2) self.assertEqual(len(list(defined1)), 2) def testWellProdInjeFilter(self): - inje = list(filter(sunbeam.Well.injector(), self.sch.get_wells(0) )) - prod = list(filter(sunbeam.Well.producer(), self.sch.get_wells(0) )) + inje = list(filter(opm.Well.injector(), self.sch.get_wells(0) )) + prod = list(filter(opm.Well.producer(), self.sch.get_wells(0) )) self.assertEqual(len(inje), 1) self.assertEqual(len(prod), 1) @@ -81,15 +81,15 @@ class TestWells(unittest.TestCase): def testOpenFilter(self): wells = self.sch.get_wells(1) - open_at_1 = sunbeam.Well.flowing() + open_at_1 = opm.Well.flowing() flowing = list(filter(open_at_1, wells)) closed = list(filter(lambda well: not open_at_1(well), wells)) self.assertEqual(2, len(flowing)) self.assertEqual(0, len(closed)) - flowing1 = filter(lambda x: not sunbeam.Well.closed()(x), wells) - closed1 = filter(sunbeam.Well.closed(), wells) + flowing1 = filter(lambda x: not opm.Well.closed()(x), wells) + closed1 = filter(opm.Well.closed(), wells) self.assertListEqual(list(closed), list(closed1)) def testCompletions(self): From c94ed2f643046f91d8d71456419f3a0f5f06f9aa Mon Sep 17 00:00:00 2001 From: Steinar Foss Date: Thu, 15 Aug 2019 11:19:18 +0200 Subject: [PATCH 2/6] renaming python/cxx/sunbeam*.* -> common *.* --- CMakeLists.txt | 8 ++++---- python/cxx/{sunbeam.cpp => common.cpp} | 2 +- python/cxx/{sunbeam.hpp => common.hpp} | 0 python/cxx/{sunbeam_state.cpp => common_state.cpp} | 2 +- python/cxx/{sunbeam_state.hpp => common_state.hpp} | 0 python/cxx/connection.cpp | 2 +- python/cxx/deck.cpp | 2 +- python/cxx/deck_keyword.cpp | 2 +- python/cxx/eclipse_3d_properties.cpp | 2 +- python/cxx/eclipse_config.cpp | 2 +- python/cxx/eclipse_grid.cpp | 2 +- python/cxx/eclipse_state.cpp | 2 +- python/cxx/group.cpp | 2 +- python/cxx/group_tree.cpp | 2 +- python/cxx/parser.cpp | 4 ++-- python/cxx/schedule.cpp | 2 +- python/cxx/table_manager.cpp | 2 +- python/cxx/well.cpp | 2 +- python/setup.py | 4 ++-- 19 files changed, 22 insertions(+), 22 deletions(-) rename python/cxx/{sunbeam.cpp => common.cpp} (96%) rename python/cxx/{sunbeam.hpp => common.hpp} (100%) rename python/cxx/{sunbeam_state.cpp => common_state.cpp} (97%) rename python/cxx/{sunbeam_state.hpp => common_state.hpp} (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0d0df2ebf..5cc88d232 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -242,10 +242,10 @@ if (OPM_ENABLE_PYTHON) python/cxx/group_tree.cpp python/cxx/parser.cpp python/cxx/schedule.cpp - python/cxx/sunbeam.cpp - python/cxx/sunbeam.hpp - python/cxx/sunbeam_state.cpp - python/cxx/sunbeam_state.hpp + python/cxx/common.cpp + python/cxx/common.hpp + python/cxx/common_state.cpp + python/cxx/common_state.hpp python/cxx/table_manager.cpp python/cxx/well.cpp COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/python/ ${CMAKE_BINARY_DIR}/python diff --git a/python/cxx/sunbeam.cpp b/python/cxx/common.cpp similarity index 96% rename from python/cxx/sunbeam.cpp rename to python/cxx/common.cpp index 4c2678ca5..ac4ed5c89 100644 --- a/python/cxx/sunbeam.cpp +++ b/python/cxx/common.cpp @@ -1,5 +1,5 @@ #include -#include "sunbeam.hpp" +#include "common.hpp" PYBIND11_MODULE(libopmcommon_python, module) { diff --git a/python/cxx/sunbeam.hpp b/python/cxx/common.hpp similarity index 100% rename from python/cxx/sunbeam.hpp rename to python/cxx/common.hpp diff --git a/python/cxx/sunbeam_state.cpp b/python/cxx/common_state.cpp similarity index 97% rename from python/cxx/sunbeam_state.cpp rename to python/cxx/common_state.cpp index 83a4dcd6a..0c9e355a3 100644 --- a/python/cxx/sunbeam_state.cpp +++ b/python/cxx/common_state.cpp @@ -1,4 +1,4 @@ -#include "sunbeam_state.hpp" +#include "common_state.hpp" SunbeamState::SunbeamState(bool file_input, const std::string& deck_input, const Opm::ParseContext& context, const Opm::Parser& parser) diff --git a/python/cxx/sunbeam_state.hpp b/python/cxx/common_state.hpp similarity index 100% rename from python/cxx/sunbeam_state.hpp rename to python/cxx/common_state.hpp diff --git a/python/cxx/connection.cpp b/python/cxx/connection.cpp index d116da3d2..bb6f43412 100644 --- a/python/cxx/connection.cpp +++ b/python/cxx/connection.cpp @@ -1,6 +1,6 @@ #include -#include "sunbeam.hpp" +#include "common.hpp" namespace { diff --git a/python/cxx/deck.cpp b/python/cxx/deck.cpp index b1271ace6..a8ff64aaf 100644 --- a/python/cxx/deck.cpp +++ b/python/cxx/deck.cpp @@ -2,7 +2,7 @@ #include #include "converters.hpp" -#include "sunbeam.hpp" +#include "common.hpp" namespace { diff --git a/python/cxx/deck_keyword.cpp b/python/cxx/deck_keyword.cpp index 443001df3..536a6c4f6 100644 --- a/python/cxx/deck_keyword.cpp +++ b/python/cxx/deck_keyword.cpp @@ -5,7 +5,7 @@ #include #include -#include "sunbeam.hpp" +#include "common.hpp" #include "converters.hpp" diff --git a/python/cxx/eclipse_3d_properties.cpp b/python/cxx/eclipse_3d_properties.cpp index 3c2efd67a..1f9b2c7e7 100644 --- a/python/cxx/eclipse_3d_properties.cpp +++ b/python/cxx/eclipse_3d_properties.cpp @@ -1,7 +1,7 @@ #include #include -#include "sunbeam.hpp" +#include "common.hpp" #include "converters.hpp" namespace { diff --git a/python/cxx/eclipse_config.cpp b/python/cxx/eclipse_config.cpp index 0818ef078..fdde72d27 100644 --- a/python/cxx/eclipse_config.cpp +++ b/python/cxx/eclipse_config.cpp @@ -5,7 +5,7 @@ #include #include -#include "sunbeam.hpp" +#include "common.hpp" void sunbeam::export_EclipseConfig(py::module& module) diff --git a/python/cxx/eclipse_grid.cpp b/python/cxx/eclipse_grid.cpp index 3e9c8f68b..20b2344ac 100644 --- a/python/cxx/eclipse_grid.cpp +++ b/python/cxx/eclipse_grid.cpp @@ -4,7 +4,7 @@ #include #include -#include "sunbeam.hpp" +#include "common.hpp" namespace { diff --git a/python/cxx/eclipse_state.cpp b/python/cxx/eclipse_state.cpp index c28df47a5..7982a44e1 100644 --- a/python/cxx/eclipse_state.cpp +++ b/python/cxx/eclipse_state.cpp @@ -1,7 +1,7 @@ #include #include -#include "sunbeam.hpp" +#include "common.hpp" namespace { diff --git a/python/cxx/group.cpp b/python/cxx/group.cpp index c357fbb30..8feba2b9b 100644 --- a/python/cxx/group.cpp +++ b/python/cxx/group.cpp @@ -1,6 +1,6 @@ #include #include -#include "sunbeam.hpp" +#include "common.hpp" namespace { diff --git a/python/cxx/group_tree.cpp b/python/cxx/group_tree.cpp index 6a1691567..fff797c67 100644 --- a/python/cxx/group_tree.cpp +++ b/python/cxx/group_tree.cpp @@ -1,7 +1,7 @@ #include #include -#include "sunbeam.hpp" +#include "common.hpp" #include "converters.hpp" namespace { diff --git a/python/cxx/parser.cpp b/python/cxx/parser.cpp index d209d7585..e1fc7715f 100644 --- a/python/cxx/parser.cpp +++ b/python/cxx/parser.cpp @@ -3,8 +3,8 @@ #include #include -#include "sunbeam_state.hpp" -#include "sunbeam.hpp" +#include "common_state.hpp" +#include "common.hpp" namespace { diff --git a/python/cxx/schedule.cpp b/python/cxx/schedule.cpp index 5302bb101..9abf5e846 100644 --- a/python/cxx/schedule.cpp +++ b/python/cxx/schedule.cpp @@ -4,7 +4,7 @@ #include #include -#include "sunbeam.hpp" +#include "common.hpp" namespace { diff --git a/python/cxx/table_manager.cpp b/python/cxx/table_manager.cpp index 5bcd41764..fa3239868 100644 --- a/python/cxx/table_manager.cpp +++ b/python/cxx/table_manager.cpp @@ -1,6 +1,6 @@ #include -#include "sunbeam.hpp" +#include "common.hpp" namespace { diff --git a/python/cxx/well.cpp b/python/cxx/well.cpp index b521c0044..285f86f9e 100644 --- a/python/cxx/well.cpp +++ b/python/cxx/well.cpp @@ -1,6 +1,6 @@ #include #include -#include "sunbeam.hpp" +#include "common.hpp" namespace { diff --git a/python/setup.py b/python/setup.py index 1ebe11dea..2bcdb85e2 100644 --- a/python/setup.py +++ b/python/setup.py @@ -35,10 +35,10 @@ ext_modules = [ 'cxx/group_tree.cpp', 'cxx/parser.cpp', 'cxx/schedule.cpp', - 'cxx/sunbeam_state.cpp', + 'cxx/common_state.cpp', 'cxx/table_manager.cpp', 'cxx/well.cpp', - 'cxx/sunbeam.cpp' + 'cxx/common.cpp' ], libraries=['opmcommon', 'boost_filesystem', 'boost_regex', 'ecl'], language='c++', From 36338c8a71cd513aa614d37374281caa1f216672 Mon Sep 17 00:00:00 2001 From: Steinar Foss Date: Thu, 15 Aug 2019 11:35:28 +0200 Subject: [PATCH 3/6] namespace sunbeam -> opmcommon_python. --- python/cxx/common.cpp | 26 +++++++++++++------------- python/cxx/common.hpp | 2 +- python/cxx/connection.cpp | 2 +- python/cxx/deck.cpp | 2 +- python/cxx/deck_keyword.cpp | 2 +- python/cxx/eclipse_3d_properties.cpp | 2 +- python/cxx/eclipse_config.cpp | 2 +- python/cxx/eclipse_grid.cpp | 2 +- python/cxx/eclipse_state.cpp | 2 +- python/cxx/group.cpp | 2 +- python/cxx/group_tree.cpp | 2 +- python/cxx/parser.cpp | 2 +- python/cxx/schedule.cpp | 2 +- python/cxx/table_manager.cpp | 2 +- python/cxx/well.cpp | 2 +- 15 files changed, 27 insertions(+), 27 deletions(-) diff --git a/python/cxx/common.cpp b/python/cxx/common.cpp index ac4ed5c89..393da99b2 100644 --- a/python/cxx/common.cpp +++ b/python/cxx/common.cpp @@ -3,18 +3,18 @@ PYBIND11_MODULE(libopmcommon_python, module) { - sunbeam::export_Parser(module); - sunbeam::export_Deck(module); - sunbeam::export_DeckKeyword(module); - sunbeam::export_Schedule(module); - sunbeam::export_Well(module); - sunbeam::export_Group(module); - sunbeam::export_GroupTree(module); - sunbeam::export_Connection(module); - sunbeam::export_EclipseConfig(module); - sunbeam::export_Eclipse3DProperties(module); - sunbeam::export_EclipseState(module); - sunbeam::export_TableManager(module); - sunbeam::export_EclipseGrid(module); + opmcommon_python::export_Parser(module); + opmcommon_python::export_Deck(module); + opmcommon_python::export_DeckKeyword(module); + opmcommon_python::export_Schedule(module); + opmcommon_python::export_Well(module); + opmcommon_python::export_Group(module); + opmcommon_python::export_GroupTree(module); + opmcommon_python::export_Connection(module); + opmcommon_python::export_EclipseConfig(module); + opmcommon_python::export_Eclipse3DProperties(module); + opmcommon_python::export_EclipseState(module); + opmcommon_python::export_TableManager(module); + opmcommon_python::export_EclipseGrid(module); } diff --git a/python/cxx/common.hpp b/python/cxx/common.hpp index 047f69bce..0682661e4 100644 --- a/python/cxx/common.hpp +++ b/python/cxx/common.hpp @@ -11,7 +11,7 @@ const py::return_value_policy ref_internal = py::return_value_policy::reference_ const py::return_value_policy python_owner = py::return_value_policy::take_ownership; const py::return_value_policy move = py::return_value_policy::move; -namespace sunbeam { +namespace opmcommon_python { void export_Connection(py::module& module); void export_Deck(py::module& module); diff --git a/python/cxx/connection.cpp b/python/cxx/connection.cpp index bb6f43412..9981e80c9 100644 --- a/python/cxx/connection.cpp +++ b/python/cxx/connection.cpp @@ -15,7 +15,7 @@ std::string direction( const Connection& c ) { } -void sunbeam::export_Connection(py::module& module) { +void opmcommon_python::export_Connection(py::module& module) { py::class_< Connection >( module, "Connection") .def_property_readonly("direction", &direction ) diff --git a/python/cxx/deck.cpp b/python/cxx/deck.cpp index a8ff64aaf..6510cd1ad 100644 --- a/python/cxx/deck.cpp +++ b/python/cxx/deck.cpp @@ -37,7 +37,7 @@ namespace { } -void sunbeam::export_Deck(py::module &module) { +void opmcommon_python::export_Deck(py::module &module) { py::class_< Deck >(module, "Deck") .def( "__len__", &size ) diff --git a/python/cxx/deck_keyword.cpp b/python/cxx/deck_keyword.cpp index 536a6c4f6..d5ee85cf6 100644 --- a/python/cxx/deck_keyword.cpp +++ b/python/cxx/deck_keyword.cpp @@ -56,7 +56,7 @@ struct DeckRecordIterator } -void sunbeam::export_DeckKeyword(py::module& module) { +void opmcommon_python::export_DeckKeyword(py::module& module) { py::class_< DeckKeyword >( module, "DeckKeyword") .def( "__repr__", &DeckKeyword::name ) .def( "__str__", &str ) diff --git a/python/cxx/eclipse_3d_properties.cpp b/python/cxx/eclipse_3d_properties.cpp index 1f9b2c7e7..dd9b6ccaa 100644 --- a/python/cxx/eclipse_3d_properties.cpp +++ b/python/cxx/eclipse_3d_properties.cpp @@ -35,7 +35,7 @@ namespace { } -void sunbeam::export_Eclipse3DProperties(py::module& module) { +void opmcommon_python::export_Eclipse3DProperties(py::module& module) { py::class_< Eclipse3DProperties >( module, "Eclipse3DProperties") .def( "getRegions", ®ions ) diff --git a/python/cxx/eclipse_config.cpp b/python/cxx/eclipse_config.cpp index fdde72d27..58b0cbe5a 100644 --- a/python/cxx/eclipse_config.cpp +++ b/python/cxx/eclipse_config.cpp @@ -8,7 +8,7 @@ #include "common.hpp" -void sunbeam::export_EclipseConfig(py::module& module) +void opmcommon_python::export_EclipseConfig(py::module& module) { py::class_< EclipseConfig >( module, "EclipseConfig" ) .def( "init", &EclipseConfig::init, ref_internal) diff --git a/python/cxx/eclipse_grid.cpp b/python/cxx/eclipse_grid.cpp index 20b2344ac..e310d3eee 100644 --- a/python/cxx/eclipse_grid.cpp +++ b/python/cxx/eclipse_grid.cpp @@ -41,7 +41,7 @@ namespace { } -void sunbeam::export_EclipseGrid(py::module& module) { +void opmcommon_python::export_EclipseGrid(py::module& module) { py::class_< EclipseGrid >( module, "EclipseGrid") .def( "_getXYZ", &getXYZ ) diff --git a/python/cxx/eclipse_state.cpp b/python/cxx/eclipse_state.cpp index 7982a44e1..47105109c 100644 --- a/python/cxx/eclipse_state.cpp +++ b/python/cxx/eclipse_state.cpp @@ -85,7 +85,7 @@ namespace { } -void sunbeam::export_EclipseState(py::module& module) { +void opmcommon_python::export_EclipseState(py::module& module) { py::class_< EclipseState >( module, "EclipseState" ) .def_property_readonly( "title", &EclipseState::getTitle ) diff --git a/python/cxx/group.cpp b/python/cxx/group.cpp index 8feba2b9b..2d9c22146 100644 --- a/python/cxx/group.cpp +++ b/python/cxx/group.cpp @@ -14,7 +14,7 @@ namespace { } } -void sunbeam::export_Group(py::module& module) { +void opmcommon_python::export_Group(py::module& module) { py::class_< Group2 >( module, "Group") .def_property_readonly( "name", &Group2::name) diff --git a/python/cxx/group_tree.cpp b/python/cxx/group_tree.cpp index fff797c67..b9331b298 100644 --- a/python/cxx/group_tree.cpp +++ b/python/cxx/group_tree.cpp @@ -15,7 +15,7 @@ namespace { } } -void sunbeam::export_GroupTree(py::module& module) { +void opmcommon_python::export_GroupTree(py::module& module) { py::class_(module, "GroupTree") diff --git a/python/cxx/parser.cpp b/python/cxx/parser.cpp index e1fc7715f..954e5c01e 100644 --- a/python/cxx/parser.cpp +++ b/python/cxx/parser.cpp @@ -46,7 +46,7 @@ namespace { } } -void sunbeam::export_Parser(py::module& module) { +void opmcommon_python::export_Parser(py::module& module) { module.def( "parse", parse_file ); module.def( "parse_string", parse_string); diff --git a/python/cxx/schedule.cpp b/python/cxx/schedule.cpp index 9abf5e846..e3109a45d 100644 --- a/python/cxx/schedule.cpp +++ b/python/cxx/schedule.cpp @@ -90,7 +90,7 @@ namespace { } -void sunbeam::export_Schedule(py::module& module) { +void opmcommon_python::export_Schedule(py::module& module) { py::class_< Schedule >( module, "Schedule") .def("_groups", &get_groups ) diff --git a/python/cxx/table_manager.cpp b/python/cxx/table_manager.cpp index fa3239868..e18b1465a 100644 --- a/python/cxx/table_manager.cpp +++ b/python/cxx/table_manager.cpp @@ -16,7 +16,7 @@ namespace { } -void sunbeam::export_TableManager(py::module& module) { +void opmcommon_python::export_TableManager(py::module& module) { py::class_< TableManager >( module, "Tables") .def( "__contains__", &TableManager::hasTables ) diff --git a/python/cxx/well.cpp b/python/cxx/well.cpp index 285f86f9e..7ff880cc2 100644 --- a/python/cxx/well.cpp +++ b/python/cxx/well.cpp @@ -33,7 +33,7 @@ namespace { } -void sunbeam::export_Well(py::module& module) { +void opmcommon_python::export_Well(py::module& module) { py::class_< Well2 >( module, "Well") .def_property_readonly( "name", &Well2::name ) From 554ceb87ddbb2cbb0dafe8f1353bd8b224ff541e Mon Sep 17 00:00:00 2001 From: Steinar Foss Date: Thu, 15 Aug 2019 15:10:10 +0200 Subject: [PATCH 4/6] setup.py will install python packages. setup.py install to CMAKE_INSTALL_PREFIX. cmake will create python install dir. --- CMakeLists.txt | 16 +++++++++------- python/setup.py | 9 +++++++++ 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5cc88d232..ef99304f2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -211,13 +211,13 @@ install(DIRECTORY cmake DESTINATION share/opm) install(FILES etc/opm_bash_completion.sh.in DESTINATION share/opm/etc) if (OPM_ENABLE_PYTHON) + + find_package(PythonInterp REQUIRED) + include(FindPythonInterp) + make_directory(${CMAKE_BINARY_DIR}/python) - if (EXISTS "/etc/debian_version") - set( PYTHON_PACKAGE_PATH "dist-packages") - else() - set( PYTHON_PACKAGE_PATH "site-packages") - endif() - set(PYTHON_INSTALL_PREFIX "lib/python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}/${PYTHON_PACKAGE_PATH}/opm" CACHE STRING "Subdirectory to install Python modules in") + set(PYTHON_PACKAGE_PATH "site-packages") + set(PYTHON_INSTALL_PREFIX "lib/python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}/${PYTHON_PACKAGE_PATH}" CACHE STRING "Subdirectory to install Python modules in") get_target_property(_ecl_include_dirs ecl INTERFACE_INCLUDE_DIRECTORIES) get_target_property(_opmcommon_include_dirs opmcommon INCLUDE_DIRECTORIES) @@ -259,7 +259,9 @@ if (OPM_ENABLE_PYTHON) COMMENT "Building python bindings") add_custom_target(opmcommon_python ALL DEPENDS python/python/opm/libopmcommon_python.so) add_dependencies(opmcommon_python opmcommon) - INSTALL( DIRECTORY ${CMAKE_BINARY_DIR}/python/python/opm/ DESTINATION ${CMAKE_INSTALL_PREFIX}/${PYTHON_INSTALL_PREFIX}) + + install( CODE "execute_process(COMMAND mkdir -p ${CMAKE_INSTALL_PREFIX}/${PYTHON_INSTALL_PREFIX} )" ) + install( CODE "execute_process(COMMAND python python/setup.py build_ext --dry-run install --prefix=${CMAKE_INSTALL_PREFIX} )" ) add_test(NAME python_tests WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/python diff --git a/python/setup.py b/python/setup.py index 2bcdb85e2..3153319db 100644 --- a/python/setup.py +++ b/python/setup.py @@ -8,6 +8,11 @@ import setuptools import glob import os import subprocess +import argparse + +setupdir = os.path.dirname(__file__) +if setupdir != '': + os.chdir( setupdir ) try: subprocess.call(["c++", "--version"]) @@ -56,6 +61,10 @@ setup( 'opm.deck', ], ext_modules=ext_modules, + package_data={ + '': ['*.so'] + }, + include_package_data=True, license='Open Source', zip_safe=False, tests_suite='tests', From 522dee0a47954b84e85f5b76eddd28d258c84e6d Mon Sep 17 00:00:00 2001 From: Steinar Foss Date: Fri, 16 Aug 2019 10:35:28 +0200 Subject: [PATCH 5/6] setuptools install PYTHONPATH circumvention. --- python/setup.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/python/setup.py b/python/setup.py index 3153319db..82e898cb5 100644 --- a/python/setup.py +++ b/python/setup.py @@ -10,6 +10,24 @@ import os import subprocess import argparse + +parser = argparse.ArgumentParser() +parser.add_argument("build") +parser.add_argument("build_ext") +parser.add_argument("--build-lib") +parser.add_argument("--prefix") +parser.add_argument("--library-dirs") +parser.add_argument("--include-dirs") +parser.add_argument("--dry-run", action='store_true') +args = parser.parse_args() + +#Circumnventing setuptools' PYTHONPATH check. +#This is necessary during install +if args.prefix: + python_version = 'python' + str(sys.version_info.major) + '.' + str(sys.version_info.minor) + pkg_path_root = os.path.join(args.prefix, 'lib', python_version, 'site-packages') + os.environ['PYTHONPATH'] += ':' + pkg_path_root + setupdir = os.path.dirname(__file__) if setupdir != '': os.chdir( setupdir ) From 10142b482e79f61c0dd2a2e774010fa903a8d956 Mon Sep 17 00:00:00 2001 From: Steinar Foss Date: Fri, 16 Aug 2019 10:37:48 +0200 Subject: [PATCH 6/6] setup.py discontinue glob use. --- python/setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/setup.py b/python/setup.py index 82e898cb5..771ef8dd1 100644 --- a/python/setup.py +++ b/python/setup.py @@ -80,7 +80,7 @@ setup( ], ext_modules=ext_modules, package_data={ - '': ['*.so'] + '': ['cxx/libopmcommon_python.so'] }, include_package_data=True, license='Open Source',