django / daphne

Django Channels HTTP/WebSocket server

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

fd_endpoint.py is not properly installed

sdc50 opened this issue · comments

Starting with v4.1 the fd_endpoint.py file is not copied/installed into the twisted/plugins directory.

Please also try and include, if you can:

  • Verified on MacOS and Linux Docker
  • A pip freeze output showing your package versions

With Daphne 4.0 (working):

(daphne-4.0) $ pip freeze
appdirs @ file:///home/conda/feedstock_root/build_artifacts/appdirs_1603108395799/work
asgiref @ file:///home/conda/feedstock_root/build_artifacts/asgiref_1711268871457/work
attrs @ file:///home/conda/feedstock_root/build_artifacts/attrs_1704011227531/work
autobahn @ file:///home/conda/feedstock_root/build_artifacts/autobahn_1686741996912/work
Automat @ file:///home/conda/feedstock_root/build_artifacts/automat_1667331175863/work
bcrypt @ file:///Users/runner/miniforge3/conda-bld/bcrypt_1702663957424/work
cffi @ file:///Users/runner/miniforge3/conda-bld/cffi_1696001825047/work
constantly==15.1.0
cryptography @ file:///Users/runner/miniforge3/conda-bld/cryptography-split_1708780331239/work
daphne @ file:///home/conda/feedstock_root/build_artifacts/daphne_1668155186031/work
hyperlink @ file:///home/conda/feedstock_root/build_artifacts/hyperlink_1610092164190/work
idna @ file:///home/conda/feedstock_root/build_artifacts/idna_1701026962277/work
incremental @ file:///home/conda/feedstock_root/build_artifacts/incremental_1665859450441/work
pyasn1 @ file:///home/conda/feedstock_root/build_artifacts/pyasn1_1701287008248/work
pyasn1-modules @ file:///home/conda/feedstock_root/build_artifacts/pyasn1-modules_1695107857548/work
pycparser @ file:///home/conda/feedstock_root/build_artifacts/pycparser_1711811537435/work
pyOpenSSL @ file:///home/conda/feedstock_root/build_artifacts/pyopenssl_1706660063483/work
service-identity @ file:///home/conda/feedstock_root/build_artifacts/service-identity-build_1700936484042/work
setuptools==69.2.0
six @ file:///home/conda/feedstock_root/build_artifacts/six_1620240208055/work
Twisted @ file:///Users/runner/miniforge3/conda-bld/twisted_1709332366653/work
txaio @ file:///home/conda/feedstock_root/build_artifacts/txaio_1673804636823/work
typing_extensions @ file:///home/conda/feedstock_root/build_artifacts/typing_extensions_1712329955671/work
wheel==0.43.0
zope.interface @ file:///Users/runner/miniforge3/conda-bld/zope.interface_1708077907560/work
(daphne-4.0) $ conda list daphne
# packages in environment at /Users/sdc50/conda/envs/daphne-4.0:
#
# Name                    Version                   Build  Channel
daphne                    4.0.0              pyhd8ed1ab_1    conda-forge
(daphne-4.0)$ ls $CONDA_PREFIX/lib/python3.1/site-packages/twisted/plugins/fd_endpoint.py
/Users/sdc50/conda/envs/daphne-4.0/lib/python3.1/site-packages/twisted/plugins/fd_endpoint.py

With Daphne 4.1 (not working)

(daphne-4.1) $ pip freeze
appdirs @ file:///home/conda/feedstock_root/build_artifacts/appdirs_1603108395799/work
asgiref @ file:///home/conda/feedstock_root/build_artifacts/asgiref_1711268871457/work
attrs @ file:///home/conda/feedstock_root/build_artifacts/attrs_1704011227531/work
autobahn @ file:///home/conda/feedstock_root/build_artifacts/autobahn_1686741996912/work
Automat @ file:///home/conda/feedstock_root/build_artifacts/automat_1667331175863/work
bcrypt @ file:///Users/runner/miniforge3/conda-bld/bcrypt_1702663957424/work
cffi @ file:///Users/runner/miniforge3/conda-bld/cffi_1696001825047/work
constantly==15.1.0
cryptography @ file:///Users/runner/miniforge3/conda-bld/cryptography-split_1708780331239/work
daphne @ file:///home/conda/feedstock_root/build_artifacts/daphne_1707583909223/work
hyperlink @ file:///home/conda/feedstock_root/build_artifacts/hyperlink_1610092164190/work
idna @ file:///home/conda/feedstock_root/build_artifacts/idna_1701026962277/work
incremental @ file:///home/conda/feedstock_root/build_artifacts/incremental_1665859450441/work
pyasn1 @ file:///home/conda/feedstock_root/build_artifacts/pyasn1_1701287008248/work
pyasn1-modules @ file:///home/conda/feedstock_root/build_artifacts/pyasn1-modules_1695107857548/work
pycparser @ file:///home/conda/feedstock_root/build_artifacts/pycparser_1711811537435/work
pyOpenSSL @ file:///home/conda/feedstock_root/build_artifacts/pyopenssl_1706660063483/work
service-identity @ file:///home/conda/feedstock_root/build_artifacts/service-identity-build_1700936484042/work
setuptools==69.2.0
six @ file:///home/conda/feedstock_root/build_artifacts/six_1620240208055/work
Twisted @ file:///Users/runner/miniforge3/conda-bld/twisted_1709332366653/work
txaio @ file:///home/conda/feedstock_root/build_artifacts/txaio_1673804636823/work
typing_extensions @ file:///home/conda/feedstock_root/build_artifacts/typing_extensions_1712329955671/work
wheel==0.43.0
zope.interface @ file:///Users/runner/miniforge3/conda-bld/zope.interface_1708077907560/work
(daphne-4.1) $ conda list daphne
# packages in environment at /Users/sdc50/conda/envs/daphne-4.1:
#
# Name                    Version                   Build  Channel
daphne                    4.1.0              pyhd8ed1ab_0    conda-forge
(daphne-4.1) $ ls $CONDA_PREFIX/lib/python3.1/site-packages/twisted/plugins/fd_endpoint.py
ls: /Users/sdc50/conda/envs/daphne-4.1/lib/python3.1/site-packages/twisted/plugins/fd_endpoint.py: No such file or directory
  • What you expected to happen vs. what actually happened

When Daphne is installed I expect the fd_enpoint.py file to be copied into the site-packaged/twisted/plugins directory so it can be discovered and loaded by twisted.

After installing Daphne 4.1, the fd_endpoint.py is not found in the site-packaged/twisted/plugins dir.

  • How you're running Channels (runserver? daphne/runworker? Nginx/Apache in front?)

I'm running Channels using Supervisord with Apache in front.

  • Console logs and full tracebacks of any errors
Traceback (most recent call last):
  File "/opt/conda/envs/tethys/bin/daphne", line 10, in <module>
    sys.exit(CommandLineInterface.entrypoint())
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/conda/envs/tethys/lib/python3.12/site-packages/daphne/cli.py", line 171, in entrypoint
    cls().run(sys.argv[1:])
  File "/opt/conda/envs/tethys/lib/python3.12/site-packages/daphne/cli.py", line 285, in run
    self.server.run()
  File "/opt/conda/envs/tethys/lib/python3.12/site-packages/daphne/server.py", line 130, in run
    ep = serverFromString(reactor, str(socket_description))
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/conda/envs/tethys/lib/python3.12/site-packages/twisted/internet/endpoints.py", line 1802, in serverFromString
    nameOrPlugin, args, kw = _parseServer(description, None)
                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/conda/envs/tethys/lib/python3.12/site-packages/twisted/internet/endpoints.py", line 1722, in _parseServer
    plugin = _matchPluginToPrefix(
             ^^^^^^^^^^^^^^^^^^^^^
  File "/opt/conda/envs/tethys/lib/python3.12/site-packages/twisted/internet/endpoints.py", line 1737, in _matchPluginToPrefix
    raise ValueError(f"Unknown endpoint type: '{endpointType}'")
ValueError: Unknown endpoint type: 'fd'

This is my temporary workaround:

cp ${CONDA_PREFIX}/lib/python3.1/site-packages/daphne/twisted/plugins/fd_endpoint.py ${CONDA_PREFIX}/lib/python3.1/site-packages/twisted/plugins/

Hi @sdc50 — thanks for the report.

daphne/setup.cfg

Lines 26 to 29 in 6379093

[options]
package_dir =
twisted=daphne/twisted
packages = find:

That should be right. Ref https://setuptools.pypa.io/en/latest/userguide/declarative_config.html#using-a-src-layout — but apparently isn't 🤔

Fancy experimenting a bit there?

It seems like switching find: to find_namespace: may do the trick.

[options]
package_dir=
    twisted=daphne/twisted
packages= find_namespace:

It seems like switching find: to find_namespace: may do the trick.

Never mind. It must have cached something. I think the only way I've been able to get it to work is by explicitly listed the packages:

[options]
package_dir=
    twisted=daphne/twisted
packages=
    daphne
    twisted.plugins

OK, reviewing the docs here I think manually specifying the packages is fine.

This can get tiresome really quickly.

Meh. I don't think it's really a problem here. 🙂

I'm sure if we read more, we could get it working again, but not sure it's worth the bandwidth.

Would you like to make a PR?

Thanks @sdc50. I'll get a release out with this tomorrow morning.