pyOpenSci / python-package-guide

scientific Python package recommendations & guidance curated by pyOpenSci
https://www.pyopensci.org/python-package-guide/
Other
70 stars 43 forks source link

TODO - How to update your package name / prevent name overlap by adding your github to the package name #261

Open pb-413 opened 1 month ago

pb-413 commented 1 month ago

Glad to see this is a TODO:

https://github.com/pyOpenSci/python-package-guide/blob/a9fc8c19b1b63113fea3b66bd06177c53be2aa5a/tutorials/publish-pypi.md?plain=1#L206C1-L213C4

I will document the steps I take here; if desired, I can make a PR with changes that walk a reader through these steps.

Also, we should consider updating earlier steps (if we want to avoid needing to rename) to create the tutorial package with a better name. e.g. hatch new pyospackage_<your-github-here> , hatch new pyospackage_pb-413.

pb-413 commented 1 month ago
  1. Replace all references to pyospackage in pyproject.toml to pyospackage_<your_github>
    • e.g. pyospackage_pb_413
    • It cannot have hyphens (-) as separators; use underscores (_) instead
    • pb-413 -> pb_413 -> pyospackage_pb_413 ( not pyospackage_pb-413!)
  2. Rename the src\pyospackage folder to the same name, pyospackage_<your_github>
    • e.g. src\pyospackage_pb_413
  3. Delete old hatch env?
    • not 100% sure this was necessary; lmk if I should double check that
    • steps:
      1. hatch env show -> grab name; for me, default
      2. hatch env find default -> grab path
      3. navigate to path in explorer
      4. delete contents of ...\hatch\env\virtual\, 3 levels up
  4. Recreate environment with hatch env create
    • not sure if this is necessary; lmk if I should try without
  5. Rebuild with hatch build

Note: I had errors when I renamed to a name with hyphens. I think your documentation already mentioned something about that, but it was on a previous page. Here is the error that pointed me to renaming that; hatch seemed to be looking for the same folder name but with underscores instead of hyphens:

> hatch env create
error: subprocess-exited-with-error

  Preparing editable metadata (pyproject.toml) did not run successfully.
  exit code: 1

  [42 lines of output]
  # big stack trace
  The most likely cause of this is that there is no directory that matches the name of your project (pyospackage_pb_413).
  # extra info

References: https://hatch.pypa.io/dev/tutorials/environment/basic-usage/#locating-environments

pb-413 commented 1 month ago

Just found out there is a command to prune (delete all) or remove (delete named) environments in hatch:

> hatch env
Usage: hatch env [OPTIONS] COMMAND [ARGS]...

Options:
  -h, --help  Show this message and exit.

Commands:
  create  Create environments
  find    Locate environments
  prune   Remove all environments
  remove  Remove environments
  run     Run commands within project environments
  show    Show the available environments

Those might be better than locating and manually deleting environments.

pb-413 commented 1 month ago

This might be a duplicate of #244, or maybe it is just related.

lwasser commented 1 month ago

thank you... let's see what @Tyler-Bonnell thinks about the change. i did just merge it!! but actually i think you have a bit more information related to hatch and environments potentially here too. i can look at this more closely later or someone else in our team can do it!

kierisi commented 1 month ago

@all-contributors add @pb-413 for code, review

allcontributors[bot] commented 1 month ago

@kierisi

@pb-413 already contributed before to code, review