Skip to content

temporal: Update and vendor ply dependency per repo's instructions as no longer published #5942

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

Open
wants to merge 16 commits into
base: main
Choose a base branch
from

Conversation

echoix
Copy link
Member

@echoix echoix commented Jun 22, 2025

Closes #5917

I updated my old branch that updated the ply dependency with a vendored copy, as per the author's instructions.

Tests still pass in CI, and it is also adjusted to be built with CMake. The dependency is removed from the various lists.

@echoix echoix requested a review from wenzeslaus June 22, 2025 15:16
@github-actions github-actions bot added windows Microsoft Windows specific macOS macOS specific linux Linux specific docker Docker related CI Continuous integration temporal Related to temporal data processing Python Related code is in Python HTML Related code is in HTML libraries module docs markdown Related to markdown, markdown files CMake labels Jun 22, 2025
for n, s in enumerate(syms):
if s[0] in "'\"":
try:
c = eval(s)

Check warning

Code scanning / Bandit

Use of possibly insecure function - consider using safer ast.literal_eval. Warning

Use of possibly insecure function - consider using safer ast.literal_eval.
Copy link
Member

Choose a reason for hiding this comment

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

From the following error message, "Literal token %s in rule %r may only be a single character" it seems ast.literal_eval may be enough, but I didn't get anything beyond that. We can make sure we test well enough our use cases (and we do have a good coverage of temporal things already) and just try to replace it.

Copy link
Member Author

@echoix echoix Jul 4, 2025

Choose a reason for hiding this comment

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

Do you want to do changes to the upstream code right away in the initial PR, or try to have them later on so we can separate out changes from the upstream changes? We have to think for the next time we sync the code

Copy link
Contributor

Choose a reason for hiding this comment

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

If we don't add a README (or similar) with list of patches added, we should add the original version as is. Then git history will tell what modifications we have made.

Copy link
Member

Choose a reason for hiding this comment

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

Git is the way to go because it will be automated as opposed to keeping a list. The security check produces a warning, but will let us merge without anything special. Let's merge the original, unpatched version.

@nilason
Copy link
Contributor

nilason commented Jun 22, 2025

PLY comes with ctypesgen (https://github.com/OSGeo/grass/tree/main/python/libgrass_interface_generator/ctypesgen/parser). Not sure if we should use that one instead…

@echoix
Copy link
Member Author

echoix commented Jun 22, 2025

PLY comes with ctypesgen (https://github.com/OSGeo/grass/tree/main/python/libgrass_interface_generator/ctypesgen/parser). Not sure if we should use that one instead…

At the time, I didn't want to couple the ply version from ctypesgen into our runtime code. Its already hard enough to get ctypesgen updated, so I left their version alone, it works with their code. Ply, in the python grass.temporal code, is distributed at runtime. I think ctypesgen is meant to be a compile-time tool, and not really distributed.

for n, s in enumerate(syms):
if s[0] in "'\"":
try:
c = eval(s)

Check warning

Code scanning / Bandit

Use of possibly insecure function - consider using safer ast.literal_eval.

Use of possibly insecure function - consider using safer ast.literal_eval.
@nilason
Copy link
Contributor

nilason commented Jul 8, 2025

PLY in ctypesgen could have been used, only copied at build. But, the embedded PLY in ctypesgen does have minor patch(es), so we should avoid that.
For the general idea of embed PLY with GRASS, it is a good one. It contains only two files. And as stated upstream:

The PLY project will make no further package-installable releases. If you want the latest version, you'll need to download it here or clone the repo.

As I understand it, it will not be updated with pip and similar anyway.

@wenzeslaus
Copy link
Member

PLY in ctypesgen could have been used, only copied at build. But, the embedded PLY in ctypesgen does have minor patch(es), so we should avoid that. For the general idea of embed PLY with GRASS, it is a good one.

Whatever you think is the best. I don't get what role ctypesgen plays in PLY. It is using existing C headers?

It contains only two files. And as stated upstream:

The PLY project will make no further package-installable releases. If you want the latest version, you'll need to download it here or clone the repo.

As I understand it, it will not be updated with pip and similar anyway.

Anyway, including PLY sounds as the right solution.

@echoix
Copy link
Member Author

echoix commented Jul 15, 2025

PLY in ctypesgen could have been used, only copied at build. But, the embedded PLY in ctypesgen does have minor patch(es), so we should avoid that. For the general idea of embed PLY with GRASS, it is a good one.
Whatever you think is the best. I don't get what role ctypesgen plays in PLY. It is using existing C headers?

It doesn't. It only itself embeds an older copy, and usually we don't have ctypesgen available at runtime once installed (at least we don't want to, it's a build time tool, and ply is an implementation detail).

The implementation detail part is the reasoning of the author of not publishing newer releases. As most projects should end up tuning their use of it.

@nilason
Copy link
Contributor

nilason commented Jul 16, 2025

I don't get what role ctypesgen plays in PLY. It is using existing C headers?

Ctypesgen uses PLY, in a central role for parsing C headers, and has it embedded, and in extension we already have it in the GRASS repo. But ctypesgen's embedded version contains minor "hacks", and is the latest released version 3.11 (from 2018).

This PR adds the current snapshot of PLY (from master), last updated in 2022, which is not ideal but I suppose ok.

@wenzeslaus
Copy link
Member

Oh, that's the other way around than I thought, that makes more sense. Let's have another PLY for our (direct) use, then.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CI Continuous integration CMake docker Docker related docs HTML Related code is in HTML libraries linux Linux specific macOS macOS specific markdown Related to markdown, markdown files module Python Related code is in Python temporal Related to temporal data processing windows Microsoft Windows specific
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Skip temporal algebra tests when ply is not installed
3 participants