Package: hassle
HassleAutomate creating, building, testing, and publishing Python packages from the command line.InstallationInstall with:pip install hassleYou should be able to typehassle helpin your terminal and see a list of commands:Additional setup:Install git and add it to your PATH if it isn't already.Some parts of this tool may requirecommunicating with Github.You will also need to register apypi accountif you want to publish packages tohttps://pypi.orgwith this tool.Once you've created and validated an account, you will need to follow the directions to generate anapi key.Copy the key and in your home directory, create a '.pypirc' file if it doesn't already exist.Edit the file so it contains the following (don't include the brackets around your api key):ConfigurationAfter installation and the above additional setup, it is a good idea to run the 'configure' command.
This isn't required and a blank config will be generated whenever it is needed if it doesn't exist.
This info, if provided, is used to populate a new project's 'pyproject.toml' file.
Typinghassle help configure:You can also view the current contents with theconfigcommand:Generating New ProjectsNew projects are generated with thenewcommand:Most of these options pertain to prefilling the generated 'pyproject.toml' file.As a simple example we'll create a new package called 'nyquil':A new folder in your current working directory called 'nyquil' should now exist.It should have the following structure:Note: By default an MIT License is added to the project. Pass the-nl/--no_licenseflag to prevent this behavior.If you open the 'pyproject.toml' file it should look like the following except
for the 'project.authors' and 'project.urls' sections:The package would do absolutely nothing, but with the generated files we do have the
viable minimum to build an installable python package.Running TestsHassle usesPytestandCoverageto run tests.When we invoke thehassle testcommand,
we should see something like this (pretending we have added test functions totests/test_nyquil.py):BuildingBuilding the package is as simple as using:>hassle buildBy default, the build command will:Run any tests in thetestsfolder (abandoning the build if any fail).Format source files with isort and black.Scan project import statements and add any missing packages to the pyprojectdependenciesfield.Usepdocto generate documentation (located in a createddocsfolder).Runpython -m build .to generate thetar.gzand.whlfiles (located in a createddistfolder).PublishingAssuming you've set up aPyPiaccount, generated the api key, and configured the '.pypirc'
file as mentioned earlier, then you can publish the current version of your package by running:>hassle publishUpdatingWhen the time comes to make changes to your package, thehassle updatecommand makes it easy.This command needs at least one argument according to the type of update:major,minor, orpatch.This argument tells Hassle how to increment the project version.Hassle uses thesemantic versioning standard,
so, for example, if your current version is1.2.3then>hassle update majorbumps to2.0.0,>hassle update minorbumps to1.3.0,and>hassle update patchbumps to1.2.4.By default, the update command will:Run any tests in thetestsfolder (abandoning the update if any fail).Increment the project version.Run the build process as outlined above (minus step 1.).Make a commit with the messagechore: build {project_version}.Git tag using the tag prefix in yourhassle_config.tomlfile and the new project version.Generate/update theCHANGELOG.mdfile usingauto-changelog.(Normallyauto-changelogoverwrites the changelog file, but Hassle does some extra things so that any manual changes you make to the changelog are preserved).Git commit the changelog.Pull/push the current branch with the remote origin.Publish the updated package if the update command was run with the-pflag.Install the updated package if the update command was run with the-iflag.