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

feat: update to recent uap-core #221

Closed
wants to merge 1 commit into from

Conversation

dilex42
Copy link

@dilex42 dilex42 commented Oct 3, 2024

Hi. I've made some updates to ua-parser/uap-core#601 and wondered what is the right course of actions to update this package for us to use.

@masklinn
Copy link
Contributor

masklinn commented Oct 5, 2024

It doesn't look like upstream has cut a 0.19, so there's no updating (probably the upcoming 1.x least of all), however that's what loading custom rulesets is for.

Admittedly in 0.x it's not amazing, or documented, but the way to do it is to install PyYaml and set the UA_PARSER_YAML environ variable to the path of the regexes.yaml file you want to load, either from outside the python process or by setting os.environ['UA_PARSER_YAML'] before you import the library.

This will load the ruleset from the yaml file instead of using the precompiled ruleset.

@masklinn masklinn closed this Oct 5, 2024
masklinn added a commit to masklinn/uap-python that referenced this pull request Nov 18, 2024
The goal of this is the ability to generate wheels for precompiled
instances of uap-core, at whatever version we want.

The goal here is ultimately to move all the precompiled stuff outside
of uap-python itself and in a separate wheel, in order to generate
wheels for precompiled instances of uap-core at whatever version we want

1. It resolves ua-parser#146 by splitting the versioning of the API and that of
   the (pre-compiled) data, this is an issue for 1.0 as that detaches
   uap-python's versioning from uap-core's.
2. It allows users to update the API and the precompiled dataset
   separately, something they would otherwise need to do via yaml.
3. It fixes ua-parser#221 by allowing the regular release of "preview"
   precompiled regexes from uap-core snapshots e.g. we could release
   0.19.dev202412 at the start of december with whatever uap-core
   merged between the previous prerelease and then. This should not be
   picked up by pip by default, but would allow users to access those
   prerelases via `pip install --pre`.
4. If done well enough, it might allow users to build bespoke
   precompiled datasets so they don't have to pick between custom
   rules and precompiled (not sure there's any demand for this but it
   seems like it might be useful).
5. If it works well enough it might actually be possible to have 0.x
   use the legacy codegen package meaning it should not need to be
   updated anymore.

This is implemented via hatch build hooks (which seem seem simpler
than doing it via setuptools in the end).

Adding `regexes.yaml` to the sdist via artifacts is a bit strange but
necessary in order to generate a complete sdist which a wheel can be
built from (even though the release script will likely only push the
wheel).
masklinn added a commit to masklinn/uap-python that referenced this pull request Nov 23, 2024
The goal of this is the ability to generate wheels for precompiled
instances of uap-core, at whatever version we want.

1. It resolves ua-parser#146 by splitting the versioning of the API and that of
   the (pre-compiled) data, this is an issue for 1.0 as that detaches
   uap-python's versioning from uap-core's.
2. It allows users to update the API and the precompiled dataset
   separately, something they would otherwise need to do via yaml.
3. It fixes ua-parser#221 by allowing the regular release of "preview"
   precompiled regexes from uap-core snapshots e.g. we could release
   0.19.dev202412 at the start of december with whatever uap-core
   merged between the previous prerelease and then. This should not be
   picked up by pip by default, but would allow users to access those
   prerelases via `pip install --pre`.
4. If done well enough, it might allow users to build bespoke
   precompiled datasets so they don't have to pick between custom
   rules and precompiled (not sure there's any demand for this but it
   seems like it might be useful).
5. If it works well enough it might actually be possible to have 0.x
   use the legacy codegen package meaning it should not need to be
   updated anymore.

This is implemented via hatch build hooks (which seem seem simpler
than doing it via setuptools in the end).

Adding `regexes.yaml` to the sdist via artifacts is a bit strange but
necessary in order to generate a complete sdist which a wheel can be
built from (even though the release script will likely only push the
wheel).
masklinn added a commit to masklinn/uap-python that referenced this pull request Nov 23, 2024
The goal of this is the ability to generate wheels for precompiled
instances of uap-core, at whatever version we want.

1. It resolves ua-parser#146 by splitting the versioning of the API and that of
   the (pre-compiled) data, this is an issue for 1.0 as that detaches
   uap-python's versioning from uap-core's.
2. It allows users to update the API and the precompiled dataset
   separately, something they would otherwise need to do via yaml.
3. It fixes ua-parser#221 by allowing the regular release of "preview"
   precompiled regexes from uap-core snapshots e.g. we could release
   0.19.dev202412 at the start of december with whatever uap-core
   merged between the previous prerelease and then. This should not be
   picked up by pip by default, but would allow users to access those
   prerelases via `pip install --pre`.
4. If done well enough, it might allow users to build bespoke
   precompiled datasets so they don't have to pick between custom
   rules and precompiled (not sure there's any demand for this but it
   seems like it might be useful).
