akretion / docky-odoo-template

This a project template to use with docky
2 stars 13 forks source link

issue when with copier 6.x #60

Open rvalyi opened 1 year ago

rvalyi commented 1 year ago

For reference with copier 6.x if you do as in the README:

copier copy https://github.com/akretion/docky-odoo-template my-odoo-project

you will get:

Traceback (most recent call last):
  File "/home/rvalyi/.local/bin/copier", line 8, in <module>
    sys.exit(CopierApp.run())
  File "/home/rvalyi/.local/lib/python3.10/site-packages/plumbum/cli/application.py", line 629, in run
    inst, retcode = subapp.run(argv, exit=False)
  File "/home/rvalyi/.local/lib/python3.10/site-packages/plumbum/cli/application.py", line 624, in run
    retcode = inst.main(*tailargs)
  File "/home/rvalyi/.local/lib/python3.10/site-packages/copier/cli.py", line 71, in _wrapper
    return method(*args, **kwargs)
  File "/home/rvalyi/.local/lib/python3.10/site-packages/copier/cli.py", line 309, in main
    ).run_copy()
  File "/home/rvalyi/.local/lib/python3.10/site-packages/copier/main.py", line 604, in run_copy
    src_abspath = self.template_copy_root
  File "/usr/lib/python3.10/functools.py", line 981, in __get__
    val = self.func(instance)
  File "/home/rvalyi/.local/lib/python3.10/site-packages/copier/main.py", line 577, in template_copy_root
    subdir = self._render_string(self.template.subdirectory) or ""
  File "/usr/lib/python3.10/functools.py", line 981, in __get__
    val = self.func(instance)
  File "/home/rvalyi/.local/lib/python3.10/site-packages/copier/template.py", line 391, in subdirectory
    return self.config_data.get("subdirectory", "")
  File "/usr/lib/python3.10/functools.py", line 981, in __get__
    val = self.func(instance)
  File "/home/rvalyi/.local/lib/python3.10/site-packages/copier/template.py", line 224, in config_data
    result = filter_config(self._raw_config)[0]
  File "/usr/lib/python3.10/functools.py", line 981, in __get__
    val = self.func(instance)
  File "/home/rvalyi/.local/lib/python3.10/site-packages/copier/template.py", line 189, in _raw_config
    for p in self.local_abspath.glob("copier.*")
  File "/usr/lib/python3.10/functools.py", line 981, in __get__
    val = self.func(instance)
  File "/home/rvalyi/.local/lib/python3.10/site-packages/copier/template.py", line 439, in local_abspath
    raise ValueError("Local template must be a directory.")
ValueError: Local template must be a directory.

if you upgrade to copier 7.x it works.

Alternatively you can bootstrap the project using this command instead:

copier copy gh:akretion/docky-odoo-template my-odoo-project

May be we can change the readme to make it easier, not sure.

hparfr commented 1 year ago

Thanks for pointing this. So the resolution is to go to v7. About the short version, I prefer to use the long version.

juanchodpg2 commented 6 months ago

Hi, a related issue here, but with copier 9.2.0. I want to use a git repo in Azure DevOps in a copier copy command. Specifically I run: copier copy https://dev.azure.com/ . and I get the following:

Traceback (most recent call last):
  File "/Users/jdpg/.local/bin/copier", line 10, in <module>
    sys.exit(copier_app_run())
  File "/Users/jdpg/Library/Application Support/pipx/venvs/copier/lib/python3.10/site-packages/plumbum/cli/application.py", line 638, in run
    inst, retcode = subapp.run(argv, exit=False)
  File "/Users/jdpg/Library/Application Support/pipx/venvs/copier/lib/python3.10/site-packages/plumbum/cli/application.py", line 633, in run
    retcode = inst.main(*tailargs)
  File "/Users/jdpg/Library/Application Support/pipx/venvs/copier/lib/python3.10/site-packages/copier/cli.py", line 280, in main
    return _handle_exceptions(inner)
  File "/Users/jdpg/Library/Application Support/pipx/venvs/copier/lib/python3.10/site-packages/copier/cli.py", line 70, in _handle_exceptions
    method()
  File "/Users/jdpg/Library/Application Support/pipx/venvs/copier/lib/python3.10/site-packages/copier/cli.py", line 271, in inner
    with self._worker(
  File "/Users/jdpg/Library/Application Support/pipx/venvs/copier/lib/python3.10/site-packages/copier/main.py", line 217, in __exit__
    raise value
  File "/Users/jdpg/Library/Application Support/pipx/venvs/copier/lib/python3.10/site-packages/copier/cli.py", line 278, in inner
    worker.run_copy()
  File "/Users/jdpg/Library/Application Support/pipx/venvs/copier/lib/python3.10/site-packages/copier/main.py", line 757, in run_copy
    self._check_unsafe("copy")
  File "/Users/jdpg/Library/Application Support/pipx/venvs/copier/lib/python3.10/site-packages/copier/main.py", line 231, in _check_unsafe
    if self.template.jinja_extensions:
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/functools.py", line 981, in __get__
    val = self.func(instance)
  File "/Users/jdpg/Library/Application Support/pipx/venvs/copier/lib/python3.10/site-packages/copier/template.py", line 326, in jinja_extensions
    return tuple(self.config_data.get("jinja_extensions", ()))
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/functools.py", line 981, in __get__
    val = self.func(instance)
  File "/Users/jdpg/Library/Application Support/pipx/venvs/copier/lib/python3.10/site-packages/copier/template.py", line 288, in config_data
    result = filter_config(self._raw_config)[0]
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/functools.py", line 981, in __get__
    val = self.func(instance)
  File "/Users/jdpg/Library/Application Support/pipx/venvs/copier/lib/python3.10/site-packages/copier/template.py", line 245, in _raw_config
    for p in self.local_abspath.glob("copier.*")
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/functools.py", line 981, in __get__
    val = self.func(instance)
  File "/Users/jdpg/Library/Application Support/pipx/venvs/copier/lib/python3.10/site-packages/copier/template.py", line 500, in local_abspath
    raise ValueError("Local template must be a directory.")
ValueError: Local template must be a directory.

It works fine with local folders, but not from Azure DevOps repos.

Any ideas? My computer can connect normally with git to that repo outside of copier.

verbockhaven commented 6 months ago

From the code it looks like a "git url" is required

class Template:
    """Object that represents a template and its current state.

    See [configuring a template][configuring-a-template].

    Attributes:
        url:
            Absolute origin that points to the template.

            It can be:

            - A local path.
            - A Git url. Note: if something fails, prefix the URL with `git+`.

So, the solution that looks to work for me is the following:

from copier import run_copy

run_copy("git+https://dev.azure.com/.....", "folder")

Or, directly using the CLI:

copier copy git+https://dev.azure.com/... folder
juanchodpg2 commented 6 months ago

From the code it looks like a "git url" is required

class Template:
    """Object that represents a template and its current state.

    See [configuring a template][configuring-a-template].

    Attributes:
        url:
            Absolute origin that points to the template.

            It can be:

            - A local path.
            - A Git url. Note: if something fails, prefix the URL with `git+`.

So, the solution that looks to work for me is the following:

from copier import run_copy

run_copy("git+https://dev.azure.com/.....", "folder")

Or, directly using the CLI:

copier copy git+https://dev.azure.com/... folder

Great, it indeed works with the git+. Thanks!