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

Pydantic 2.0 (complete rewrite) breaks copier #1225

Closed
henryiii opened this issue Jun 30, 2023 · 7 comments · Fixed by #1229 or #1244
Closed

Pydantic 2.0 (complete rewrite) breaks copier #1225

henryiii opened this issue Jun 30, 2023 · 7 comments · Fixed by #1229 or #1244
Labels
bug triage Trying to make sure if this is valid or not

Comments

@henryiii
Copy link
Contributor

henryiii commented Jun 30, 2023

Describe the problem

After over a year and two PyCons, the Rust rewrite of Pydandic with 17x+ speedup (last I heard maybe it was 23x?) is out (four hours ago)! Unfortunately, it breaks copier. As much as I hate suggesting it, you might want to do a quick patch release with a version cap, then work on making it work (Unless it's really easy to fix, of course, which it might be).

Also, it's a really bad idea to use things from dependencies that start with underscores. Just saying. :P

(They did an incredible amount of work to try to make sure they didn't break users. Users importing underscore objects doesn't count!)

Template

https://github.com/scientific-python/cookie

(If you want one, that is - you can't even start copier on a fresh install)

To Reproduce

Run copier.

That's all.

Logs

  File "/home/runner/work/cookie/cookie/.nox/compare_copier/bin/copier", line 5, in <module>
    from copier.__main__ import copier_app_run
  File "/home/runner/work/cookie/cookie/.nox/compare_copier/lib/python3.8/site-packages/copier/__init__.py", line 6, in <module>
    from .main import *  # noqa: F401,F403
  File "/home/runner/work/cookie/cookie/.nox/compare_copier/lib/python3.8/site-packages/copier/main.py", line 29, in <module>
    from .errors import (
  File "/home/runner/work/cookie/cookie/.nox/compare_copier/lib/python3.8/site-packages/copier/errors.py", line 6, in <module>
    from pydantic.errors import _PathValueError
ImportError: cannot import name '_PathValueError' from 'pydantic.errors' (/home/runner/work/cookie/cookie/.nox/compare_copier/lib/python3.8/site-packages/pydantic/errors.py)

Expected behavior

Not to break when pydantic is installed, or not to install pedantic 2.0.

Screenshots/screencasts/logs

No response

Operating system

macOS

Operating system distribution and version

Any

Copier version

8.0.0

Python version

All

Installation method

pipx+pypi

Additional context

Broken logs at https://github.com/scientific-python/cookie/actions/runs/5426746583/jobs/9869183393

@luismata01
Copy link

Hi
I have the same problem use this ti install copier on Doodba copier template


Traceback (most recent call last):
File "/home/luis/.local/bin/copier", line 5, in
from copier.main import copier_app_run
File "/home/luis/.local/pipx/venvs/copier/lib/python3.8/site-packages/copier/init.py", line 6, in
from .main import * # noqa: F401,F403
File "/home/luis/.local/pipx/venvs/copier/lib/python3.8/site-packages/copier/main.py", line 29, in
from .errors import (
File "/home/luis/.local/pipx/venvs/copier/lib/python3.8/site-packages/copier/errors.py", line 6, in
from pydantic.errors import _PathValueError
ImportError: cannot import name '_PathValueError' from 'pydantic.errors' (/home/luis/.local/pipx/venvs/copier/lib/python3.8/site-packages/pydantic/errors.py

Tecnativa/doodba-copier-template#392 (comment)

Can you help me please

@sisp
Copy link
Member

sisp commented Jul 2, 2023

As a temporary workaround until we've fixed this problem, please override the installed version of Pydantic in your virtual environment where Copier is installed:

  • With pip:

    pip install -U 'pydantic<2'
  • With pipx:

    pipx inject copier 'pydantic<2'
  • With poetry:

    poetry add 'pydantic@<2'

Sorry for the inconvenience.

@luismata01
Copy link

Member
Thank's for your support

This solution work form me using
pipx inject copier 'pydantic<2'

Thanks

@roestzwiee
Copy link

Hi,
for those who have a dependency to copier v7, will there also be a fix for copier 7.2?

@henryiii
Copy link
Contributor Author

henryiii commented Jul 3, 2023

for those who have a dependency to copier v7, will there also be a fix for copier 7.2?

#1229 (comment) seems to indicate that might happen.

XaF added a commit to XaF/qolsysgw that referenced this issue Jul 3, 2023
Copier depends on pydantic and imports a private object from it.
Pydantic 2 has been rewritten in rust and does not have that private
object anymore. See the following link for more details:
copier-org/copier#1225 (comment)
FeodorFitsner added a commit to flet-dev/flet that referenced this issue Jul 4, 2023
@yajo
Copy link
Member

yajo commented Jul 10, 2023

You can enter a shell

As much as I hate suggesting it, you might want to do a quick patch release with a version cap, then work on making it work

See #1244.

@yajo
Copy link
Member

yajo commented Jul 10, 2023

FWIW you can enter a shell with a perfectly installable Copier doing:

nix shell github:copier-org/copier/v8.0.0

Change that last part for the tag you want.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug triage Trying to make sure if this is valid or not
Projects
None yet
5 participants