python-package-guide icon indicating copy to clipboard operation
python-package-guide copied to clipboard

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

Open pb-413 opened this issue 1 year ago • 6 comments

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 avatar May 20 '24 16:05 pb-413

  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!)
  1. Rename the src\pyospackage folder to the same name, pyospackage_<your_github>
  • e.g. src\pyospackage_pb_413
  1. 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
  5. Recreate environment with hatch env create
  • not sure if this is necessary; lmk if I should try without
  1. 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 avatar May 20 '24 16:05 pb-413

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 avatar May 20 '24 18:05 pb-413

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

pb-413 avatar May 21 '24 16:05 pb-413

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!

lwasser avatar May 31 '24 00:05 lwasser

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

kierisi avatar May 31 '24 21:05 kierisi

@kierisi

@pb-413 already contributed before to code, review

allcontributors[bot] avatar May 31 '24 21:05 allcontributors[bot]