Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Intra-application dependencies between modules #7

Open
krivenko opened this issue Nov 17, 2017 · 6 comments
Open

Intra-application dependencies between modules #7

krivenko opened this issue Nov 17, 2017 · 6 comments

Comments

@krivenko
Copy link
Contributor

When cpp2py was a part of triqs, it was possible to define a wrapped type in one Python module, and then use it in another module of the same application. For example, I could have the following description file,

module = module_(full_name = "module4", doc = "My application", app_name = "myapp")

module.use_module('module1', 'myapp')
module.use_module('module2', 'myapp')
module.use_module('module3', 'myapp')

Can I achieve a similar effect with the new cpp2py?
As far as I can see, use_module() is now not a thing...

@parcollet
Copy link
Member

just import the module in the desc.
All information is now contained in the module, including the type converters, various tables.

@krivenko
Copy link
Contributor Author

Thank you for the answer!
For the sake of testing, I am now trying to add a second module to cthyb.

from cpp2py.wrap_generator import *

# The module
module = module_(full_name = "test_module", doc = "The cthyb solver", app_name = "solver_core")

# Imports
import pytriqs.gf
import pytriqs.operators
import pytriqs.statistics.histograms
import pytriqs.atom_diag
import solver_core

module.generate_code()

There seems to be a problem with some mako template:

[ 97%] Building CXX object python/cthyb/CMakeFiles/test_module.dir/test_module_wrap.cxx.o
/home/igor/Physics/TRIQS/cthyb/build/python/cthyb/test_module_wrap.cxx:41:32: error: use of undeclared identifier 'triqs'
template<> struct py_converter<triqs::atom_diag::atom_diag<true>> { 
                               ^
/home/igor/Physics/TRIQS/cthyb/build/python/cthyb/test_module_wrap.cxx:81:32: error: use of undeclared identifier 'triqs'
template<> struct py_converter<triqs::atom_diag::atom_diag<false>> { 
                               ^
/home/igor/Physics/TRIQS/cthyb/build/python/cthyb/test_module_wrap.cxx:611:10: error: expected "FILENAME" or <FILENAME>
#include ../../cthyb/solver_core.hpp
         ^
/home/igor/Physics/TRIQS/cthyb/build/python/cthyb/test_module_wrap.cxx:618:32: error: use of undeclared identifier 'cthyb'
template<> struct py_converter<cthyb::solver_core> { 
                               ^
/home/igor/Physics/TRIQS/cthyb/build/python/cthyb/test_module_wrap.cxx:661:33: error: use of undeclared identifier 'cthyb'
template <> struct py_converter<cthyb::block_order> {
                                ^

@parcollet
Copy link
Member

which module do you want to add to cthyb ?

@krivenko
Copy link
Contributor Author

I don't want to modify cthyb.

I just use it as a working setup to learn how inter-module dependencies work.
The module I'm trying to add is called test_module, and its .desc file is posted in the previous comment. Here are the lines I added to CMakeLists.txt:

add_cpp2py_module(test_module)

target_link_libraries(test_module cthyb_c)

target_include_directories(test_module PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})

@parcollet
Copy link
Member

The simplest would be for me to see your dev branch.

krivenko added a commit to TRIQS/cthyb that referenced this issue Nov 17, 2017
@krivenko
Copy link
Contributor Author

The simplest would be for me to see your dev branch.

Here it is: https://github.com/TRIQS/cthyb/tree/cpp2py_test_module

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants