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 with the packaging tutorial #604

Closed
eranbet opened this issue Jul 20, 2022 · 9 comments
Closed

Trouble with the packaging tutorial #604

eranbet opened this issue Jul 20, 2022 · 9 comments

Comments

@eranbet
Copy link

eranbet commented Jul 20, 2022

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
Copy link
Contributor

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

@eranbet
Copy link
Author

eranbet commented Jul 20, 2022

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

@abravalheri
Copy link
Contributor

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
Copy link
Contributor

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 added a commit to abravalheri/setuptools that referenced this issue Aug 4, 2022
Based on the following discussions:

- pypa/packaging.python.org#1031 (comment)
- pypa/packaging-problems#604

it seems that people are having a hard time finding information about
validation error due to the long traceback and debug info.

The idea behind this change is to make the most relevant information
to fix the error easier to spot.
@abravalheri
Copy link
Contributor

abravalheri commented Aug 6, 2022

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
Copy link

alyaly1987UNH commented Dec 22, 2022

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
Copy link

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

@abravalheri
Copy link
Contributor

abravalheri commented Dec 22, 2022

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
Copy link
Contributor

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.

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

4 participants