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

feat: add .tool-versions and prompt for poetry_version #37

Merged
merged 12 commits into from
Mar 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions cookiecutter.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"project_name_underscored": "{{ cookiecutter.project_name.lower().replace(' ', '_') }}",
"github_username": "elixir-cloud-aai",
"python_version": "3.13.0",
"poetry_version": "1.8.5",
"add_script": "y",
"year": "{% now 'utc', '%Y' %}",
"add_pypi_release_ci": "y",
Expand All @@ -29,6 +30,7 @@
"project_name_dashed": "Distribution name <lowercase, hyphens, no spaces> (used on PyPI)",
"github_username": "GitHub account name (used in repo URL and package metadata)",
"python_version": "Minimum Python version <X.Y.Z format> (used in dependency specification)",
"poetry_version": "Poetry version <X.Y.Z format>",
"add_script": "CLI tool inclusion flag <y/n> (used in build configuration)",
"add_pypi_release_ci": "PyPI publishing automation flag <y/n>"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ RUN sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master
&& git clone https://github.com/zsh-users/zsh-autosuggestions.git ${ZSH_CUSTOM}/plugins/zsh-autosuggestions \
&& git clone https://github.com/zdharma-continuum/fast-syntax-highlighting.git ${ZSH_CUSTOM}/plugins/fast-syntax-highlighting

# Clone asdf scripts
RUN git clone https://github.com/asdf-vm/asdf.git ~/.asdf

# Install direnv
RUN curl -sfL https://direnv.net/install.sh | bash

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ export ZSH="/root/.oh-my-zsh"

# Plugins
plugins=(
asdf # Sets up asdf version manager
direnv # Loads .envrc files
git # Adds git command aliases and useful prompt info
docker # Provides docker command completion and aliases
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ inputs:
default: '{{ cookiecutter.python_version }}'
description: The version of Python to use
poetry-version:
default: '1.8.2'
default: '{{ cookiecutter.poetry_version }}'
description: The version of Poetry to install
poetry-install-options:
default: ''
Expand All @@ -19,7 +19,7 @@ inputs:
default: ''
description: Options to pass to poetry export for hash generation for cache
invalidation

{% raw %}
runs:
using: composite
steps:
Expand Down
2 changes: 2 additions & 0 deletions {{ cookiecutter.project_name_dashed }}/.tool-versions
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
poetry {{ cookiecutter.poetry_version }}
python {{ cookiecutter.python_version }}
9 changes: 9 additions & 0 deletions {{ cookiecutter.project_name_dashed }}/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ help:
@echo " \033[1m\033[35mdocs\033[0m \033[37m(d)\033[0m: \033[36mGenerate project documentation.\033[0m\n"

@echo "Environment Management --------------------------------------------------------"
@echo " \033[1m\033[35masdf-install\033[0m \033[37m(asdfi)\033[0m: \033[36mTry to install tools listed in .tool-versions.\033[0m"
@echo " \033[1m\033[35mclean-venv\033[0m \033[37m(cv)\033[0m: \033[36mRemove virtual environment.\033[0m"
@echo " \033[1m\033[35minstall\033[0m \033[37m(i)\033[0m: \033[36mInstall app and dependencies.\033[0m"
@echo " \033[1m\033[35mvenv\033[0m \033[37m(v)\033[0m: \033[36mCreate virtual environment.\033[0m\n"
Expand All @@ -39,6 +40,14 @@ help:
# NOTE: Do not modify the autogenerated targets, unless necessary, write custom
# targets in the custom section below..

.PHONY: asdf-install asdfi
asdf-install:
@echo "\nInstalling ASDF Plugins & Tools +++++++++++++++++++++++++++++++++++++++++++++++\n"
@cat .tool-versions | cut -d' ' -f1 | grep "^[^\#]" | xargs -I {} asdf plugin add {}
@asdf install

asdfi: asdf-install

.PHONY: clean-venv cv
clean-venv:
@echo "\nRemoving the virtual environment ++++++++++++++++++++++++++++++++++++++++++++++\n"
Expand Down
35 changes: 35 additions & 0 deletions {{ cookiecutter.project_name_dashed }}/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
- [Development](#development)
- [Makefile](#makefile)
- [Environment reproducibility](#environment-reproducibility)
- [asdf](#asdf)
- [Dev containers](#dev-containers)
- [Editor config](#editor-config)
- [Setting environment variables (direnv)](#setting-environment-variables-direnv)
Expand Down Expand Up @@ -128,6 +129,38 @@ make u

### Environment reproducibility

Below mentioned are some tools and configuration that you can use to make your
environment development-ready. This is optional and opinionated but can help you
set up your environment quickly.

#### asdf

We recommend using [asdf][asdf] to manage your development environment
efficiently. This tool allows you to handle multiple language versions and tools
seamlessly. You can install asdf by following the
[official installation guide][asdf-install]. If you are working within
[dev containers](#dev-containers), asdf will come pre-installed.

The project includes a `.tool-versions` file, which lists the specific versions
of tools used. This ensures consistency across environments. To streamline the
installation process, use the following command to install the required tools
defined in the `.tool-versions` file:

```sh
make asdfi
```

> **Note:** The `make asdfi` command might not install every tool listed in
> the `.tool-versions` file. After running the command, verify that all
> necessary tools are installed. If any tools are missing, install them
> manually using asdf.

Example manual installation command:

```sh
asdf install <tool-name> <version>
```

#### Dev Containers

Our project supports [Dev Containers][devcontainers] for an easy and reproducible
Expand Down Expand Up @@ -237,6 +270,8 @@ To get in touch with us, please use one of the following routes:

[![logo-elixir]][elixir] [![logo-elixir-cloud-aai]][elixir-cloud-aai]

[asdf]: https://asdf-vm.com/
[asdf-install]: https://asdf-vm.com/guide/getting-started.html
[badge-chat-url]: https://join.slack.com/t/elixir-cloud/shared_invite/enQtNzA3NTQ5Mzg2NjQ3LTZjZGI1OGQ5ZTRiOTRkY2ExMGUxNmQyODAxMDdjM2EyZDQ1YWM0ZGFjOTJhNzg5NjE0YmJiZTZhZDVhOWE4MWM
[badge-license-url]: http://www.apache.org/licenses/LICENSE-2.0
[code-of-conduct]: https://elixir-cloud-aai.github.io/about/code-of-conduct/
Expand Down