Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Packaging modernization & cleanup #148

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 3 commits into from
Apr 30, 2023
Merged

Conversation

masklinn
Copy link
Contributor

@masklinn masklinn commented Nov 25, 2022

  • drop support for EOL'd (and soon to be EOL'd) versions of python, remove unnecessary __future__ imports
  • replace explicit invocations of setup.py (and recommendations thereof), as that has been deprecated for a while
  • switch all but the codegen over to pyproject.toml
    • modernize the codegen code
    • use subcommands to hook codegen in, and only perform it when building a wheel (or an editable wheel though that seems a bit iffy)
  • add uap-core to the sdist, as that seems sensible, and also necessary with removing codegen from the sdist path
  • change the CI setup to test installation via source, wheel, and sdist, so we know all of them work correctly

@masklinn masklinn marked this pull request as draft November 25, 2022 13:45
@masklinn masklinn mentioned this pull request Nov 25, 2022
@masklinn
Copy link
Contributor Author

masklinn commented Nov 27, 2022

TODO: as part of the systems modernisation, enable doctests in pytest (for the readme, and also maybe the package though I'm not sure there's any docstring doctest currently) we don't currently have any doctests and --doctest-modules can't cope with circular imports at all, so just don't bother.

@masklinn masklinn marked this pull request as ready for review April 22, 2023 15:23
@masklinn masklinn changed the title Layout and system modernization Packaging modernization Apr 22, 2023
@masklinn masklinn changed the title Packaging modernization Packaging modernization & cleanup Apr 22, 2023
@masklinn masklinn force-pushed the cleanup branch 10 times, most recently from 2ba1611 to 34353ed Compare April 26, 2023 19:42
- 2.7 was EOL'd in 2020
- 3.6 was EOL'd in 2021
- 3.7 will be EOL'd in June 2023

Even if a 1.0 is cut before June it doesn't seem likely that it'll
matter a lot.

3.8 doesn't bring a lot that's likely to be useful as far as I know,
candidates I can think of are:

- positional-only parameters
- typed dicts and literals, to add typing to the legacy API

While at it, remove the now unnecessary future imports, as well as the
module-level docstrings (they're not very helpful) and the per-file
license headers (they don't seem useful).
PEP 517
=======

Don't migrate away from setuptools, but move "static" packaging
content from `setup.py` to `pyproject.toml` and `setup.cfg`. Building
should now be performed using
[`build`](https://pypa-build.readthedocs.io/en/stable/), as direct
invocations of `setup.py` have been deprecated for a while.

Also remove the legacy `__author__` strictures from the source files,
as `pyproject.toml` supports an authors section which is more suitable.

Codegen Modernization
=====================

The modernization via command overrides and self-invocation still
generated `setup.py` warnings.

Migrate the "invoke commands in commands" method to codegen
sub-commands in `build`, it looks like this suffices for what we
need. This reuses the existing code, though modernizes it
significantly thanks to the previous commit.

This is strongly inspired by @abravalheri's comments on codegen in
setuptools discussions e.g. pypa/setuptools#3180 and
pypa/setuptools#3762, those comments were very helpful in getting a
better understanding of the sub_commands system (also @jaraco's
comments but those were a touch terse so can't say I really got it
until sumbling on @abravalheri's).

Leverages the setuptools subcommands protocol to support editable
wheels, as that might be useful. Don't use editable wheels for testing
though, as I don't see the point.

Note: not sure the git submodule stuff is useful during the codegen,
so currently commented it out.

sdists
======

I'm not entirely clear what sdists should really be about, adding
codegen to sdist using subcommands seems not necessarily trivial, so
for now make them basically an export:

- remove `_regexes.py` from sdist
- add uap-core to the manifest, and thus the sdist, at least
  `regexes.yaml`

Currently the test files (both python and yaml) are also included, but
it's not clear that they *should* be. That seems like [a whole
debate](https://discuss.python.org/t/should-sdists-include-docs-and-tests/14578/117),

One strong argument (to me) in favor of a sdist maximalism is that it
matches the wheels and more official releases, but in that case the
sdist should probably be better crafted than what I threw together.

Tox
===

Switch tox to an explicit `pip install` as its builtin handling for
installing packages (whether via sdist or develop) does not seem
compatible with PEP-517. Need to think about moving to tox 4, which
apparently has native support for PEP 517 packages. Cf ua-parser#157.

Also remove the `docs` tox env, it hasn't been a thing since
8273477 but I forgot to remove it
from the envlist.
- remove old compile step
- update python-action to v4 and "primary" python to 3.11
- produce sdist and wheel just once
- ensure we're testing after installing from wheel, sdist, and source
@masklinn masklinn merged commit e2267d2 into ua-parser:master Apr 30, 2023
@masklinn masklinn deleted the cleanup branch April 30, 2023 11:50
@masklinn masklinn mentioned this pull request Jul 2, 2023
5 tasks
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

Successfully merging this pull request may close these issues.

1 participant