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

Trouble following packaging libraries tutorial #170

Closed
DerekYu177 opened this issue Jun 24, 2018 · 18 comments
Closed

Trouble following packaging libraries tutorial #170

DerekYu177 opened this issue Jun 24, 2018 · 18 comments

Comments

@DerekYu177
Copy link

Hi there! First time trying to upload my package.

I've followed the guide for uploading my packages from within my folder, validating that the dist packages exist:

➜  dist git:(master) ls
dynamictableprint-0.0.1-py3-none-any.whl dynamictableprint-0.0.1.tar.gz

I then followed the publishing instructions onto the test pypi platform:

python3 -m pip install --user --upgrade twine
twine upload --repository-url https://test.pypi.org/legacy/ dist/*

Where both were uploaded successfully.
I first installed this on my system, and then installed in a conda environemnt
Being a conda user, I created a conda environment, installed pip into the environment, and attempted to pull down the package with the following command:

image

(sorry, tmux didn't let me copy the second line for some reason)

@DerekYu177
Copy link
Author

I see that the line says from versions: which made me think that the setup.py was not set correctly, but I checked and under versions: it is "0.0.1", so I'm confused as to why I cannot install my own package.

@pradyunsg
Copy link
Member

pip is unable to find a dependency of you package (specifically tableprint). Perhaps it's not available on testpypi

@DerekYu177
Copy link
Author

Ah, perhaps that is it. Is there a way to know for sure? I did not write the dependency, so I'm not sure how to proceed to isolate if that is the issue.

@pradyunsg
Copy link
Member

Instead of trying to install your package, try installing the dependency via testpypi. If that fails, that's what causing the issue. (change the last argument in the pip install call to be the name of the dependency)

Indeed, the dependency is not available on testpypi so, I'd expect that to fail. It is available on PyPI. That's basically what's happening here. Packages available on testpypi can differ from packages available on PyPI.

As a workaround, you can try install the dependency first via a plain pip install package and then check if your package is installable. Once you upload to PyPI, it'll just work.

(on mobile, can't type out the commands to use)

@theacodes I think that the guide should cover this, noting that the packages available on testpypi would be different from the ones on PyPI and providing advice on how to work around that.

@DerekYu177
Copy link
Author

I'll leave this open until I can confirm that the solution works (about to board a plane)

@theacodes
Copy link
Member

Agreed, can you file a bug over there, @pradyunsg?

@pradyunsg
Copy link
Member

pypa/packaging.python.org#528

Done. :)

@DerekYu177
Copy link
Author

I've done the following without success following the conventions in:
https://conda.io/docs/user-guide/tasks/manage-environments.html#using-pip-in-an-environment
and
pypa/packaging.python.org#528

conda create --name test2 python=3.6
conda install -n test2 pip 
source activate test2
python3 -m pip install --no-deps --index-url https://test.pypi.org/simple dynamictableprint
pip install tableprint
python:
    import dynamictableprint
    ModuleNotFoundError: no module named 'dynamictableprint'

There was an error when installing tableprint that twine and requests-toolbelt required requests. I don't think that it is an error but I pip installed them anyway. When I reran the command
pip install --no-deps --index-url https://test.pypi.org/simple dynamictableprint I got the following message:
image
But running python3 and then calling import dynamictableprint still results in error. Importing tableprint is OK tho.

Checking my site-packages, it looks like the dynamictableprint-0.0.1.dist-info has been added, but I don't see the dynamictableprint module actually imported. To me, this feels like something was missing when I uploaded my dist/*

Any thoughts/solutions?

@DerekYu177
Copy link
Author

@pradyunsg @theacodes so... I thought it would work on PyPI, but it didn't so... pip install dynamictableprint is definitely broken

@pradyunsg
Copy link
Member

Does the following work for you?

python3 -m pip install --no-deps --index-url https://test.pypi.org/simple dynamictableprint
python3 -m pip install dynamictableprint

pip install dynamictableprint is definitely broken

That's odd. It's working for me:

Collecting dynamictableprint
  Downloading https://files.pythonhosted.org/packages/b2/8e/2933ebb90ecaae0c68bcc43bc6c94248c7a90ab9ce1e61642063597200f0/dynamictableprint-0.0.1-py3-none-any.whl
Collecting tableprint (from dynamictableprint)
  Downloading https://files.pythonhosted.org/packages/b4/22/237af092c15d69b93857cb16bf180a650f51d07446a6119f1496c73d419c/tableprint-0.7.1.tar.gz
Requirement already satisfied: numpy in /Users/pradyunsg/.venvwrap/venvs/pip/lib/python3.6/site-packages (from tableprint->dynamictableprint) (1.14.5)
Requirement already satisfied: six in /Users/pradyunsg/.venvwrap/venvs/pip/lib/python3.6/site-packages (from tableprint->dynamictableprint) (1.11.0)
Collecting future (from tableprint->dynamictableprint)
  Downloading https://files.pythonhosted.org/packages/00/2b/8d082ddfed935f3608cc61140df6dcbf0edea1bc3ab52fb6c29ae3e81e85/future-0.16.0.tar.gz (824kB)
    100% |████████████████████████████████| 829kB 4.1MB/s
Collecting wcwidth (from tableprint->dynamictableprint)
  Downloading https://files.pythonhosted.org/packages/7e/9f/526a6947247599b084ee5232e4f9190a38f398d7300d866af3ab571a5bfe/wcwidth-0.1.7-py2.py3-none-any.whl
Building wheels for collected packages: tableprint, future
  Running setup.py bdist_wheel for tableprint ... done
  Stored in directory: /Users/pradyunsg/Library/Caches/pip/wheels/f3/85/50/13fdeeb11b9453c850be1b5b964471e05d5b9454d8c3c56e76
  Running setup.py bdist_wheel for future ... done
  Stored in directory: /Users/pradyunsg/Library/Caches/pip/wheels/bf/c9/a3/c538d90ef17cf7823fa51fc701a7a7a910a80f6a405bf15b1a
Successfully built tableprint future
Installing collected packages: future, wcwidth, tableprint, dynamictableprint
Successfully installed dynamictableprint-0.0.1 future-0.16.0 tableprint-0.7.1 wcwidth-0.1.7

@pradyunsg
Copy link
Member

Oh!

Looking at https://github.com/DerekYu177/dynamictableprint/blob/master/setup.py#L136, you'd want to use packages not py_modules since you have a package called dynamictableprint; it's not a single module called dynamictableprint.py.

@DerekYu177
Copy link
Author

Ohhh, using packages=['dynamictableprint'] instead of py_modules=["dynamictableprint"] should work?

@DerekYu177
Copy link
Author

DerekYu177 commented Jun 28, 2018

Instead I could uncomment and use https://github.com/DerekYu177/dynamictableprint/blob/master/setup.py#L135, what do you think? @pradyunsg

Then I just rerun the python3 setup.py sdist bdist_wheel and then twine upload dist/* and all good?

@pradyunsg
Copy link
Member

Both would work. The latter is more portable across different packages, allowing you to copy-paste your setup.py across packages.

@DerekYu177
Copy link
Author

DerekYu177 commented Jun 28, 2018

Oh, I'm getting a 400 (File already exists) when I try to upload, is there a way to do this safely? I suppose I could nuke the release and start again?

Oh, maybe I update the version and re-upload?

Okay, the latter doesn't work and PyPI frowns against the former.

Nope, I got it, I removed the previous versions. All good 😄

@DerekYu177
Copy link
Author

Closing this since we figured it out! Lots of love to all of you at pypa! ❤️

@pradyunsg
Copy link
Member

Oh, I'm getting a 400 (File already exists) when I try to upload, is there a way to do this safely? I suppose I could nuke the release and start again?

Well, not exactly. PyPI doesn't allow you to re-upload a release file with the same name. For fixing distribution related issues, you can create a post release though by adding a ".postN" (N is a number) to the version: https://www.python.org/dev/peps/pep-0440/#post-releases

@DerekYu177
Copy link
Author

Yeah I didn't realize that running setup.py created additional sources in dist/ instead of replacing the ones currently existing. that's why when I pushed to PyPI it said file exists, because the v0.0.1 files did exist in my dist/. It should probably be clarified somewhere

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants