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 python modules #258

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

Conversation

SomeoneSerge
Copy link

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

$ nix shell github:SomeoneSerge/pkgs#prefix-python-modules
$ prefix-python-modules . --prefix dino

This change extends generic names, like utils, with the project project name.
This way dino can be used in the same PYTHONPATH with other projects without the risk of collision

The extra commit also adds a pyproject.toml file, which is just an easy way to have wheels automatically generated. Wheels make it easier to package dino in distributions, including those other than pypi.

The changes have been tested in a somewhat automated way12. Happy to revert or extend any particular bit if you like, just hoping to get the actual prefixes merged. Thanks

Footnotes

  1. https://github.com/SomeoneSerge/pkgs/blob/0d2b35d8704636ffb6538c24b4e5c180d9bb17a3/python-packages/by-name/om/omnimotion/preprocess-dataset.nix#L14-L18

  2. https://github.com/SomeoneSerge/pkgs/blob/0d2b35d8704636ffb6538c24b4e5c180d9bb17a3/python-packages/by-name/di/dino/package.nix#L29

This is a semi-automated change:

```bash
$ sed -i \
  -e 's/^\(\s*\)\(state_dict = torch.hub\)/\1print(f"Going to download {url=} via torch.hub")\n\1\2/' \
  utils.py
$ pname=dino
$ prefix-python-modules . --prefix $pname
```
@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Nov 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants