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

Prefix top-level modules: * -> raft.* #176

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

SomeoneSerge
Copy link

@SomeoneSerge SomeoneSerge commented Nov 3, 2023

This change is semi-automated and relies on the python-rope/rope refactoring library:

$ nix shell github:SomeoneSerge/pkgs#prefix-python-modules
$ pname=raft
$ find -iname '*.py' -exec \
  sed -i 's/sys.path.append.*$/pass/' '{}' '+'
$ rm -rf alt_cuda_corr # confuses rope, recover later
$ prefix-python-modules . --prefix "$pname"
$ prefix-python-modules . --prefix "$pname" \
    --rename-external 'utils' "$pname".core.utils "**" \
    --rename-external 'update' "$pname".core.update "**" \
    --rename-external 'extractor' "$pname".core.extractor "**" \
    --rename-external 'corr' "$pname".core.corr "**"
$ git checkout -- alt_cuda_corr

This change augments generic names like core and utils, which are unspecific and may cause conflicts when used as top-level, with project name as the prefix. This change makes it easier to just compose raft in the same environment with other projects without "human intervention" or microservices. In particular, this makes it easier to run comparisons against the exact code, rather than reimplementations. E.g. sys.path manipulations and git-submodules -> raft used as a library

One of the commits also adds pyproject.toml: this was just the easiest way to have wheels and entry points automatically generated, both when used with pip, and when packaging for other distributions (wheels have been somewhat of an exchange format lately)

I didn't try restructuring alt_cuda_corr, other than prefixing the .so and the .dist-info with raft_, because there are other projects that intend to ship this exact same module, but may actually diverge in the implementation. I thought it reasonable that each project would use its own version of the kernel, because that's safer and not much more expensive

The top-level project declares raft-alt-cuda-corr as Requires-dist:. The intention is that, when used outside the dev environment, the kernel package is just installed first. Cf. an example

I can revert any particular bit if you like, but it would be nice if you agreed with the prefix thing, because that really makes consumption easier, regardless of distro/environment/etc

This is a semi-automated change based on python-rope/rope:

```bash
$ pname=raft
$ find -iname '*.py' -exec \
  sed -i 's/sys.path.append.*$/pass/' '{}' '+'
$ rm -rf alt_cuda_corr # confuses rope, recover later
$ prefix-python-modules . --prefix "$pname"
$ prefix-python-modules . --prefix "$pname" \
    --rename-external 'utils' "$pname".core.utils "**" \
    --rename-external 'update' "$pname".core.update "**" \
    --rename-external 'extractor' "$pname".core.extractor "**" \
    --rename-external 'corr' "$pname".core.corr "**"
$ git checkout -- alt_cuda_corr
```
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