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

Can't install from sdist: poetry.core.masonry.utils.module.ModuleOrPackageNotFound: No file/folder found for package nonecorn #24

Open
reivilibre opened this issue Oct 1, 2022 · 9 comments
Labels
question Further information is requested

Comments

@reivilibre
Copy link

To reproduce:

In a fresh venv,

pip install https://files.pythonhosted.org/packages/84/93/4439b0208d05aa0ebf33385f188aed4b74435612a39beaf62ecfce6548b3/nonecorn-0.14.1.dev1.tar.gz
Collecting https://files.pythonhosted.org/packages/84/93/4439b0208d05aa0ebf33385f188aed4b74435612a39beaf62ecfce6548b3/nonecorn-0.14.1.dev1.tar.gz
  Downloading nonecorn-0.14.1.dev1.tar.gz (47 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 47.5/47.5 KB 271.5 kB/s eta 0:00:00
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... error
  error: subprocess-exited-with-error
  
  × Preparing metadata (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [16 lines of output]
      Traceback (most recent call last):
        File "/tmp/.venv/lib/python3.9/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 363, in <module>
          main()
        File "/tmp/.venv/lib/python3.9/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 345, in main
          json_out['return_val'] = hook(**hook_input['kwargs'])
        File "/tmp/.venv/lib/python3.9/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 164, in prepare_metadata_for_build_wheel
          return hook(metadata_directory, config_settings)
        File "/run/user/1000/pip-build-env-9vx0dx3v/overlay/lib/python3.9/site-packages/poetry/core/masonry/api.py", line 41, in prepare_metadata_for_build_wheel
          builder = WheelBuilder(poetry)
        File "/run/user/1000/pip-build-env-9vx0dx3v/overlay/lib/python3.9/site-packages/poetry/core/masonry/builders/wheel.py", line 56, in __init__
          super().__init__(poetry, executable=executable)
        File "/run/user/1000/pip-build-env-9vx0dx3v/overlay/lib/python3.9/site-packages/poetry/core/masonry/builders/builder.py", line 83, in __init__
          self._module = Module(
        File "/run/user/1000/pip-build-env-9vx0dx3v/overlay/lib/python3.9/site-packages/poetry/core/masonry/utils/module.py", line 69, in __init__
          raise ModuleOrPackageNotFound(
      poetry.core.masonry.utils.module.ModuleOrPackageNotFound: No file/folder found for package nonecorn
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

I can't see any option in pyproject.toml that tells it the module is actually called 'hypercorn' not 'nonecorn'; suspect there's something missing but not sure

@reivilibre
Copy link
Author

It might be something like this that is needed:

packages = [
    { include = "src/hypercorn" }
]

@synodriver
Copy link
Member

Sorry for the late reply. Anyway, thanks for reporting it. The issue seems to related to poetry which I do not familiar with. Try install from pypi? pip install nonecorn==0.14.1dev1

@synodriver
Copy link
Member

By the way, this branch is intended to be the test branch of hypercorn, so its version number is always dev. I have already used some additional features, such as gunicorn process management, zerocopy, etc., but the upstream may not fully accept my features, so I released them separately in pypi.

@synodriver
Copy link
Member

Since it is a dev branch, this repo is specially prepared for those who are particularly interested in asgi, because it implements every asgi extension, although the documentation is not yet complete, but I believe those people are looking at the code directly.

@synodriver
Copy link
Member

synodriver commented Nov 10, 2022

For users who want to try new features, you can take a look at my usage first, at there. The easiest way to start is to read hypercorn's document because it's 100% compatible with hypercorn, the only difference would be the support for asgi extensions, gunicorn and some extra code.

@reivilibre
Copy link
Author

Sorry for the late reply. Anyway, thanks for reporting it. The issue seems to related to poetry which I do not familiar with. Try install from pypi? pip install nonecorn==0.14.1dev1

I was trying to package my application (which was depending on nonecorn because I needed some of your ASGI extensions) in a situation where I have to install from the sdist. When you run pip install nonecorn then, depending on your system, pip will likely prefer to use the wheel. But if pip used the sdist from PyPI then I think it would fail with the same error. (basically the sdist that has been uploaded isn't valid since you can't use it to build the wheel.)

I'm not that familiar with poetry either but I wonder if

packages = [
    { include = "src/hypercorn" }
]

would work under [tool.poetry] in pyproject.toml?

I find it confusing that there's both a setup.py and a pyproject.toml — I don't know if this is nonecorn specific though. I would expect to only see pyproject.toml on a Poetry project.

@synodriver
Copy link
Member

synodriver commented Nov 11, 2022

I find it confusing that there's both a setup.py and a pyproject.toml — I don't know if this is nonecorn specific though. I would expect to only see pyproject.toml on a Poetry project.

Upstream has changed from setuptools to poetry, but I prefer setuptools, so I keep setup.py remain.

Actually I have already used pip install nonecorn in my project, and it works fine. What system and python version are you using?

And I wonder if this package is able to build on your system with python setup.py sdist bdist_wheel, that's what I have used to build and upload to pypi.

@synodriver synodriver added the question Further information is requested label Nov 11, 2022
@reivilibre
Copy link
Author

Actually I have already used pip install nonecorn in my project, and it works fine

This is because it's using the wheel, which isn't affected by this problem. However, the sdists (source distributions) don't work. To reproduce, you can also try pip install --no-binary :all: nonecorn==0.14.1dev1, which forces pip not to use the wheel. You should observe that it also fails with the error given here.
When someone packages something for a distribution, they usually want to use a source distribution.

My system here today is Ubuntu 22.04 with Python 3.10.6, but I was trying to package on NixOS 22.05 with Python 3.9 I think — I don't think the system seems to affect the fact that the sdists don't work.

Upstream has changed from setuptools to poetry, but I prefer setuptools, so I keep setup.py remain.

Somewhat fair enough, the world of Python packaging is a mess in my opinion and it can be very confusing. However, instead of keeping setuptools, you seem to have ended up with some frankensteinian hybrid of the two :P. The sdist seems to be relying on Poetry to build, which strikes me as unusual if you built the project with python setup.py sdist...

This section is in pyproject.toml:

[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"

That tells pip to use poetry to install the project, when it's installed bare. This is essentially a bug if installing via Poetry doesn't work. Maybe the easiest solution is to just remove pyproject.toml if you don't want to touch Poetry?

When you build packages (e.g. python setup.py sdist bdist_wheel) I always recommend installing them in a fresh venv with e.g. pip install path/to/dist/nonecorn-x.y.z.tar.gz to ensure they work.

However: just now I added

packages = [
    { include = "src/hypercorn" }
]

to the [tool.poetry] section in pyproject.toml and I can confirm it now works when installing it.

@synodriver
Copy link
Member

synodriver commented Nov 11, 2022

So it seems that poetry conflicts with setuptools. I'll have a try later.

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

No branches or pull requests

2 participants