Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python pip module is broken #2803

Open
mttkay opened this issue Nov 8, 2024 · 5 comments
Open

Python pip module is broken #2803

mttkay opened this issue Nov 8, 2024 · 5 comments
Labels
bug Something isn't working

Comments

@mttkay
Copy link

mttkay commented Nov 8, 2024

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 mttkay added the bug Something isn't working label Nov 8, 2024
@mttkay
Copy link
Author

mttkay commented Nov 8, 2024

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
Copy link
Author

mttkay commented Nov 8, 2024

Could this be related to this commit? 7b27e50

It references this issue: #2484

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

@mttkay
Copy link
Author

mttkay commented Nov 8, 2024

Think I found it:

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
Copy link
Author

mttkay commented Nov 9, 2024

Looks like a duplicate of #2624

@dcontiveros
Copy link

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants