import os
from conans import ConanFile, tools
from extensions import build, package



class <$name>Conan(ConanFile):
    name = "<$name>"
    version = "<$version>"
    license = "<Put the package license here>"
    author = "<Put your name here> <And your email here>"
    url = "<$url>"
    description = "<$description>"
    topics = ("<Put some tag here>", "<here>", "<and here>")
    settings = "os"
    requires = <$requirements>


    def source(self):
        self.run("git clone <$url>")

    def requirements(self):
        pass

    def build(self):
        build.build_pre(self)
        conan_dir = os.getcwd()
        self.output.info('building package in directory {}'.format(conan_dir))
        #print('rootpath: {}'.format(
        #    self.deps_cpp_info['hello_test'].rootpath
        #))
        with open('<$name>.txt', 'w') as file:
            file.write(
                'This is the package binary produced by {}'.format(self.name)
            )

        #with tools.chdir(os.path.join(conan_dir, '..')):
        #    # create venv
        #    self.run("python -m venv ./venv")
        #    # install scons
        #    self.run("pip install scons")
        #    # activate venv and run scons
        #    self.run("source ./venv/bin/activate")
        #    self.run("scons --build-workarea={}".format(conan_dir))
        build.build_post(self)
    
    def package_info(self):
        """
            Info about this package that will be used by its consumers should be added here
        """
        self.cpp_info.name = "<$name>"
        #self.cpp_info.names["generator_name"] = ""
        #self.cpp_info.includedirs = ['include']  # Ordered list of include paths
        #self.cpp_info.libs = []  # The libs to link against
        #self.cpp_info.system_libs = []  # System libs to link against
        #self.cpp_info.libdirs = ['lib']  # Directories where libraries can be found
        #self.cpp_info.resdirs = ['res']  # Directories where resources, data, etc. can be found
        #self.cpp_info.bindirs = ['bin']  # Directories where executables and shared libs can be found
        #self.cpp_info.srcdirs = []  # Directories where sources can be found (debugging, reusing sources)
        #self.cpp_info.build_modules = {}  # Build system utility module files
        #self.cpp_info.defines = []  # preprocessor definitions
        #self.cpp_info.cflags = []  # pure C flags
        #self.cpp_info.cxxflags = []  # C++ compilation flags
        #self.cpp_info.sharedlinkflags = []  # linker flags
        #self.cpp_info.exelinkflags = []  # linker flags
        #self.cpp_info.components  # Dictionary with the different components a package may have
        #self.cpp_info.requires = None  # List of components from requirements

    def export(self):
        self.copy("*.py", src="extensions", dst="extensions")

    def package(self):
        package.package_pre(self)
        print('current folder ' + os.getcwd())
        self.copy("*.txt", dst="content", keep_path=False)
        package.package_post(self)
