vonshednob / pter

Manage your todo.txt in a commandline user interface (TUI)
https://vonshednob.cc/pter/
MIT License
102 stars 6 forks source link

Can't build tarballs from codeberg #41

Closed andrei-a-papou closed 5 months ago

andrei-a-papou commented 6 months ago

I can't build https://codeberg.org/vonshednob/pter/archive/v3.15.2.tar.gz, the error is: error: can't copy 'man/pter.1': doesn't exist or not a regular file

Here's how I'm building: python3 ./setup.py build && python3 ./setup.py install

Same thing happened with https://codeberg.org/vonshednob/pter/archive/v3.15.1.tar.gz, but interestingly I just downloaded https://vonshednob.cc/releases/pter-3.15.1.tar.gz and there was no problem. Apparently, the tarballs at codeberg and https://vonshednob.cc are different.

There's no tarball for 3.15.2 at https://vonshednob.cc, so now I'm stuck :) Can't install via pip as I need to patch the tarball first with my own set of patches.

andrei-a-papou commented 6 months ago

OK, seems like apt install python3-docutils works around the issue, but shouldn't docutils be fetched by setup.py somehow and/or listed as deps? And why doesn't the issue occur with https://vonshednob.cc/releases/?

vonshednob commented 6 months ago

The tarball from my website has been produced with python -m build, so it’s not just the source code, but contains the generated man page, too.

I was rather reluctant to add docutils as a build-time dependency -- the pter package on pypi and on the website, as well as the one in AUR (all the same file, from python -m build) "just work". So adding docutils as a build-time dependency would be an unnecessary step. :thinking:

How about adding a Development section to the README and add that type of information there?

andrei-a-papou commented 6 months ago

How about adding a Development section to the README and add that type of information there?

IMO, that would be fine. For the record, this is what I use to build pter inside a Docker image (based on Debian 12/Bookworm):

apt-get install --no-install-recommends -y \
    python3.11-minimal python3-setuptools python3-docutils ca-certificates

cd /path/to/pter-source-dir && \
    python3 ./setup.py build && python3 ./setup.py install

The package ca-certificates is also needed on a minimal Debian install -- without it, no deps like pytodotxt can be downloaded.

vonshednob commented 6 months ago

Interesting, but I remember from my own experience with … uhm, something, that ca-certificates surprisingly is not installed by default. But I guess it makes sense for containers, similar to not installing man pages.

andrei-a-papou commented 6 months ago

But I guess it makes sense for containers, similar to not installing man pages.

Yeah, this is inside the debian:bookworm-slim image. I guess they save space by not installing ca-certificates.

How about adding a Development section to the README and add that type of information there?

I've played with several build options recently and yes, adding instructions on how to build from both kinds of tarballs would be much appreciated.

Right now I can build from both kinds of tarballs using setup.py, but it turns out calling it directly is now deprecated (warnings get printed out).

Building using pip from a source directory fails for me: a man page is not found even after installing docutils. This is with 3.15.2, codeberg tarball. So I couldn't convert to using pip, unfortunately.

Running pip3 install pter works, but then it's hard or very awkward to apply my patches (of which I have more :))

So I'm stuck with using the deprecated setup.py, which works across the board -- for now. It's by no means a blocker, just something that will be hopefully addressed in the future.

vonshednob commented 6 months ago

I think the current thing to do is run python -m build and python -m install. Totally not a circular dependency when you need to install the install package first :upside_down_face:

andrei-a-papou commented 6 months ago

OK, I've tried that, it appears to print the same warnings as pip:

warning: no files found matching '*.html' under directory 'pter'                                                                                                                               
warning: no files found matching '*' under directory 'man' 

Then errors out:

error: can't copy 'man/pter.1': doesn't exist or not a regular file

This is with codeberg tarball, v3.15.2. Package python3-docutils installed via apt-get.

(sigh) Back to setup.py :)

vonshednob commented 6 months ago

That's odd. With docutils it should be able to build the man page during python -m build :thinking: maybe there's another dependency that I forgot

vonshednob commented 5 months ago

Okay, I give up for now -- apparently it's far from straight forward to declare a build-time dependency in python. I’ll try to make it not burst into flames when python is being build without having the docutils installed: e12dc7e0. Let me know if this worked.

andrei-a-papou commented 5 months ago

Oh man, now I'm getting error: can't copy 'man/pter.1': doesn't exist or not a regular file even when building from git.

This happens when running python3 ./setup.py build && python3 ./setup.py install

What commands do you issue to build pter from git?

vonshednob commented 5 months ago

Curious. I just clean-built in an empty virtualenv with that new configuration and it worked. At what step does it crash for you? python setup.py build or python setup.py install?

Edit: right, container… based on it trying to copy, it’s probably the install step.

vonshednob commented 5 months ago

Could you try to use pip install . instead of python setup.py?

andrei-a-papou commented 5 months ago

I'm sorry, the error is slightly different, it's in regard to qpter, not pter. Sorry for the confusion.

Here's the actual error: error: can't copy 'man/pter/qpter.1': doesn't exist or not a regular file

So the install step still fails, but the error is different from the one in https://github.com/vonshednob/pter/issues/41#issuecomment-1953218088

andrei-a-papou commented 5 months ago

Could you try to use pip install . instead of python setup.py?

Yes, the following worked for me in a Docker container:

apt-get install --no-install-recommends -y \
    python3.11-minimal python3-pip python3-docutils ca-certificates
cd /tmp/pter && pip3 install --break-system-packages . && find /tmp/pter -delete

(For speed of hacking this Dockerfile, I didn't use a virtuaelnv nor do I care for one in an isolated container.)

UPD: apt install python3-docutils doesn't seem to be necessary for a successful build via pip.

vonshednob commented 5 months ago

I'm sorry, the error is slightly different, it's in regard to qpter, not pter. Sorry for the confusion.

No worries, I also missed that.

Here's the actual error: error: can't copy 'man/pter/qpter.1': doesn't exist or not a regular file

Yeah, that was me fumbling the patch. There really is no man/pter/qpter.1 file, but a man/qpter.1 file. :facepalm:

Anyway, should be fixed with 12ea984a

andrei-a-papou commented 5 months ago

Now it builds fine via python3 ./setup.py build && python3 ./setup.py install.

But there is a bunch of warnings (they don't appear when building via pip):

doc/pter.config.rst:213: (WARNING/2) Inline literal start-string without end-string.                                                                                                           
doc/pter.config.rst:213: (WARNING/2) Inline literal start-string without end-string.                                                                                                           
doc/pter.config.rst:213: (WARNING/2) Inline literal start-string without end-string.                                                                                                           
doc/pter.config.rst:213: (WARNING/2) Inline literal start-string without end-string. 

The warnings are for the build stage. There are other warnings but they are related to the deprecated use of setup.py.

UPDATE: There are some other warnings (don't know if they are serious), I wrapped them in asterisks in context:

reating build/bdist.linux-x86_64/egg/EGG-INFO
copying pter.egg-info/PKG-INFO -> build/bdist.linux-x86_64/egg/EGG-INFO
copying pter.egg-info/SOURCES.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
copying pter.egg-info/dependency_links.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
copying pter.egg-info/entry_points.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
copying pter.egg-info/requires.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
copying pter.egg-info/top_level.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
**zip_safe flag not set; analyzing archive contents...**
**pter.__pycache__.common.cpython-311: module references __file__**
creating dist
creating 'dist/pter-3.15.2.dev0-py3.11.egg' and adding 'build/bdist.linux-x86_64/egg' to it
vonshednob commented 5 months ago

The line 213 warning is … well, a speciality of trying to express "+-@" (the last character is a space) in reStructuredText. I’ll verify this later. Thanks for the heads-up!

I guess the big win is that it builds and installs now.

andrei-a-papou commented 5 months ago

I guess the big win is that it builds and installs now.

Absolutely!

vonshednob commented 5 months ago

I think I might have fixed the warning. D'you think this issue can be closed?

andrei-a-papou commented 5 months ago

Tested with both setup.py and with pip3, you certainly did!

D'you think this issue can be closed?

Sure, it builds just fine now.

andrei-a-papou commented 5 months ago

@vonshednob By the way, will you keep uploading tarballs to https://vonshednob.cc/pter/releases.html? I'm asking since one can build man pages form https://vonshednob.cc releases, which doesn't happen with tarballs from codeberg. And I sometimes need to do man pter :)

vonshednob commented 5 months ago

Absolutely! Documentation on the terminal is very much required in my opinion. Just haven't released 3.16 yet.