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

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

Open
johanneskastl opened this issue Jul 19, 2022 · 6 comments
Open

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

johanneskastl opened this issue Jul 19, 2022 · 6 comments

Comments

@johanneskastl
Copy link

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

mcepl commented Jul 19, 2022

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.

@mcepl mcepl changed the title How to handle "Exception: 'setup.py' does not exist in ..." Support packages without setup.py (just with pyproject.toml) Jul 19, 2022
@johanneskastl
Copy link
Author

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

mcepl commented Jul 19, 2022

hatch-vcs

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

danigm added a commit to danigm/metaextract that referenced this issue Oct 13, 2022
Following the doc from setuptools, when there's no setup.py file it's
possible to use a simple one with just the call to `setup()` that will
get the data from pyproject.toml:
https://setuptools.pypa.io/en/latest/userguide/pyproject_config.html#configuring-setuptools-using-pyproject-toml-files

This should fix the issue in py2pack trying to generate from projects
that doesn't provide a setup.py file:
openSUSE/py2pack#159
@danigm
Copy link
Contributor

danigm commented Oct 13, 2022

I've created a PR in metaextract project that should fix this issue: toabctl/metaextract#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: ofek/hatch-vcs@c5388d6

danigm added a commit to danigm/metaextract that referenced this issue Oct 13, 2022
Following the doc from setuptools, when there's no setup.py file it's
possible to use a simple one with just the call to `setup()` that will
get the data from pyproject.toml:
https://setuptools.pypa.io/en/latest/userguide/pyproject_config.html#configuring-setuptools-using-pyproject-toml-files

This should fix the issue in py2pack trying to generate from projects
that doesn't provide a setup.py file:
openSUSE/py2pack#159
danigm added a commit to danigm/metaextract that referenced this issue Oct 13, 2022
Following the doc from setuptools, when there's no setup.py file it's
possible to use a simple one with just the call to `setup()` that will
get the data from pyproject.toml:
https://setuptools.pypa.io/en/latest/userguide/pyproject_config.html#configuring-setuptools-using-pyproject-toml-files

This should fix the issue in py2pack trying to generate from projects
that doesn't provide a setup.py file:
openSUSE/py2pack#159
@danigm
Copy link
Contributor

danigm commented Oct 14, 2022

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

danigm commented Nov 24, 2022

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants