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

Fix: use hatch for workflow #178

Merged
merged 4 commits into from
Feb 15, 2024
Merged

Fix: use hatch for workflow #178

merged 4 commits into from
Feb 15, 2024

Conversation

lwasser
Copy link
Member

@lwasser lwasser commented Jan 29, 2024

This is what the intro looks like fully committing to hatch. Setting up that config.toml file for default hatch settings is important as a starting point.


Copy link
Collaborator

@JacksonBurns JacksonBurns left a comment

Choose a reason for hiding this comment

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

This is a great tutorial! I just have some small mainly grammar things and a comment or two.

Dependency management|✖| Currently you have to add dependencies manually with Hatch. However a feature to support dependencies management may be added in a future release.
Environment Management |✅ | Hatch supports Python virtual environments. If you wish to use other types of environments such as Conda, you will need to [install a plugin such as hatch-conda for conda support](https://github.com/OldGrumpyViking/hatch-conda).
Publish to PyPI and test PyPI|✅|Hatch supports publishing to both test PyPI and PyPI
Version Control based versioning|✅ | Hatch offers `hatch_vcs` which is a plugin that uses setuptools_scm to support versioning using git tags. The workflow with `hatch_vcs` is the same as that with `setuptools_scm`.
Version bumping| ✅ | Hatch supports you bumping the version of your package using standard semantic version terms patch; minor; major
Follows current packaging standards|✅|Hatch supports current packaging standards for adding metadata to the **pyproject.toml** file.
Install your package in editable mode|✅| You can install your package in editable mode using `pip install -e .` Hatch mentions [editable installs](https://hatch.pypa.io/latest/config/build/#dev-mode) but refers to pip in its documentation.
Install your package in editable mode|✅| Hatch will install your package into any of it's environments by default in editable mode. You can install your package in editable mode manually using `pip install -e .` Hatch mentions [editable installs](https://hatch.pypa.io/latest/config/build/#dev-mode) but refers to pip in its documentation.
Copy link
Collaborator

Choose a reason for hiding this comment

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

"it's" -> "its"

Copy link
Member Author

Choose a reason for hiding this comment

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

very good catch ! fixed. this page has actually been reviewed many times by many people and no one else caught this! :)

Copy link
Member Author

Choose a reason for hiding this comment

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

i actually just discovered that the caption for the graphic also has a note to myself that no one caught! i'm going to pull this page out and merge it separately with all of these typo fixes!

tutorials/1-installable-code.md Outdated Show resolved Hide resolved
# View the current file structure
ls
➜ hatch new pyospackage
pyospackage
Copy link
Collaborator

Choose a reason for hiding this comment

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

Love these diagrams

tutorials/1-installable-code.md Outdated Show resolved Hide resolved

:::{note}
You will learn how to automate defining a package
version using git tags in the version and release your package lesson.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Quotes around "Version and Release Your Package"? Could help with clarity

Copy link
Collaborator

Choose a reason for hiding this comment

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

Actually I see later on in this document there is a link to the lesson, can that be put here also?

Copy link
Member Author

Choose a reason for hiding this comment

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

great suggestion. the actual tutorial on doing this with hatch isn't created ... yet! maybe i'll make this a TODO so it's hidden until we actually build and publish that lesson. that might be a good middle ground for now!

tutorials/get-to-know-hatch.md Outdated Show resolved Hide resolved
[terminal.styles]
```

Also notice that the default license option is MIT. While we will discuss license in more detail in a later lesson... the MIT license is the recommended permissive license from choosealicense.com and as such we will use it for this tutorial series.
Copy link
Collaborator

Choose a reason for hiding this comment

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

I like suggesting the MIT license

Copy link
Member Author

Choose a reason for hiding this comment

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

perfect! it does seem like a simpler choice.


A few features that hatch offers

1. it will convert metadata stored in a setup.py or setup.cfg file to a pyproject.toml file for you. While we haove not extensively tested this feature yet, please let us know if you try it!
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could be nice to include some contact info on this line to encourage more interaction!

@lwasser lwasser marked this pull request as ready for review January 30, 2024 17:01
@lwasser
Copy link
Member Author

lwasser commented Jan 30, 2024

@all-contributors please add @JacksonBurns for code, review, tutorials

Copy link
Contributor

@lwasser

I've put up a pull request to add @JacksonBurns! 🎉

* Use the shell `cd` command to navigate in your shell to the location where you'd like your package directory to live. Hatch will create the package directory for you
* Choose a name for your package. The name should:
* Have no spaces (*Required*)
* Use all lowercase characters (*Recommended*). For this tutorial we will use `pyospackage`.
Copy link
Collaborator

Choose a reason for hiding this comment

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

It might be good to say that no symbols should be used except for _ or -.

Edit: I had originally written out a bit of a post about how some prefer the project name to use all -, while some prefer all _ (which will always match the package name then) and that it's generally a bad and confusing idea to use.. But it looks like Hatch already has stong opinions about this! After running some tests, hatch new will normalize the project name to all - and the package name to all _ (even spaces get normalized to this). IME this is a fine and popular naming scheme - we should maybe just keep it in mind when crafting examples.

Copy link
Member Author

Choose a reason for hiding this comment

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

oh @ucodery gosh i had no idea that hatch normalized file names.

i just ran some tests too:

❯ hatch new test-me-foreee
test-me-foreee
├── src
│   └── test_me_foreee
│       ├── __about__.py
│       └── __init__.py
├── LICENSE.txt
├── README.md
└── pyproject.toml

so its rules are

  • dashes for the top level directory
  • dashes for the project name in the pyproject.toml
  • underscores for the package directory name

I wonder why it chose underscores only for that directory? that always confused me when i was newer to packaging - where the final name is pulled from and how the final package name could be different from the directory name.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ok this may be a bit too much. but i suspect the project directory name thing will trip users up. Mostly because it did so for me for a long time.

Screenshot 2024-02-14 at 6 29 20 PM

Copy link
Collaborator

Choose a reason for hiding this comment

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

Personally, I think a call out that hatch makes some decisions for you is enough. having that much example output is just a wall of text, especially for those that might not care about the admonition.

I wonder why it chose underscores only for that directory?

This is the one name choice that is not really a choice. The package directory becomes the final python package, the thing that gets imported, and so must follow python variable naming rules.

I suspect that hatch is running the standard name normalization on the new name, using that for the package directory, then using a .replace('_', '-') for all other names it defines.

Comment on lines +11 to +13
If you are comfortable using [pipx](https://pipx.pypa.io/stable/) to install hatch, we encourage you to do so. pipx will ensure that your package is available across all of your Python environments on your computer rather than just in the environment that you install it into.

However if you are not sure about pipx, you can install hatch using pip or conda.
Copy link
Collaborator

Choose a reason for hiding this comment

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

I love this new pipx tip!

Copy link
Member Author

Choose a reason for hiding this comment

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

yay! pipx is really growing on me. i still don't fully understand how it works on the back end but as a user, having hatch and nox, etc available to me in "all the pythons" 😆 , is really nice.

tutorials/get-to-know-hatch.md Outdated Show resolved Hide resolved
@lwasser
Copy link
Member Author

lwasser commented Feb 15, 2024

Ok y'all. this PR has been open for a few weeks and we haven't gotten a tremendous amount of additional feedback! thank you so much @ucodery and @JacksonBurns for the feedback! i think i've addressed all of the comments! I'm going to go ahead and merge it.

@lwasser lwasser merged commit d146fdb into pyOpenSci:main Feb 15, 2024
4 checks passed
@lwasser lwasser deleted the hatch-init branch February 15, 2024 01:54
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.

3 participants