openSUSE / py2pack

Generate distribution packages from PyPI
Apache License 2.0
69 stars 40 forks source link

Support packages without setup.py (just with pyproject.toml) #159

Open johanneskastl opened 2 years ago

johanneskastl commented 2 years ago

When trying to update jsonschema to the latest version, py2pack errors out:

$ py2pack generate -t opensuse.spec -f python-jsonschema.spec jsonschema
generating spec file for jsonschema...
Traceback (most recent call last):
  File "/usr/bin/py2pack", line 10, in <module>
    sys.exit(main())
  File "/usr/lib/python3.10/site-packages/py2pack/__init__.py", line 366, in main
    args.func(args)
  File "/usr/lib/python3.10/site-packages/py2pack/__init__.py", line 255, in generate
    _augment_data_from_tarball(args, tarball_file[0], data)
  File "/usr/lib/python3.10/site-packages/py2pack/__init__.py", line 163, in _augment_data_from_tarball
    data_archive = meta_utils.from_archive(filename)
  File "/usr/lib/python3.10/site-packages/metaextract/utils.py", line 134, in from_archive
    data = _setup_py_run_from_dir(root_dir, py_interpreter)
  File "/usr/lib/python3.10/site-packages/metaextract/utils.py", line 98, in _setup_py_run_from_dir
    raise Exception("'setup.py' does not exist in '%s'" % (
Exception: 'setup.py' does not exist in '/tmp/metaextract_bx91p8iz/jsonschema-4.7.2'

How to handle these cases, where apparently upstream changed the packaging setup?

mcepl commented 2 years ago

First of all, using py2pack for upgrading already existing package is rather bad idea. Just use the existing SPEC file, increase Version, download new tarball (using osc service disabledrun download_files), update *.changes (using osc vc), and you can run osc build to test the result.

johanneskastl commented 2 years ago

First of all, using py2pack for upgrading already existing package is rather bad idea. Just use the existing SPEC file, increase Version, download new tarball (using osc service disabledrun download_files), update *.changes (using osc vc), and you can run osc build to test the result.

This error also happens on new packages.

I tried to create hatch_vcs (or hatch-vcs), and had the same error.

mcepl commented 2 years ago

hatch-vcs

Yup, another setup.py-less package https://github.com/ofek/hatch-vcs

danigm commented 2 years ago

I've created a PR in metaextract project that should fix this issue: https://github.com/toabctl/metaextract/pull/16

But hatch_vcs will continue failing because it looks like the pyproject.toml file in the current release is broken, it'll be fixed in future releases with this commit: https://github.com/ofek/hatch-vcs/commit/c5388d67192d9bf88191927a35f51705121784a1

danigm commented 2 years ago

There's a new release of metaextract that comes with pyproject support, so updating that, now py2pack should work with this kind of packages.

danigm commented 1 year ago

The current solution in metaextract only works correctly with packages that uses setuptools as build system. For packages that uses flit, hatch poetry or something else, can work, but it generates a lot of warnings and it's not able to get data from dynamic of custom fields.

Maybe it's a good idea to explore the possibility of extend metaextract with support for the most common build systems, or maybe we can just try to get all the metadata from the package itself instead of using the setup.py.

I'll explore different solutions, so maybe this can be improved to work with all these modern python build systems.