Skip to content

Commit

Permalink
Rename project from python-hugo to hugo
Browse files Browse the repository at this point in the history
Closes #20
  • Loading branch information
agriyakhetarpal authored Jan 8, 2024
2 parents eb685b0 + 31e9fc3 commit d1bcf41
Show file tree
Hide file tree
Showing 9 changed files with 59 additions and 55 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ go.work
.DS_Store

# Binaries
python_hugo/binaries/*
hugo/binaries/*

# ruff cache
.ruff_cache/
Expand Down
4 changes: 2 additions & 2 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
include licenses/LICENSE-hugo.txt
include python_hugo/binaries/*
exclude python_hugo/binaries/hugo-*
include hugo/binaries/*
exclude hugo/binaries/hugo-*
62 changes: 30 additions & 32 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,19 @@

[actions-badge]: https://github.com/agriyakhetarpal/hugo-python-distributions/workflows/CI/badge.svg
[actions-link]: https://github.com/agriyakhetarpal/hugo-python-distributions/actions
[pypi-link]: https://pypi.org/project/python-hugo/
[pypi-platforms]: https://img.shields.io/pypi/pyversions/python-hugo/
[pypi-version]: https://img.shields.io/pypi/v/python-hugo/
[pypi-downloads-total]: https://img.shields.io/pypi/dd/python-hugo/
[pypi-downloads-monthly]: https://img.shields.io/pypi/dm/python-hugo/
[license-badge]: https://img.shields.io/pypi/l/python-hugo?color=lavender
[pypi-link]: https://pypi.org/project/hugo/
[pypi-platforms]: https://img.shields.io/pypi/pyversions/hugo/
[pypi-version]: https://img.shields.io/pypi/v/hugo/
[pypi-downloads-total]: https://static.pepy.tech/badge/hugo/
[pypi-downloads-monthly]: https://static.pepy.tech/badge/hugo/month/
[license-badge]: https://img.shields.io/pypi/l/hugo?color=lavender
[license-link]: https://apache.org/licenses/LICENSE-2.0
[hugo-badge]: https://img.shields.io/badge/hugo-extended-pink.svg?style=flat&logo=hugo
[hugo-link]: https://gohugo.io/
[docs-link]: https://github.com/agriyakhetarpal/hugo-python-distributions/
[docs-badge]: https://img.shields.io/badge/docs-read%20on%20GitHub-blue.svg?style=flat&logo=github


| Classifiers | Description |
| ------ | ----------- |
| Builds | [![Actions Status][actions-badge]][actions-link] |
Expand All @@ -22,32 +23,22 @@

Binaries for the extended version of the Hugo static site generator, installable via `pip`

This package provides wheels for [Hugo](https://gohugo.io/) to be used with `pip` on macOS, Linux, and Windows; for Python versions 3.8–3.12.
This package provides wheels for [Hugo](https://gohugo.io/) so that it can be used with `pip` on macOS, Linux, and Windows; for Python versions 3.8–3.12.

## What is Hugo?

[Hugo](https://gohugo.io/) is a static site generator written in [Go](https://golang.org/). It is designed to be fast and flexible, and it is used by many people and organizations for their websites, documentation, and personal blogs.

## What version of `python-hugo` do I install?

This package, `python-hugo` is versioned separately and will adhere to an [amalgamation](https://jacobtomlinson.dev/posts/2023/sometimes-i-regret-using-calver/) of [CalVer](https://calver.org/) (calendar versioning) and [SemVer](https://semver.org/) (semantic versioning) software standards, which is subject to change if deemed absolutely necessary. A release for `python-hugo` will be versioned as `YY.M.PATCH` where `YY` is the year, `M` is the month, and `PATCH` is the patch number of the release. For example, `31.8.2` shall be the release for `python-hugo` on August 2031, patch number 2. This is done to avoid confusion with the versioning of Hugo itself, which uses `SemVer` – but is likely versioned according to [0ver](https://0ver.org/) software standards based on their [versioning history](https://github.com/gohugoio/hugo/releases). A bump in the `python-hugo` version does not necessarily mean a bump in the Hugo version, and vice versa, but it is likely that a bump in the PATCH number of `python-hugo` will correspond to a new release of Hugo, as mentioned in the table below.

The version of `python-hugo` you install will correspond to a particular version of Hugo as listed in the following table in ascending order of `python-hugo` version.

<!-- NOTE: add versions to this table as we go along with releases. -->

| `python-hugo` version | Hugo (extended) version |
| --------------------- | ------------------------------------------------------------------- |
| `24.1.0` | [`0.121.1`](https://github.com/gohugoio/hugo/releases/tag/v0.121.1) |
| `24.1.1` | [`0.121.2`](https://github.com/gohugoio/hugo/releases/tag/v0.121.2) |
> [!NOTE]
> This distribution of `Hugo` is currently not affiliated with the official `Hugo` project. Please refer to the [Hugo documentation](https://gohugo.io/documentation/) for more information on Hugo.
<!-- NOTE: add versions to this table as we go along with releases. -->
## What version of `hugo` do I install?

If you would like to use any available version of Hugo, you don't need to worry about this and you can just install the latest version of `python-hugo` on PyPI.
This package, `hugo` is versioned alongside the Hugo releases and is aligned with the versioning of Hugo itself, which uses `SemVer` – but is likely versioned according to [0ver](https://0ver.org/) software standards based on their [versioning history](https://github.com/gohugoio/hugo/releases).

If you would like to use a specific version of Hugo, you can install the corresponding version of `python-hugo` as listed in the table above.
Binaries for `hugo` through these wheels are available for Hugo versions **0.121.2** and above. If you need an older version of `hugo` that is not available through this package, please consider using the [official Hugo binaries](https://github.com/gohugoio/hugo/releases).

Please refer to the section on [Supported platforms](#supported-platforms) for a list of `python-hugo`'s supported platforms and architectures. If it does, jump to the [Quickstart](#quickstart) section to get started.
Please refer to the section on [Supported platforms](#supported-platforms) for a list of wheels available for supported platforms and architectures. If it does, jump to the [Quickstart](#quickstart) section to get started.

## Documentation

Expand All @@ -57,20 +48,20 @@ Create a virtual environment and install the package (or install it globally on

```bash
python -m virtualenv venv # (or your preferred method of creating virtual environments)
pip install python-hugo
pip install hugo
```

This places a `hugo` executable in a `binaries` directory in your virtual environment and adds an entry point to it.

Alternatively, you can install the package globally on your system:

```bash
python3.X -m pip install python-hugo # Unix
py -m pip install python-hugo # Windows
python3.X -m pip install hugo # Unix
py -m pip install hugo # Windows
```

> [!TIP]
> It is a great idea to use [`pipx`](https://github.com/pypa/pipx) to install Hugo in an isolated location without having to create a virtual environment, which will allow you to use Hugo as a command-line tool without having to install it globally on your system. Please refer to the [`pipx` documentation](https://pipx.pypa.io/stable/) for more information.
> It is a great idea to use [`pipx`](https://github.com/pypa/pipx) to install or use Hugo in an isolated location without having to create a virtual environment, which will allow you to run Hugo as a command-line tool without having to install it globally on your system. Please refer to the [`pipx` documentation](https://pipx.pypa.io/stable/) for more information.
Then, you can use the `hugo` commands as you would normally:

Expand All @@ -79,24 +70,26 @@ hugo version
hugo env --logLevel info
```

and

```bash
hugo new site mysite
hugo --printI18nWarnings server
# and so on
...
```

Virtual environments allow multiple versions of Hugo to be installed and used side-by-side. To use a specific version of Hugo, you can specify the version when installing the package (please refer to [What version of `python-hugo` do I install?](#what-version-of-python-hugo-do-i-install) for more information):
Virtual environments can allow multiple versions of Hugo to be installed and used side-by-side. To use a specific version of Hugo, you can specify the version when installing the package (please refer to the section [_What version of `hugo` do I install?_](#what-version-of-hugo-do-i-install) for more information):

```bash
pip install "python-hugo==24.1.1"
pip install "hugo==0.121.2"
```

For more information on using Hugo and its command-line interface, please refer to the [Hugo documentation](https://gohugo.io/documentation/) and [Hugo CLI documentation](https://gohugo.io/commands/).

### Supported platforms

A subset of the platforms supported by Hugo itself are supported by `python-hugo`. The plan is to support as many platforms as possible with Python wheels and platform tags. Please refer to the following table for a list of supported platforms and architectures:
A subset of the platforms supported by Hugo itself are supported by these wheels for `hugo` via `hugo-python-distributions`. The plan is to support as many platforms as possible with Python wheels and platform tags. Please refer to the following table for a list of supported platforms and architectures:

| Platform | Architecture | Supported |
| -------- | --------------- | ------------------------------- |
Expand Down Expand Up @@ -179,8 +172,8 @@ This package is designed to be used in the following scenarios:
- You want to use Hugo in a Python-based project, such as a static site generator that uses Hugo as a backend?
- You want to test a new version of Hugo without having to install it globally on your system or affecting your existing Hugo installation
- Python wheels allow for incredibly fast installation, in comparison to using other methods of installing Hugo such as system package managers
- Easier updates to the latest version of Hugo through the use of the `pip install --upgrade python-hugo` command, and automatic updates if you use a package manager such as [Poetry](https://python-poetry.org/) or [PDM](https://pdm.fming.dev/) to manage your Python dependencies or a tool such as [pipx](https://pipxproject.github.io/pipx/) to manage your command-line tools
- ...and so on
- Easy updates to the latest version of Hugo through the use of the `pip install --upgrade hugo` command, and automatic updates possible too if you use a package manager such as [Poetry](https://python-poetry.org/) or [PDM](https://pdm.fming.dev/) to manage your Python dependencies or a tool such as [pipx](https://pipxproject.github.io/pipx/) to manage your command-line tools
- ...and more!

#### (Known) limitations

Expand All @@ -190,3 +183,8 @@ This package is designed to be used in the following scenarios:
### Licensing

This project is licensed under the terms of the [Apache 2.0 license](LICENSE). Hugo is available under Apache 2.0 (see [the Hugo license](licenses/LICENSE-hugo.txt)) as well.

### Footnotes

- This project is currently not affiliated with the official Hugo project. Please refer to the [Hugo documentation](https://gohugo.io/documentation/) for more information on Hugo.
- The author of this project: @agriyakhetarpal, would like to express a token of gratitude to the owner of the `Hugo` package on PyPI (@nariman) for their kind gesture of granting access to take over the package name with the underlying provisions of PEP 541. This way, it allows users to install the package using the same name as the official Hugo project, which undoubtedly provides for a better user experience and convenience to users of this package when compared to the previous package name, `python-hugo`.
4 changes: 2 additions & 2 deletions python_hugo/__init__.py → hugo/__init__.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
"""
Copyright (c) 2023 Agriya Khetarpal. All rights reserved.
python-hugo: Binaries for the Hugo static site generator, installable with pip
hugo: Binaries for the Hugo static site generator, installable with pip
"""

from __future__ import annotations

from python_hugo.cli import __call
from hugo.cli import __call

# Hugo binary entry point caller
if __name__ == "__main__":
Expand Down
File renamed without changes.
9 changes: 6 additions & 3 deletions python_hugo/cli.py → hugo/cli.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""
Copyright (c) 2023 Agriya Khetarpal. All rights reserved.
python-hugo: Binaries for the Hugo static site generator, installable with pip
hugo: Binaries for the Hugo static site generator, installable with pip
"""

from __future__ import annotations
Expand Down Expand Up @@ -44,16 +44,19 @@ def hugo_executable():
)


MESSAGE = f"Running Hugo {HUGO_VERSION} via python-hugo at {hugo_executable()}"
MESSAGE = (
f"Running Hugo {HUGO_VERSION} via hugo-python-distributions at {hugo_executable()}"
)


def __call():
"""
Hugo binary entry point. Passes all command-line arguments to Hugo.
"""
print(MESSAGE)
if sysplatform == "win32":
# execvp broken on Windows, use subprocess instead to not launch a new shell
print(f"\033[95m{MESSAGE}\033[0m")
check_call([hugo_executable(), *argv[1:]])
else:
print(f"\033[95m{MESSAGE}\033[0m")
execvp(hugo_executable(), ["hugo", *argv[1:]])
7 changes: 3 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ requires = ["setuptools>=64", "pooch", "tqdm", "wheel==0.42.0"]
build-backend = "setuptools.build_meta"

[project]
name = "python-hugo"
name = "hugo"
authors = [
{ name = "Agriya Khetarpal", email = "[email protected]" },
]
Expand All @@ -12,10 +12,9 @@ maintainers = [
]
description = "Binaries for the Hugo static site generator, installable with pip"
readme = "README.md"
version = "24.1.1"
license = {text = "Apache License v2.0"}
requires-python = ">=3.8,<3.13"
dynamic = ["scripts"]
dynamic = ["scripts", "version"]
classifiers = [
"Development Status :: 3 - Alpha",
"Intended Audience :: Developers",
Expand Down Expand Up @@ -45,7 +44,7 @@ Issues = "https://github.com/agriyakhetarpal/hugo-python-distributions/issues"
Changelog = "https://github.com/agriyakhetarpal/hugo-python-distributions/releases"

[tool.ruff]
src = ["python_hugo"]
src = ["hugo"]
extend-select = [
"B", # flake8-bugbear
"I", # isort
Expand Down
2 changes: 2 additions & 0 deletions scripts/ci/tools/macos/fuse_wheels.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,6 @@ def copy_if_universal(wheel_name, in_dir, out_dir):
src_path = Path(out_dir) / wheel_name
dest_path = Path(out_dir) / wheel_name_new

print(f"Renamed wheel {wheel_name} to {wheel_name_new}")

Path(src_path).rename(dest_path)
24 changes: 13 additions & 11 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from setuptools.command.build_ext import build_ext
from wheel.bdist_wheel import bdist_wheel, get_platform

# Has to be kept in sync with the version in python_hugo/cli.py
# Has to be kept in sync with the version in hugo/cli.py and incantation of setup()
HUGO_VERSION = "0.121.2"
HUGO_RELEASE = (
f"https://github.com/gohugoio/hugo/archive/refs/tags/v{HUGO_VERSION}.tar.gz"
Expand Down Expand Up @@ -90,13 +90,13 @@ def run(self):
tar.extractall(path=HUGO_CACHE_DIR)

# The binary is put into GOBIN, which is set to the package directory
# (python_hugo/binaries/) for use in editable mode. The binary is copied
# (hugo/binaries/) for use in editable mode. The binary is copied
# into the wheel afterwards
# Error: GOBIN cannot be set if GOPATH is set when compiling for different
# architectures, so we use the default GOPATH/bin as the place to copy
# binaries from
# os.environ["GOBIN"] = os.path.join(
# os.path.dirname(os.path.abspath(__file__)), "python_hugo", "binaries"
# os.path.dirname(os.path.abspath(__file__)), "hugo", "binaries"
# )
os.environ["CGO_ENABLED"] = "1"
os.environ["GOPATH"] = os.path.abspath(HUGO_CACHE_DIR) # noqa: PTH100
Expand Down Expand Up @@ -159,12 +159,12 @@ def run(self):
)
original_name.rename(new_name)

# Copy the new_name file into a folder binaries/ inside python_hugo/
# Copy the new_name file into a folder binaries/ inside hugo/
# so that it is included in the wheel.
# basically we are copying hugo-HUGO_VERSION-PLATFORM-ARCH into
# python_hugo/binaries/ and creating the folder if it does not exist.
# hugo/binaries/ and creating the folder if it does not exist.

binaries_dir = Path(__file__).parent / "python_hugo" / "binaries"
binaries_dir = Path(__file__).parent / "hugo" / "binaries"
if not binaries_dir.exists():
binaries_dir.mkdir()

Expand Down Expand Up @@ -262,7 +262,7 @@ def run(self):
# into the wheel.
hugo_binary = (
Path(__file__).parent
/ "python_hugo"
/ "hugo"
/ "binaries"
/ (
f"hugo-{HUGO_VERSION}-{HUGO_PLATFORM}-{os.environ.get('GOARCH', HUGO_ARCH)}"
Expand All @@ -284,7 +284,7 @@ def run(self):
Extension(
name="hugo.build",
sources=[
f"python_hugo/binaries/hugo-{HUGO_VERSION}-{HUGO_PLATFORM}-{os.environ.get('GOARCH', HUGO_ARCH)}"
f"hugo/binaries/hugo-{HUGO_VERSION}-{HUGO_PLATFORM}-{os.environ.get('GOARCH', HUGO_ARCH)}"
+ FILE_EXT
],
)
Expand All @@ -294,13 +294,15 @@ def run(self):
"clean": Cleaner,
"bdist_wheel": HugoWheel,
},
packages=["python_hugo", "python_hugo.binaries"],
packages=["hugo", "hugo.binaries"],
package_data={
"python_hugo": [
"hugo": [
f"binaries/hugo-{HUGO_VERSION}-{HUGO_PLATFORM}-{os.environ.get('GOARCH', HUGO_ARCH)}"
+ FILE_EXT
],
},
include_package_data=True,
entry_points={"console_scripts": ["hugo=python_hugo.cli:__call"]},
entry_points={"console_scripts": ["hugo=hugo.cli:__call"]},
# has to be kept in sync with the version in hugo/cli.py
version=HUGO_VERSION,
)

0 comments on commit d1bcf41

Please sign in to comment.