michael-lazar / pygopherd

Multiprotocol Gopher/Web Server [Python 3]
https://michael-lazar.github.io/pygopherd/doc/pygopherd.html
GNU General Public License v2.0
33 stars 8 forks source link

Python 3.12 Support #11

Open nickenzi opened 1 month ago

nickenzi commented 1 month ago

Pygopherd cannot run under Python 3.12.

michael-lazar commented 1 month ago

Hey, I just merged some fixes for python 3.12 here: https://github.com/michael-lazar/pygopherd/pull/12

I haven't tried it out on a live server yet, but the tests are passing at least. Give it a shot when you get a chance.

nickenzi commented 1 month ago

I tried installing the latest and greatest on Mint 21.3/Python 3.10.12 before I attempt my dist-upgrade again to Mint 22/Python 3.12 but got an error.

python3 -m pip install . produces: /usr/bin/python3: No module named pip

I'll try again after the dist-upgrade completes and let you know if anything changes.

nickenzi commented 1 month ago

Ok, making progress. I installed the python3-pip package from the repository. Now the install spits this back:

error: externally-managed-environment

× This environment is externally managed ╰─> To install Python packages system-wide, try apt install python3-xyz, where xyz is the package you are trying to install.

If you wish to install a non-Debian-packaged Python package,
create a virtual environment using python3 -m venv path/to/venv.
Then use path/to/venv/bin/python and path/to/venv/bin/pip. Make
sure you have python3-full installed.

If you wish to install a non-Debian packaged Python application,
it may be easiest to use pipx install xyz, which will manage a
virtual environment for you. Make sure you have pipx installed.

See /usr/share/doc/python3.12/README.venv for more information.

note: If you believe this is a mistake, please contact your Python installation or OS distribution provider. You can override this, at the risk of breaking your Python installation or OS, by passing --break-system-packages. hint: See PEP 668 for the detailed specification.

I installed the pipx package from the repository, then ran: sudo pipx install . which then prompted me to run sudo pipx ensurepath

Now, when I try to start pygopherd with the systemd service I had created for the previous version, I get this:

