Skip to content

build: move project metadata to pyproject #4441

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

Closed

Conversation

bastimeyer
Copy link
Member

@bastimeyer bastimeyer commented Apr 9, 2022

Follow up of #4440 with the pyproject.toml metadata changes, according to PEP 621.
https://peps.python.org/pep-0621/
https://setuptools.pypa.io/en/stable/history.html#v61-0-0

See #4321


  1. Move the the project metadata from setup.cfg (soon to be deprecated by setuptools) to pyproject.toml according to PEP 621 and bump setuptools requirement to >= 61 (requires at least py37)
  2. Remove {dev,docs}-requirements.txt in favor of package "extra" dependencies that can be installed like this streamlink[dev], streamlink[docs]
  3. Move last remaining setuptools configs from setup.cfg to pyproject.toml

This leaves setup.cfg with only flake8 related content. Flake8 doesn't support pyproject yet AFAIK, so the file could be renamed to .flake8, similar to .coveragerc which includes configs for the coverage package, but that's rather pointless, because the stuff will be moved eventually anyway.

I've tried to keep the resulting package metadata as close to the currently included metadata. There are some changes though (ignoring the changes on master):

$ pip install .
$ diff \
  <( \
    curl -sSL 'https://files.pythonhosted.org/packages/67/97/22af99220a108d24eb635c9f1693ea52e1ffe5b0c93098dae7258c2a6a4d/streamlink-3.2.0.tar.gz' \
    | bsdtar -xOzf - 'streamlink-3.2.0/PKG-INFO' \
  ) \
  src/streamlink.egg-info/PKG-INFO
3c3
< Version: 3.2.0
---
> Version: 3.2.0+28.g678ff680
8c8,33
< License: Simplified BSD
---
> License: Copyright (c) 2011-2016, Christopher Rosell
>         Copyright (c) 2016-2022, Streamlink Team
>         All rights reserved.
>         
>         Redistribution and use in source and binary forms, with or without
>         modification, are permitted provided that the following conditions are met:
>         
>         1. Redistributions of source code must retain the above copyright notice, this
>            list of conditions and the following disclaimer.
>         2. Redistributions in binary form must reproduce the above copyright notice,
>            this list of conditions and the following disclaimer in the documentation
>            and/or other materials provided with the distribution.
>         
>         THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
>         ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
>         WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
>         DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
>         ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
>         (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
>         LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
>         ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
>         (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
>         SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
>         
>         
> Project-URL: Home-Page, https://github.com/streamlink/streamlink
23d47
< Classifier: Programming Language :: Python :: 3.6
120c144
<   [streamlink-plugins]: https://streamlink.github.io/plugin_matrix.html
---
>   [streamlink-plugins]: https://streamlink.github.io/plugins.html

@bastimeyer
Copy link
Member Author

Just rebased the branch...

I dropped the commit which moves the {dev,docs}-requirements.txt contents to project.optional-dependencies, because updating these extra deps while having an editable install of streamlink makes pip overwrite that install with a regular one, which is annoying. Let's keep the requirements files for now.

Other changes after rebasing:

  • updated the install docs
  • bumped min. pip version to 21

@bastimeyer bastimeyer marked this pull request as ready for review April 10, 2022 11:06
@bastimeyer bastimeyer added the WIP Work in process label Apr 10, 2022
@bastimeyer bastimeyer marked this pull request as draft April 10, 2022 11:08
@bastimeyer bastimeyer force-pushed the build/pyproject-metadata branch from 678ff68 to ecbc474 Compare April 10, 2022 11:22
@bastimeyer
Copy link
Member Author

I've commented earlier (and then deleted my post again) that I noticed issues with the sdist tarballs and that it somehow includes every file in the git repo instead of only the package files and stuff defined in MANIFEST.in.

I still have no idea why this happened when building the sdist tarball and I first thought that this was caused by these changes here or #4440. All I know is that this started happening after the move to pyproject.toml, even after deleting the build/ and src/streamlink.egg-info/ dirs, running setup.py clean --all, and even after rolling back to 3.2.0.

After checking 3.2.0, master and this PR branch again in a clean git clone, clean venv, and updated pip+setuptools, everything seems to be working reliably and deterministically, but I can't figure out why this sdist issue is sometimes happening in my development venv. As long as this doesn't affect the release sdists though, this shouldn't be an issue, but it confuses me.


Regarding the current state of this PR, I had to add entry-points to the dynamic attribute in the recent push, because entry_points gets set in setup.py, as it checks if wheels are built for Windows which then include the additional streamlinkw entry. The data-files config does not need an entry in the dynamic attribute for some reason. This may be because it has been deprecated by setuptools. I don't think it will be possible anymore in the future to include man files and shell completions in wheels.


So the only thing that may be of concern here is that the most recent version of setuptools (62.1.0) still consideres metadata in pyproject.toml as experimental.
https://setuptools.pypa.io/en/latest/userguide/pyproject_config.html#configuring-setuptools-using-pyproject-toml-files

Support for project metadata in pyproject.toml is still experimental and may be removed (or change) in future releases.

@bastimeyer bastimeyer removed the WIP Work in process label Apr 15, 2022
@bastimeyer bastimeyer force-pushed the build/pyproject-metadata branch 2 times, most recently from 1dbb0e6 to 6f3c1ee Compare June 9, 2022 17:17
@bastimeyer
Copy link
Member Author

Just a quick force-push in order to resolve the merge conflicts.

This is still considered too new to be merged, as setuptools 61 is required (2022-03-24) and setuptools still considers pyproject metadata experimental itself.
https://setuptools.pypa.io/en/latest/history.html

@bastimeyer bastimeyer force-pushed the build/pyproject-metadata branch from 6f3c1ee to a73f374 Compare January 25, 2023 14:21
@bastimeyer
Copy link
Member Author

Rebased to master and fixed merge conflicts.

Also changed:

I'll keep this PR as a draft, since setuptools still doesn't consider pyproject.toml project metadata stable

@bastimeyer bastimeyer force-pushed the build/pyproject-metadata branch from a73f374 to 91d7f39 Compare February 5, 2023 12:19
@bastimeyer
Copy link
Member Author

bastimeyer commented Feb 5, 2023

Rebased to master once again, with changes of #5141 applied to pyproject.toml
https://setuptools.pypa.io/en/stable/userguide/datafiles.html#package-data

- bump min. setuptools version to 64
- bump min. pip version to 21 in dev-requirements.txt
- move PEP 621 metadata from setup.cfg to pyproject.toml
- update install docs
@bastimeyer bastimeyer force-pushed the build/pyproject-metadata branch from 91d7f39 to d868f27 Compare February 11, 2023 21:59
@bastimeyer
Copy link
Member Author

Rebased and fixed merge conflicts once more (#5143 and #5149)

@bastimeyer bastimeyer closed this Jul 14, 2023
@bastimeyer bastimeyer deleted the build/pyproject-metadata branch July 17, 2023 00:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant