milesmcc / shynet

Modern, privacy-friendly, and detailed web analytics that works without cookies or JS.
Apache License 2.0
2.9k stars 185 forks source link

Docker-less troubles #329

Closed CarlSinclair closed 2 months ago

CarlSinclair commented 2 months ago

Edit: updated instructions to fix my own problem. And help anyone who finds this.

As discussed in #9, I've been trying to get shynet up and running without docker in order to submit a PR with documentation. I'm using RHEL but once done the instructions can easily be translated into Debian or any other Linux flavor.

I'm running into issues. Here's what I've done so far:

  1. sudo dnf install -y python3 python3-pip git gcc
  2. curl -sSL https://install.python-poetry.org | python3 -
  3. git clone https://github.com/milesmcc/shynet.git
  4. cd shynet
  5. npm install
  6. poetry run pip install "Cython<3.0" "pyyaml==5.4.1" "django-allauth==0.45.0" --no-build-isolation
  7. poetry install
  8. set up the .env file with your db, your domain in allowed_hosts and csrf_trusted_origins, and port (matching your vhost). I also did django_secret_key and time_zone.
  9. set up a corresponding vhost or Caddy site block
  10. poetry run python manage.py migrate
  11. poetry run python manage.py collectstatic
  12. python manage.py compilemessages

Here's the output: The updated instructions shouldn't cause this error.

    main()
  File "shynet/shynet/manage.py", line 17, in main
    execute_from_command_line(sys.argv)
  File "/root/.cache/pypoetry/virtualenvs/shynet-p4mndYDs-py3.9/lib/python3.9/site-packages/django/core/management/__init__.py", line 446, in execute_from_command_line
    utility.execute()
  File "/root/.cache/pypoetry/virtualenvs/shynet-p4mndYDs-py3.9/lib/python3.9/site-packages/django/core/management/__init__.py", line 420, in execute
    django.setup()
  File "/root/.cache/pypoetry/virtualenvs/shynet-p4mndYDs-py3.9/lib/python3.9/site-packages/django/__init__.py", line 24, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "/root/.cache/pypoetry/virtualenvs/shynet-p4mndYDs-py3.9/lib/python3.9/site-packages/django/apps/registry.py", line 91, in populate
    app_config = AppConfig.create(entry)
  File "/root/.cache/pypoetry/virtualenvs/shynet-p4mndYDs-py3.9/lib/python3.9/site-packages/django/apps/config.py", line 193, in create
    import_module(entry)
  File "/usr/lib64/python3.9/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 984, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'allauth'

  ChefBuildError

  Backend subprocess exited when trying to invoke get_requires_for_build_wheel

  Traceback (most recent call last):
    File "/root/.local/share/pypoetry/venv/lib64/python3.9/site-packages/pyproject_hooks/_in_process/_in_process.py", line 373, in <module>
      main()
    File "/root/.local/share/pypoetry/venv/lib64/python3.9/site-packages/pyproject_hooks/_in_process/_in_process.py", line 357, in main
      json_out["return_val"] = hook(**hook_input["kwargs"])
    File "/root/.local/share/pypoetry/venv/lib64/python3.9/site-packages/pyproject_hooks/_in_process/_in_process.py", line 134, in get_requires_for_build_wheel
      return hook(config_settings)
    File "/tmp/tmpam4wz8v1/.venv/lib/python3.9/site-packages/setuptools/build_meta.py", line 327, in get_requires_for_build_wheel
      return self._get_build_requires(config_settings, requirements=[])
    File "/tmp/tmpam4wz8v1/.venv/lib/python3.9/site-packages/setuptools/build_meta.py", line 297, in _get_build_requires
      self.run_setup()
    File "/tmp/tmpam4wz8v1/.venv/lib/python3.9/site-packages/setuptools/build_meta.py", line 497, in run_setup
      super().run_setup(setup_script=setup_script)
    File "/tmp/tmpam4wz8v1/.venv/lib/python3.9/site-packages/setuptools/build_meta.py", line 313, in run_setup
      exec(code, locals())
    File "<string>", line 9, in <module>
  ImportError: cannot import name 'convert_path' from 'setuptools' (/tmp/tmpam4wz8v1/.venv/lib/python3.9/site-packages/setuptools/__init__.py)

  at ~/.local/share/pypoetry/venv/lib64/python3.9/site-packages/poetry/installation/chef.py:164 in _prepare
      160│
      161│                 error = ChefBuildError("\n\n".join(message_parts))
      162│
      163│             if error is not None:
    → 164│                 raise error from None
      165│
      166│             return path
      167│
      168│     def _prepare_sdist(self, archive: Path, destination: Path | None = None) -> Path:

Note: This error originates from the build backend, and is likely not a problem with poetry but with django-allauth (0.45.0) not supporting PEP 517 builds. You can verify this by running 'pip wheel --no-cache-dir --use-pep517 "django-allauth (==0.45.0)"'.

I was able to install django-allauth manually using pip, but that doesn't prevent poetry from trying to install it. I couldn't find a requirements.py file to remove it as a dependency.

milesmcc commented 2 months ago

Dependencies are defined in the pyproject.toml file; perhaps remove (or modify) django-allauth there? And feel free to do a dependency bump (if everything works smoothly after that bump, please also feel free to upstream it as a PR).

Docker is the only officially supported way of running Shynet—too much surface area for me to maintain otherwise—so I'm going to close this issue, though perhaps others can chime in if they have ideas for how to resolve this issue.

CarlSinclair commented 1 month ago

I got the server running and successfully logged in, but I'm getting a weird error:

Forbidden (403)
CSRF verification failed. Request aborted.

Even though the exact domain is in the .env file. I even replaced it with https:// to allow all domains, and the error persists. Is there another setting somewhere for trusted origins?

CarlSinclair commented 1 month ago

For anyone who finds this and would like to help, I figured out the django allauth issue from this commit that addresses exactly that.

The command in question is poetry run pip install "Cython<3.0" "pyyaml==5.4.1" "django-allauth==0.45.0" --no-build-isolation followed by poetry install