Skip to main content

Create, build, test, and publish Python projects and packages.

Project description

Hassle

Automate creating, building, testing, and publishing Python packages from the command line.

Installation

Install with:

pip install hassle

You should be able to type hassle help in 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 require communicating with Github.
You will also need to register a pypi account if you want to publish packages to https://pypi.org with this tool.
Once you've created and validated an account, you will need to follow the directions to generate an api 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):

Configuration

After 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. Typing hassle help configure:

You can also view the current contents with the config command:

Generating New Projects

New projects are generated with the new command:

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_license flag 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 Tests

Hassle uses Pytest and Coverage to run tests.
When we invoke the hassle test command, we should see something like this (pretending we have added test functions to tests/test_nyquil.py):

Building

Building the package is as simple as using:

>hassle build

By default, the build command will:

  1. Run any tests in the tests folder (abandoning the build if any fail).
  2. Format source files with isort and black.
  3. Scan project import statements and add any missing packages to the pyproject dependencies field.
  4. Use pdoc to generate documentation (located in a created docs folder).
  5. Run python -m build . to generate the tar.gz and .whl files (located in a created dist folder).

Publishing

Assuming you've set up a PyPi account, 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 publish

Updating

When the time comes to make changes to your package, the hassle update command makes it easy.
This command needs at least one argument according to the type of update: major, minor, or patch.
This argument tells Hassle how to increment the project version.
Hassle uses the semantic versioning standard, so, for example, if your current version is 1.2.3 then

>hassle update major bumps to 2.0.0,
>hassle update minor bumps to 1.3.0,
and
>hassle update patch bumps to 1.2.4.

By default, the update command will:

  1. Run any tests in the tests folder (abandoning the update if any fail).
  2. Increment the project version.
  3. Run the build process as outlined above (minus step 1.).
  4. Make a commit with the message chore: build {project_version}.
  5. Git tag using the tag prefix in your hassle_config.toml file and the new project version.
  6. Generate/update the CHANGELOG.md file using auto-changelog.
    (Normally auto-changelog overwrites the changelog file, but Hassle does some extra things so that any manual changes you make to the changelog are preserved).
  7. Git commit the changelog.
  8. Pull/push the current branch with the remote origin.
  9. Publish the updated package if the update command was run with the -p flag.
  10. Install the updated package if the update command was run with the -i flag.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

hassle-3.1.10.tar.gz (16.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

hassle-3.1.10-py3-none-any.whl (18.3 kB view details)

Uploaded Python 3

File details

Details for the file hassle-3.1.10.tar.gz.

File metadata

  • Download URL: hassle-3.1.10.tar.gz
  • Upload date:
  • Size: 16.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.0

File hashes

Hashes for hassle-3.1.10.tar.gz
Algorithm Hash digest
SHA256 bf49bc41ae3d95b45da4e726259ecabee9772f2e1430a953b4cf2f1f11f73455
MD5 1e2518bb67606e5afc463b41a9a389ad
BLAKE2b-256 bba411ffdae03b087839859571f437024fb1be985b13af27966b2e54cc2b3d30

See more details on using hashes here.

File details

Details for the file hassle-3.1.10-py3-none-any.whl.

File metadata

  • Download URL: hassle-3.1.10-py3-none-any.whl
  • Upload date:
  • Size: 18.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.0

File hashes

Hashes for hassle-3.1.10-py3-none-any.whl
Algorithm Hash digest
SHA256 4ae98f4fb93c0891772b8920d90ac9d66e3b7f1dd620935faf564bdc717ee276
MD5 c142abb4ba5e3cacc1a7c46658d4426b
BLAKE2b-256 daa13ec09cb1e56722cdf20e91d4f66e9d11a5e84f27f83975cf57ced130888e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page