notcurses icon indicating copy to clipboard operation
notcurses copied to clipboard

Python pip module is broken

Open mttkay opened this issue 1 year ago • 6 comments

On macOS Sonoma 14.7 using homebrew for package management. Python 3.12.3 (using asdf shim).

Expected behavior

Running the Python sample apps should work using the notcurses pip module available here: https://pypi.org/project/notcurses/

For example:

from notcurses import notcurses_version

print(notcurses_version())

See https://github.com/dankamongmen/notcurses/blob/fb9b326e1877831af6bffcd79138baf161965ed8/python/examples/000-print-version.py

Actual behavior

Program fails with:

python main-notcurses.py

Traceback (most recent call last):
  File "/Users/mk/Projects/mine/texterminate/main-notcurses.py", line 3, in <module>
    print(notcurses_version())
          ^^^^^^^^^^^^^^^^^
NameError: name 'notcurses_version' is not defined

I also found that this file is completely empty, which seems wrong?

cat /Users/mk/.asdf/installs/python/3.12.3/lib/python3.12/site-packages/notcurses/__init__.py

This file is not empty in the project repo: https://github.com/dankamongmen/notcurses/blob/7e1a5d48e728e8e8e3ce6dc47fdb37c7a7d169bf/python/notcurses/init.py

mttkay avatar Nov 08 '24 13:11 mttkay

There is something not quite right here. The pip package for v3.0.9 has the following contents:

ll src/notcurses/
total 24
 0 -rw-r--r--@ 1 mk  staff     0B Nov 28  2021 __init__.py
 8 -rw-r--r--@ 1 mk  staff   2.5K Dec  8  2021 build_notcurses.py
16 -rwxr-xr-x@ 1 mk  staff   5.2K Dec  8  2021 notcurses.py*

Note the zero bytes module file. Moreover, notcurses.py has only 184 LOC:

wc -l src/notcurses/notcurses.py
     184 src/notcurses/notcurses.py

When I check out v3.0.9 on this repository, I see the following instead:

g co v3.0.9
HEAD is now at 040ff99fb v3.0.9
ll python/notcurses/
total 376
  8 -rw-r--r--  1 mk  staff   3.2K Nov  8 10:15 __init__.py
 48 -rw-r--r--  1 mk  staff    23K Nov  8 10:15 channels.c
 48 -rw-r--r--  1 mk  staff    22K Nov  8 10:15 context.c
  8 -rw-r--r--  1 mk  staff   3.5K Nov  8 10:15 functions.c
 16 -rw-r--r--  1 mk  staff   4.4K Nov  8 10:15 main.c
  8 -rw-r--r--  1 mk  staff   1.9K Nov  8 10:15 misc.c
 16 -rw-r--r--  1 mk  staff   7.9K Nov  8 10:15 notcurses-python.h
 88 -rw-r--r--  1 mk  staff    41K Nov  8 10:15 notcurses.py
136 -rw-r--r--  1 mk  staff    65K Nov  8 10:15 plane.c
  0 -rw-r--r--  1 mk  staff     0B Nov  8 10:15 py.typed

Note that the module is now 3.2K

and:

wc -l python/notcurses/notcurses.py
    1338 python/notcurses/notcurses.py

So it seems that the pip package is missing a substantial amount of code. What am I missing here? 🤔

mttkay avatar Nov 08 '24 19:11 mttkay

Could this be related to this commit? 7b27e508cbb75f722e4c21000de413bf4dbcac82

It references this issue: https://github.com/dankamongmen/notcurses/issues/2484

How and where is the pip package assembled that is published at https://pypi.org/project/notcurses/?

mttkay avatar Nov 08 '24 20:11 mttkay

Think I found it: https://github.com/dankamongmen/notcurses/blob/bfb65c252e0764796e379595ad6e089dcb573ffe/python/setup.py#L39

FWIW, this works fine for me:

CFLAGS=-I/opt/homebrew/include python setup.py build

Why was this build step disabled? 🤔

I think for now I'll just vendor this code and the object file. Would be nice to have this available again as a pip module though.

mttkay avatar Nov 08 '24 20:11 mttkay

Looks like a duplicate of https://github.com/dankamongmen/notcurses/issues/2624

mttkay avatar Nov 09 '24 08:11 mttkay

@mttkay Just to add onto your observations, I also wanted python bindings for latest release. Pip gave me the same issues you referenced in #2484 .

I did the following:

# install via brew
brew install notcurses

# grabbed master from repo

# Built python import
cd REPO/python
CFLAGS=-I/usr/local/Cellar/notcurses/3.0.11/include/notcurses pip install .

This got me a similar line count:

wc -l ~/.pyenv/versions/3.13.0/lib/python3.13/site-packages/notcurses/notcurses.py
    1338  ~/.pyenv/versions/3.13.0/lib/python3.13/site-packages/notcurses/notcurses.py

Let me know how I can help getting this into PyPI.

dcontiveros avatar Dec 06 '24 17:12 dcontiveros

i just got my pypi account back open. let me look into this. sorry about the delay!

dankamongmen avatar Jan 22 '25 02:01 dankamongmen