Skip to content

setup: switch to declarative package metadata #4113

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

Merged
merged 1 commit into from
Oct 23, 2021

Conversation

bastimeyer
Copy link
Member

@bastimeyer bastimeyer commented Oct 21, 2021

  • move static package metadata to setup.cfg
  • rename deprecated license_file field to license_files

Remove setuptools arguments:

  • test_suite:
    Unneeded, as we disable the deprecated setuptools test command

Keep dynamic setuptools arguments:

  • version/cmdclass:
    For writing static version info via versioneer
  • install_requires:
    Some dependencies still depend on special environment variables
    instead of package "extra" dependency fields
  • entry_points:
    The gui_scripts entry point should only be set when building wheels
    for Windows via --plat-name={win32,win-amd64,cygwin}
  • data_files:
    All data files are optional and should not cause the build to fail if
    they are missing, eg. when building from sdist

Static package metadata could've also been moved into pyproject.toml (PEP 518 / PEP 621), but this would've changed how Streamlink gets built from source by tools like pip, and this causes issues with the integrated versioneer module that's required by setup.py.


TODO (in future PRs):

  • Add the pyproject.toml file, at least with the build-system data, as it defines setuptools as build tool, which is currently only implied as a default.
    I had already added it but then ran into issues with installing in develop mode (pip install -e) because it couldn't import versioneer.
  • Define optional dependencies as extras_require instead of using env vars in setup.py
  • Remove the NO_DEPS env var, as it's unused

Some quick checks:

python setup.py --version

  • outputs correct version (required by script/build-and-sign.sh)

python setup.py build

  • writes built project files (into build/lib)
  • writes streamlink/plugins/.removed (via options.package_data)
  • bakes version info via versioneer

python setup.py sdist

  • includes correct source tree
  • includes correct metadata and entry_points in embedded egg-info
  • includes streamlink/plugins/.removed (via MANIFEST.in)
  • bakes version info via versioneer

python setup.py bdist_wheel

  • includes built project files
  • includes correct metadata and entry_points (Windows wheels also have the gui_scripts entry point)
  • includes streamlink/plugins/.removed (via options.package_data)
  • includes optional data files (shell completions and man pages)
  • bakes version info via versioneer

python setup.py install

  • writes built project files
  • writes correct metadata and entry_points in egg-info directory
  • writes streamlink/plugins/.removed (via options.package_data)
  • writes optional data files (shell completions and man pages)
  • bakes version info via versioneer

python setup.py develop / pip install -e .

  • works

./script/makeinstaller.sh

  • builds but didn't test it yet
  • writes streamlink/plugins/.removed (via options.package_data)

Please don't merge unless carefully reviewed, as I might have missed something...

- move static package metadata to setup.cfg
- rename deprecated license_file field to license_files

Remove setuptools arguments:
- test_suite:
  Unneeded, as we disable the deprecated setuptools test command

Keep dynamic setuptools arguments:
- version/cmdclass:
  For writing static version info via versioneer
- install_requires:
  Some dependencies still depend on special environment variables
  instead of package "extra" dependency fields
- entry_points:
  The `gui_scripts` entry point should only be set when building wheels
  for Windows via `--plat-name={win32,win-amd64,cygwin}`
- data_files:
  All data files are optional and should not cause the build to fail if
  they are missing, eg. when building from sdist
@bastimeyer bastimeyer force-pushed the setup/declarative-metadata branch from 9067df9 to eb1cde2 Compare October 21, 2021 06:34
Copy link
Member

@gravyboat gravyboat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me when comparing against the setup.cfg options from the setuptools documentation, other changes look good as well. We can wait for someone else to approve if you would like, but I'm happy with this change and don't see any errors.

@bastimeyer
Copy link
Member Author

bastimeyer commented Oct 23, 2021

Let's get this merged later today then if there's no further review. It's all looking fine as far as I can tell.

Btw, there's setuptools_scm which can be used to replace versioneer. I will look into that later some time. That would allow adding a pyproject.toml file without any issues. It would require a backport dependency for py37 though.
https://github.com/pypa/setuptools_scm/

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.

2 participants