1

I know there's a similar question like this out here but after trying their solution, it still hasn't worked for me.

Project Structure:

README.md
LICENSE
setup.py
rolimons/
└── __init__.py
└── users.py
└── items.py
└── client.py

My setup file contains the following:

from setuptools import find_packages, setup

with open("README.md", encoding="utf-8") as f:
    readme = f.read()

setup(
    name="rolimons",
    version="1.2.5",
    author="walker",
    description="Rolimons API Wrapper",
    long_description=readme,
    long_description_content_type="text/markdown",
    packages=['rolimons'],
    url="https://github.com/wa1ker38552/Rolimons-PY",
    install_requires=["requests", "bs4", "requests_html"],
    python_requires=">=3.7",
)

I have published the package after following these steps:
Change version in setup.py
python setup.py sdist
twine upload --skip-existing dist/*

After this, I go to a different project and run pip install rolimons --upgrade and after running, it gives an import error stating that it can't find the module.

What am I doing wrong?

sinoroc
  • 18,409
  • 2
  • 39
  • 70
walker
  • 444
  • 2
  • 12
  • I recommend you edit your question to show the code that does the import as well as the text of the error message. – sinoroc Sep 07 '22 at 20:11
  • I think I found the issue: your project contains a `pyproject.toml` file which declares Poetry as the build back-end. The `pyproject.toml` takes preecedence over `setup.py`, so the `setup.py` is completely ignored. And the Poetry configuration in `pyproject.toml` is obviously incorrect. You probably should delete the `pyproject.toml` file completely since it seems that you do not actually intend it to be used. – sinoroc Sep 07 '22 at 20:16
  • @sinoroc, it's literally `import rolimons` that's it – walker Sep 07 '22 at 20:24
  • Also, when I use `pip install rolimons`, it doesn't update the package. The package is on 1.2.7 while the version I have shows 1.1.3 even though I've used `pip install rolimons --upgrade` multiple times already – walker Sep 07 '22 at 20:25
  • Do you switch to a different virtual environment when you install? If the upgrade does not work, then the issue with the import seems secondary. You should get the upgrade to work first. Maybe try to run `python -m pip uninstall rolimons` a couple of times first until `python -m pip list` does not show it anymore. – sinoroc Sep 07 '22 at 20:30
  • I found the issue with the old packages. Everytime I install, it gives an error so pip moves on to the next version until 1.1.3 which is the last version that works. BUT 1.1.3 shows an error saying module not found...? – walker Sep 07 '22 at 23:21
  • The version `1.1.3` is incorrectly packaged. To be more precise there is no importable package in the distribution package. You can see it [here](https://inspector.pypi.io/project/rolimons/1.1.3/packages/5c/5c/04ef9dd83c5d0ab7bc770d89bc98d7fe186942f49fb9c6177b1a2bc50d13/rolimons-1.1.3.tar.gz/), there is no `rolimons` package at all in there, I do not know why, maybe there was no `rolimons/__init__.py` file, so setuptools did not add it in the distribution (`sdist`). – sinoroc Sep 08 '22 at 15:18
  • Huh, that's weird. In the source files there's a directory called `rolimons/`. Why wouldn't it be packaged when distributed? I specified the name and packages in `setup.py` – walker Sep 08 '22 at 15:44
  • It is only a guess. Fact is that this version `1.1.3` does not contain a `rolimons` importable package. The later versions seem to be okay, at least `1.2.8` (the one I just checked), although you really need to remove the `pyproject.toml` or rewrite it completely so that it fits `setuptools` (and not `poetry` as it is now, because that is obviously inconsistent and wrong, and will cause issues sooner or later). – sinoroc Sep 08 '22 at 16:11
  • Yea but I can't import version `1.2.8` since the imports fail until `1.1.3`. Also what do you mean by removing `pyproject.toml`? Do I remove in in the package source or in the the project where I'm importing it? – walker Sep 08 '22 at 16:37
  • Also I made another post to show the issues about python installing older and older versions until `1.1.3` https://stackoverflow.com/questions/73652595/python-imports-keep-failing – walker Sep 08 '22 at 16:52
  • Remove `pyproject.toml` in rolimons. -- "_Yea but I can't import version 1.2.8 since the imports fail until 1.1.3_", I do not understand your point here, just uninstall the old versions and install the latest one, what is the blocker here? It should work fine once you remove `pyproject.toml` in the rolimons project, then rebuild and republish to PyPI. – sinoroc Sep 08 '22 at 19:39
  • Basically, I think I've located the source. When I push a new version to pypi, I use `twine upload --skip-existing dist/*` which causes it to fail. When python sees that the package installation has failed, it goes to the next recent version which would be `1.2.7` and it does this until it reaches a version that was uploaded using `twine upload dist/*` but the problem is I don't know how to update to a new version using `twine upload dist/*` – walker Sep 08 '22 at 19:43
  • No, from my point of view, that is not your issue. Your issue is that your project is not build-able. Remove `pyproject.toml` then re-upload. – sinoroc Sep 08 '22 at 19:55
  • Versions are failing after `1.2.9` even after removing `pypoetry.lock` – walker Sep 08 '22 at 21:16
  • You need to upload to PyPI, a new version without `pyproject.toml`. I never said anything about `pypoetry.lock`. – sinoroc Sep 08 '22 at 21:38
  • Sorry, I mean `pyproject.toml` also I have found the issue. It has something to do with your earlier comment about switching environments. I am only able to import a version after I switch to a different virtual environment. I do not know why this is, but after switching, the packaging works succesfully. – walker Sep 08 '22 at 21:39

0 Answers0