5. If it works well enough it might actually be possible to have 0.x
   use the legacy codegen package meaning it should not need to be
   updated anymore.

This is implemented via hatch build hooks (which seem seem simpler
than doing it via setuptools in the end).

Adding `regexes.yaml` to the sdist via artifacts is a bit strange but
necessary in order to generate a complete sdist which a wheel can be
built from (even though the release script will likely only push the
wheel).
masklinn added a commit to masklinn/uap-python that referenced this pull request Nov 23, 2024
The goal of this is the ability to generate wheels for precompiled
instances of uap-core, at whatever version we want.

1. It resolves ua-parser#146 by splitting the versioning of the API and that of
   the (pre-compiled) data, this is an issue for 1.0 as that detaches
   uap-python's versioning from uap-core's.
2. It allows users to update the API and the precompiled dataset
   separately, something they would otherwise need to do via yaml.
3. It fixes ua-parser#221 by allowing the regular release of "preview"
   precompiled regexes from uap-core snapshots e.g. we could release
   0.19.dev202412 at the start of december with whatever uap-core
   merged between the previous prerelease and then. This should not be
   picked up by pip by default, but would allow users to access those
   prerelases via `pip install --pre`.
4. If done well enough, it might allow users to build bespoke
   precompiled datasets so they don't have to pick between custom
   rules and precompiled (not sure there's any demand for this but it
   seems like it might be useful).
5. If it works well enough it might actually be possible to have 0.x
   use the legacy codegen package meaning it should not need to be
   updated anymore.

This is implemented via hatch build hooks (which seem seem simpler
than doing it via setuptools in the end).

Adding `regexes.yaml` to the sdist via artifacts is a bit strange but
necessary in order to generate a complete sdist which a wheel can be
built from (even though the release script will likely only push the
wheel).
masklinn added a commit to masklinn/uap-python that referenced this pull request Nov 23, 2024
The goal of this is the ability to generate wheels for precompiled
instances of uap-core, at whatever version we want.

1. It resolves ua-parser#146 by splitting the versioning of the API and that of
   the (pre-compiled) data, this is an issue for 1.0 as that detaches
   uap-python's versioning from uap-core's.
2. It allows users to update the API and the precompiled dataset
   separately, something they would otherwise need to do via yaml.
3. It fixes ua-parser#221 by allowing the regular release of "preview"
   precompiled regexes from uap-core snapshots e.g. we could release
   0.19.dev202412 at the start of december with whatever uap-core
   merged between the previous prerelease and then. This should not be
   picked up by pip by default, but would allow users to access those
   prerelases via `pip install --pre`.
4. If done well enough, it might allow users to build bespoke
   precompiled datasets so they don't have to pick between custom
   rules and precompiled (not sure there's any demand for this but it
   seems like it might be useful).
5. If it works well enough it might actually be possible to have 0.x
   use the legacy codegen package meaning it should not need to be
   updated anymore.

This is implemented via hatch build hooks (which seem seem simpler
than doing it via setuptools in the end).

Adding `regexes.yaml` to the sdist via artifacts is a bit strange but
necessary in order to generate a complete sdist which a wheel can be
built from (even though the release script will likely only push the
wheel).
masklinn added a commit that referenced this pull request Nov 23, 2024
The goal of this is the ability to generate wheels for precompiled
instances of uap-core, at whatever version we want.

1. It resolves #146 by splitting the versioning of the API and that of
   the (pre-compiled) data, this is an issue for 1.0 as that detaches
   uap-python's versioning from uap-core's.
2. It allows users to update the API and the precompiled dataset
   separately, something they would otherwise need to do via yaml.
3. It fixes #221 by allowing the regular release of "preview"
   precompiled regexes from uap-core snapshots e.g. we could release
   0.19.dev202412 at the start of december with whatever uap-core
   merged between the previous prerelease and then. This should not be
   picked up by pip by default, but would allow users to access those
   prerelases via `pip install --pre`.
4. If done well enough, it might allow users to build bespoke
   precompiled datasets so they don't have to pick between custom
   rules and precompiled (not sure there's any demand for this but it
   seems like it might be useful).
5. If it works well enough it might actually be possible to have 0.x
   use the legacy codegen package meaning it should not need to be
   updated anymore.

This is implemented via hatch build hooks (which seem seem simpler
than doing it via setuptools in the end).

Adding `regexes.yaml` to the sdist via artifacts is a bit strange but
necessary in order to generate a complete sdist which a wheel can be
built from (even though the release script will likely only push the
wheel).
@masklinn
Copy link
Contributor

FYI between the versioning issues of trying to update the library's API and the inconsistent release schedule of uap-core, I ended up deciding to split the precompiled ruleset into its own wheel and set up the infrastructure to generate prereleases for the uap-core master, so if you upgrade to ua-parser 1.0 then upgrade the builtins to a prerelease you should have the rules you added as part of the builtins.

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.

2 participants