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

add black dependency, re #10690 #10691

Closed
wants to merge 1 commit into from
Closed

Conversation

apeters
Copy link
Member

@apeters apeters commented Mar 15, 2024

Types of changes

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Description of Change

adds a dependency on the black module

Issues Solved

creating an app or project using the command arches-admin startapp or arches-admin startproject
throws an error

(testenv) bash-3.2$ arches-admin startproject testproj
Traceback (most recent call last):
  File "/Users/alexei/Work/Projects/arches/shpo/testapp/testenv/bin/arches-admin", line 246, in <module>
    main()
  File "/Users/alexei/Work/Projects/arches/shpo/testapp/testenv/bin/arches-admin", line 239, in main
    COMMANDS[args.command](args)
  File "/Users/alexei/Work/Projects/arches/shpo/testapp/testenv/bin/arches-admin", line 157, in command_startproject
    cmd.handle(options)
  File "/Users/alexei/Work/Projects/arches/shpo/testapp/testenv/bin/arches-admin", line 151, in handle
    super(ArchesProjectCommand, self).handle('project', project_name, target, **options)
  File "/Users/alexei/Work/Projects/arches/shpo/testapp/testenv/lib/python3.11/site-packages/django/core/management/templates.py", line 232, in handle
    run_formatters([top_dir], **formatter_paths)
  File "/Users/alexei/Work/Projects/arches/shpo/testapp/testenv/lib/python3.11/site-packages/django/core/management/utils.py", line 172, in run_formatters
    subprocess.run(
  File "/usr/local/Cellar/[email protected]/3.11.6_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/subprocess.py", line 548, in run
    with Popen(*popenargs, **kwargs) as process:
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/Cellar/[email protected]/3.11.6_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/subprocess.py", line 1026, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/usr/local/Cellar/[email protected]/3.11.6_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/subprocess.py", line 1950, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: '/Users/alexei/Library/Python/3.7/bin/black'

Checklist

  • Unit tests pass locally with my changes
  • I have added tests that prove my fix is effective or that my feature works
  • I have added necessary documentation (if appropriate)

Ticket Background

@jacobtylerwalls
Copy link
Member

@chiatt posted a workaround on the Django forum when this happened to him. I couldn't reproduce either then or now.

This is definitely a bug in Django, because this is supposed to be frictionless -- Django is only supposed to format your files if you have a working black install.

Cyrus's workaround was to just rip out the unrelated black installation. From your trace it looks like it's trying to invoke a python 3.7 interpreter. My guess is that based on some combination of your $CWD and $PATH is to blame for black being able to be detected at one time and not the other. I would just uninstall python 3.7.

I don't feel too strongly, but it seems like a shame to add a dependency just to work around a bug in Django. I'll report it upstream and see if anyone thinks it should be fixed.

@apeters
Copy link
Member Author

apeters commented Apr 6, 2024

@chiatt posted a workaround on the Django forum when this happened to him. I couldn't reproduce either then or now.

This is definitely a bug in Django, because this is supposed to be frictionless -- Django is only supposed to format your files if you have a working black install.

Cyrus's workaround was to just rip out the unrelated black installation. From your trace it looks like it's trying to invoke a python 3.7 interpreter. My guess is that based on some combination of your $CWD and $PATH is to blame for black being able to be detected at one time and not the other. I would just uninstall python 3.7.

I don't feel too strongly, but it seems like a shame to add a dependency just to work around a bug in Django. I'll report it upstream and see if anyone thinks it should be fixed.

Thanks @jacobtylerwalls! I didn't realize that this was a Django issue. Closing this PR and ticket.

@apeters apeters closed this Apr 6, 2024
@apeters apeters deleted the 10690_add_black_dependency branch April 6, 2024 02:20
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

Successfully merging this pull request may close these issues.

2 participants