Springerle/py-generic-project

post_gen_project license copy broken

TheMeier opened this issue · 3 comments

with current versions of cookiecutter (1.6.0) the license handlin is broken

it seems repo_dir is not available for templating

I see this can only be changed in cookiecutter itself as the hook is run from inside the new-project dir. For vcs templates one could find the path to the template repo with something like this

    user_config_data = config.get_user_config()
    repo_url = '{{ cookiecutter._template }}'
    clone_to_dir = user_config_data['cookiecutters_dir']
    print("repo url {}".format(repo_url))
    if repository.is_repo_url(repo_url):
        repo_type, repo_url = vcs.identify_repo(repo_url)
        tail = os.path.split(repo_url)[1]
        if repo_type == 'git':
            repo_dir = "{}/{}".format(clone_to_dir,os.path.normpath(os.path.join(clone_to_dir, tail.rsplit('.git')[0])))
        elif repo_type == 'hg':
            repo_dir = "{}/{}".format(clone_to_dir, os.path.normpath(os.path.join(clone_to_dir, tail)))

but for non vcs templates I don't find a way to get an absolute path to the template directory 😦

The license stuff relies on patches I wasn't able to place upstream at the time. I guess I should take a look at it again, given the current code bases.

actually I thought of a different approach. put the licenese folder inside the repo template as licenses.in then copy from there and delete licenses.in afterwards
this should work and eliminate any need for changes in cookiecutter