pypa / packaging-problems

An issue tracker for the problems in packaging
151 stars 35 forks source link

Trouble with the packaging tutorial #604

Closed eranbet closed 2 years ago

eranbet commented 2 years ago

OS version

Ubuntu 20.04

Python version

3.8.10

Pip version

21.3.1

Guide link

https://packaging.python.org/tutorials/packaging-projects

Problem description

Using setuptools as build-system, running python3 -m build throws an error.

Error message

Traceback (most recent call last):
  File "/home/duality/PycharmProjects/CFW-pack/venv/lib/python3.8/site-packages/pep517/in_process/_in_process.py", line 363, in <module>
    main()
  File "/home/duality/PycharmProjects/CFW-pack/venv/lib/python3.8/site-packages/pep517/in_process/_in_process.py", line 345, in main
    json_out['return_val'] = hook(**hook_input['kwargs'])
  File "/home/duality/PycharmProjects/CFW-pack/venv/lib/python3.8/site-packages/pep517/in_process/_in_process.py", line 297, in get_requires_for_build_sdist
    return hook(config_settings)
  File "/tmp/build-env-brakmagw/lib/python3.8/site-packages/setuptools/build_meta.py", line 181, in get_requires_for_build_sdist
    return self._get_build_requires(config_settings, requirements=[])
  File "/tmp/build-env-brakmagw/lib/python3.8/site-packages/setuptools/build_meta.py", line 159, in _get_build_requires
    self.run_setup()
  File "/tmp/build-env-brakmagw/lib/python3.8/site-packages/setuptools/build_meta.py", line 174, in run_setup
    exec(code, locals())
  File "<string>", line 3, in <module>
  File "/tmp/build-env-brakmagw/lib/python3.8/site-packages/setuptools/__init__.py", line 87, in setup
    return distutils.core.setup(**attrs)
  File "/tmp/build-env-brakmagw/lib/python3.8/site-packages/setuptools/_distutils/core.py", line 151, in setup
    dist.parse_config_files()
  File "/tmp/build-env-brakmagw/lib/python3.8/site-packages/setuptools/dist.py", line 868, in parse_config_files
    pyprojecttoml.apply_configuration(self, filename, ignore_option_errors)
  File "/tmp/build-env-brakmagw/lib/python3.8/site-packages/setuptools/config/pyprojecttoml.py", line 58, in apply_configuration
    config = read_configuration(filepath, True, ignore_option_errors, dist)
  File "/tmp/build-env-brakmagw/lib/python3.8/site-packages/setuptools/config/pyprojecttoml.py", line 122, in read_configuration
    validate(subset, filepath)
  File "/tmp/build-env-brakmagw/lib/python3.8/site-packages/setuptools/config/pyprojecttoml.py", line 47, in validate
    raise error from None
ValueError: invalid pyproject.toml config: `project`

ERROR Backend subprocess exited when trying to invoke get_requires_for_build_sdist
abravalheri commented 2 years ago

Can you try validating your project with something like validate-pyproject to see exactly what is the problem?

eranbet commented 2 years ago

Setting requires = ["setuptools<61.0"] seems to resolve the issue.

abravalheri commented 2 years ago

Please open an issue in the setuptools repository if that is the case. If you can also share your pyproject.toml file to see what is going wrong, that would be very helpful.

abravalheri commented 2 years ago

Please note that setting requires = ["setuptools<61.0"] effectively disables parsing pyproject.toml. I don't know if that is exactly what you are looking for.

I did a quick test here and the latest version of setuptools does work normally with the pyproject.toml example provided in the package tutorial. So probably it would be worthy to investigate a bit more your pyproject.toml.

I suspect that the logs providaded by setuptools and build also contain a bit more information about what is going wrong... If you scroll before the traceback you are probably going to see some helpful messages. For example, if you accidentally change requires-python to python-requires, you should see an error like the following:

configuration error: `project` must not contain {'python-requires'} properties
abravalheri commented 2 years ago

Hi @eranbet, the upcoming version 63.4.2 of setuptools, should also print a summary of the problem with pyproject.toml at the bottom of the stack trace, not only at the top.

This should make it easier to spot during debugging.

I think I will close this issue for now since you seem to have moved on and did not provide any further information.

Please feel free to comment in this issue with extra information if you would like the investigation to proceed (I am more than happy to reopen it).

alyaly1987UNH commented 1 year ago

having same issue, here is my .toml file contents.

[build-system] requires = ["setuptools"] build-backend = "setuptools.build_meta" [project] name = "Pypack" version = "0.0.1" dependencies = [ "requests", 'importlib-metadata; python_version<"3.8"', ] authors = [ { name="myname", email="myemail@mydomain.com" }, ] description = "A package made to " readme = "README.txt" requires-python = ">=3.8" classifiers = [ "Programming Language :: Python :: 3", "License :: OSI Approved :: GNU GENERAL PUBLIC LICENSE", "Operating System :: OS Independent", ] [project.urls] "Homepage" = "https://github.com/..." "Bug Tracker" = "https://github.com/.../issues" [project.scripts] load-as-run= "src.Pypack.mod:load" [project.gui-scripts] hello-world = "src.Pypack.mod:hello_world"

alyaly1987UNH commented 1 year ago

changing to setuptools<61.0 fixes issue for me as well.

abravalheri commented 1 year ago

Setting setuptools<61.0 is very rarely a good solution and it is strongly discouraged. People looking at this issue in the future should not attempt this.

I recommend instead having a look on the traceback and trying to fix the errors described there.

henryiii commented 1 year ago

As a reminder from above, setting setuptools<61 causes the project table to be completely ignored. So it doesn't "fix" it, it just builds a UNKNOWN-0.0.0 package with no configuration.

Pasting your traceback (surrounded by triple tick marks for nice GitHub formatting!) would be helpful.