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

caption indices not available in pip3 verision #15

Closed
ghost opened this issue Nov 17, 2018 · 18 comments
Closed

caption indices not available in pip3 verision #15

ghost opened this issue Nov 17, 2018 · 18 comments
Labels
bug Something isn't working

Comments

@ghost
Copy link

ghost commented Nov 17, 2018

When pip3 installing cutie, the version of cutie that is installed is cutie-0.2.1

The select function in this version does not have an argument for caption indices:

def select(
        options: List[str],
        deselected_prefix: str = '\033[1m[ ]\033[0m ',
        selected_prefix: str = '\033[1m[\033[32;1mx\033[0;1m]\033[0m ',
        selected_index: int = 0) -> int:
    """Select an option from a list.

    Args:
        options (List[str]): The options to select from.
        deselected_prefix (str, optional): Prefix for deselected option ([ ]).
        selected_prefix (str, optional): Prefix for selected option ([x]).
        selected_index (int, optional): The index to be selected at first.

    Returns:
        int: The index that has been selected.
    """
    print('\n' * (len(options) - 1))
    while 1:
        print(f'\033[{len(options) + 1}A')
        for i, option in enumerate(options):
            print('\033[K{}{}'.format(
                selected_prefix if i == selected_index else deselected_prefix,
                option))
        keypress = readchar.readkey()
        if keypress == readchar.key.UP:
            selected_index = max(selected_index - 1, 0)
        elif keypress == readchar.key.DOWN:
            selected_index = min(selected_index + 1, len(options) - 1)
        else:
            break
    return selected_index

Are there plans to distribute the version of cutie that has the features as the example in the readme? I like the caption indices feature but currently do not have access to it.

@Kamik423 Kamik423 added the bug Something isn't working label Nov 17, 2018
@Kamik423
Copy link
Owner

Kamik423 commented Nov 17, 2018

Thanks for the report!

I am pretty sure I found it: it was due to me not cleaning my local build correctly. I switched from a package structure (single file in directory: cutie/__init__.py) to a module (just cutie.py). The distribution now contained both a package and a module, in which case python opted for the (older) package. I cleaned the build folder correctly, which removed the deprecated package and reuploaded it as cutie-0.2.2.

TL;DR

It should be fixed now. Can you confirm?

@ghost
Copy link
Author

ghost commented Nov 17, 2018

I do not believe this fixed it -- though I am able to install cutie 2.2, I still receive this error, and the function appears unchanged from the copy and paste above.

Traceback (most recent call last):
  File "app.py", line 59, in <module>
    ProjectSelect()
  File "app.py", line 40, in __init__
    command(self)
  File "app.py", line 54, in EditExisting
    cutie.select(options, caption_indices=caption_indices)
TypeError: select() got an unexpected keyword argument 'caption_indices'

@Kamik423
Copy link
Owner

I am so sorry this is such a huge inconvenience for you!

Could you please do:

pip3 install --upgrade --no-cache -I cutie

And paste the output from pip here? (If it still does not work then)

@ghost
Copy link
Author

ghost commented Nov 17, 2018

No sweat @Kamik423 - happy to help:


kdggavkc@far-madding:~/Code/jungle/ritual$ pip3 install --upgrade --no-cache -I cutie
Collecting cutie
  Downloading https://files.pythonhosted.org/packages/79/1d/f8389619189b3de32f66be40cc7d17d6d2c06e35bbd21f6869120bd912b3/cutie-0.2.2-py3-none-any.whl
Collecting readchar (from cutie)
  Downloading https://files.pythonhosted.org/packages/ef/f3/50cc9199733bf91f3c140150752a6430d8b785f9d22a31dcae721edb0b9a/readchar-2.0.1-py3-none-any.whl
Collecting colorama (from cutie)
  Downloading https://files.pythonhosted.org/packages/0a/93/6e8289231675d561d476d656c2ee3a868c1cca207e16c118d4503b25e2bf/colorama-0.4.0-py2.py3-none-any.whl
Installing collected packages: readchar, colorama, cutie
Successfully installed colorama-0.4.0 cutie-0.2.2 readchar-2.0.1

@Kamik423
Copy link
Owner

The file downloaded for cutie does not contain the erroneous files. Does it still happen? Or did this latest install fix it?

@ghost
Copy link
Author

ghost commented Nov 17, 2018

From where I stand, the select function is unchanged from the original post. You are unable to replicate?

EDIT - corrected "statement" to "function"

@ghost
Copy link
Author

ghost commented Nov 17, 2018

The cutie.py file in this repo is what was bdist_wheeled and twined?

@Kamik423
Copy link
Owner

No. When I downloaded PyPI version 2.1 it was broken the way you described. After upgrading to 2.2 it was fixed.

Can you do

pip3 show cutie

and take a look at the directory listed as Location (in my case /usr/local/lib/python3.7/site-packages) and tell me what things in there are named cutie (directories / .py files / ...).

Are you using virtual environments?


Concerning the question:

python setup.py sdist bdist_wheel
twine upload dist/*

@ghost
Copy link
Author

ghost commented Nov 17, 2018

kdggavkc@far-madding:~/Code/jungle$ pip3 show cutie
Name: cutie
Version: 0.2.2
Summary: Commandline User Tools for Input Easification
Home-page: https://github.com/kamik423/cutie
Author: Hans
Author-email: [email protected]
License: MIT
Location: /home/kdggavkc/.local/lib/python3.6/site-packages
Requires: colorama, readchar

Should I be on Python 3.7?

EDIT - 1 sec to look inside

@Kamik423
Copy link
Owner

Python 3.6 should work just fine. I am on 3.7.

Can you go to /home/kdggavkc/.local/lib/python3.6/site-packages and search for cutie?

@ghost
Copy link
Author

ghost commented Nov 17, 2018

Yes - in that location there are:

cutie (directory)
cutie.py (this contains the version of select I would like)
cutie-0.2.1.dist-info (directory)
cutie-0.2.2.dist-info (directory

@ghost
Copy link
Author

ghost commented Nov 17, 2018

@Kamik423 I have deleted all of those and ran your original suggested statement, and that has worked. Apologies for the difficulty.

@ghost ghost closed this as completed Nov 17, 2018
@ghost
Copy link
Author

ghost commented Nov 17, 2018

But thank you for the help

@Kamik423
Copy link
Owner

Kamik423 commented Nov 17, 2018

Digging around a bit, I found this.
When upgrading cutie the from 0.2.1 to 0.2.2 did you use the -I or --ignore-installed option?

I want to prevent this for other users.

Steps to reproduce

pip3 uninstall cutie
pip3 install cutie==0.2.1
# Both package and module found, issue occurs
pip3 install --upgrade cutie
# Package removed, issue fixed
# When instead using
pip3 install --upgrade cutie -I
# The issue still occurs

@ghost
Copy link
Author

ghost commented Nov 17, 2018

@Kamik423 I did not pass those flags

@Kamik423
Copy link
Owner

This is weird. But the issue is resolved now and I know what to do, should it happen to other users.

Thank you for your help!

@ghost
Copy link
Author

ghost commented Nov 17, 2018

I suspect it could be that my import was prioritizing a different build than what I had installed, even though I had uninstalled the older version.

@Kamik423
Copy link
Owner

A part of it is, that it is somehow possible to upgrade to 0.2.2 without deleting the old package, because it only contains a module. This only happens for me with the -I option. With the "regular" upgrade it gets removed correctly for me.

This issue was closed.
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

1 participant