2024-09-11T13:11:00.557031-04:00 hoosac systemd[1]: Started pygopherd.service - Pygopherd Server. 2024-09-11T13:11:00.726551-04:00 hoosac pygopherd[5035]: /usr/local/bin/pygopherd:4: DeprecationWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html 2024-09-11T13:11:00.727292-04:00 hoosac pygopherd[5035]: import('pkg_resources').run_script('pygopherd==3.0.1', 'pygopherd') 2024-09-11T13:11:00.887394-04:00 hoosac pygopherd[5035]: Traceback (most recent call last): 2024-09-11T13:11:00.887469-04:00 hoosac pygopherd[5035]: File "/usr/local/bin/pygopherd", line 4, in 2024-09-11T13:11:00.887503-04:00 hoosac pygopherd[5035]: import('pkg_resources').run_script('pygopherd==3.0.1', 'pygopherd') 2024-09-11T13:11:00.887534-04:00 hoosac pygopherd[5035]: ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 2024-09-11T13:11:00.887585-04:00 hoosac pygopherd[5035]: File "/usr/lib/python3/dist-packages/pkg_resources/init.py", line 3327, in 2024-09-11T13:11:00.888431-04:00 hoosac pygopherd[5035]: @_call_aside 2024-09-11T13:11:00.888547-04:00 hoosac pygopherd[5035]: ^^^^^^^^^^^ 2024-09-11T13:11:00.888587-04:00 hoosac pygopherd[5035]: File "/usr/lib/python3/dist-packages/pkg_resources/init.py", line 3302, in _call_aside 2024-09-11T13:11:00.889390-04:00 hoosac pygopherd[5035]: f(*args, **kwargs) 2024-09-11T13:11:00.889440-04:00 hoosac pygopherd[5035]: File "/usr/lib/python3/dist-packages/pkg_resources/init.py", line 3340, in _initialize_master_working_set 2024-09-11T13:11:00.890362-04:00 hoosac pygopherd[5035]: working_set = WorkingSet._build_master() 2024-09-11T13:11:00.890412-04:00 hoosac pygopherd[5035]: ^^^^^^^^^^^^^^^^^^^^^^^^^^ 2024-09-11T13:11:00.890446-04:00 hoosac pygopherd[5035]: File "/usr/lib/python3/dist-packages/pkg_resources/init.py", line 631, in _build_master 2024-09-11T13:11:00.890595-04:00 hoosac pygopherd[5035]: ws.require(requires) 2024-09-11T13:11:00.890695-04:00 hoosac pygopherd[5035]: File "/usr/lib/python3/dist-packages/pkg_resources/init.py", line 968, in require 2024-09-11T13:11:00.891007-04:00 hoosac pygopherd[5035]: needed = self.resolve(parse_requirements(requirements)) 2024-09-11T13:11:00.891057-04:00 hoosac pygopherd[5035]: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 2024-09-11T13:11:00.891118-04:00 hoosac pygopherd[5035]: File "/usr/lib/python3/dist-packages/pkg_resources/init.py", line 829, in resolve 2024-09-11T13:11:00.891318-04:00 hoosac pygopherd[5035]: dist = self._resolve_dist( 2024-09-11T13:11:00.891367-04:00 hoosac pygopherd[5035]: ^^^^^^^^^^^^^^^^^^^ 2024-09-11T13:11:00.891399-04:00 hoosac pygopherd[5035]: File "/usr/lib/python3/dist-packages/pkg_resources/init.py", line 870, in _resolve_dist 2024-09-11T13:11:00.891701-04:00 hoosac pygopherd[5035]: raise DistributionNotFound(req, requirers) 2024-09-11T13:11:00.891752-04:00 hoosac pygopherd[5035]: pkg_resources.DistributionNotFound: The 'pygopherd==3.0.1' distribution was not found and is required by the application 2024-09-11T13:11:00.924507-04:00 hoosac systemd[1]: pygopherd.service: Main process exited, code=exited, status=1/FAILURE 2024-09-11T13:11:00.925002-04:00 hoosac systemd[1]: pygopherd.service: Failed with result 'exit-code'.

It's almost as if it can't find the version of pygopherd that pipx installed and I'm not sure how to force it to do so. I know it's mentioned a .deb version is kicking around somewhere. Would it be possible to point me to it so I can try cramming it into Linux Mint? Or, do you have any ideas on how to force it to use the pipx-installed version?

michael-lazar commented 1 month ago

Here's how I install and run inside of a virtual environment for local development and testing

python3.12 -m venv venv
source venv/bin/activate
pip install .
pygopherd conf/local.conf

The debian package is here, if you're on a debian-based distro you can run apt install pygopherd which is probably the easiest way to get up and running:

https://packages.debian.org/sid/pygopherd

nickenzi commented 1 month ago

I installed the Debian package on Mint 22 and things got a little bit better:

2024-09-11T13:56:32.056498-04:00 hoosac systemd[1]: Started pygopherd.service - Pygopherd Server. 2024-09-11T13:56:32.239024-04:00 hoosac pygopherd[5904]: /usr/local/bin/pygopherd:4: DeprecationWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html 2024-09-11T13:56:32.240339-04:00 hoosac pygopherd[5904]: import('pkg_resources').run_script('pygopherd==3.0.1', 'pygopherd') 2024-09-11T13:56:32.382559-04:00 hoosac pygopherd[5904]: Traceback (most recent call last): 2024-09-11T13:56:32.382633-04:00 hoosac pygopherd[5904]: File "/usr/local/bin/pygopherd", line 4, in 2024-09-11T13:56:32.382708-04:00 hoosac pygopherd[5904]: import('pkg_resources').run_script('pygopherd==3.0.1', 'pygopherd') 2024-09-11T13:56:32.382745-04:00 hoosac pygopherd[5904]: File "/usr/lib/python3/dist-packages/pkg_resources/init.py", line 722, in run_script 2024-09-11T13:56:32.382992-04:00 hoosac pygopherd[5904]: self.require(requires)[0].run_script(script_name, ns) 2024-09-11T13:56:32.383126-04:00 hoosac pygopherd[5904]: File "/usr/lib/python3/dist-packages/pkg_resources/init.py", line 1548, in run_script 2024-09-11T13:56:32.383502-04:00 hoosac pygopherd[5904]: raise ResolutionError( 2024-09-11T13:56:32.383588-04:00 hoosac pygopherd[5904]: pkg_resources.ResolutionError: Script 'scripts/pygopherd' not found in metadata at '/usr/lib/python3/dist-packages/pygopherd-3.0.1.egg-info' 2024-09-11T13:56:32.416996-04:00 hoosac systemd[1]: pygopherd.service: Main process exited, code=exited, status=1/FAILURE 2024-09-11T13:56:32.417176-04:00 hoosac systemd[1]: pygopherd.service: Failed with result 'exit-code'.

I then tried the sudo python3 setup.py install method from the previous versions and now I'm back up and running. Not sure if I've just made a mess of my system or if it's because I'm trying to run it as a systemd service, or if there's an easy way to do systemd + venv.