Skip to content

Commit

Permalink
fix: Fix issues with dependencies and default tools (#274)
Browse files Browse the repository at this point in the history
  • Loading branch information
xmnlab authored May 3, 2024
1 parent 6722b04 commit ed65b11
Show file tree
Hide file tree
Showing 15 changed files with 860 additions and 775 deletions.
8 changes: 4 additions & 4 deletions .makim.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
version: 1.0
groups:
clean:
targets:
tasks:
tmp:
help: Clean unnecessary temporary files
shell: bash
Expand All @@ -20,7 +20,7 @@ groups:
find . -name '*~' -exec rm -f {} +
docs:
targets:
tasks:
build:
help: Build documentation
run: |
Expand All @@ -45,7 +45,7 @@ groups:
-p "@google/semantic-release-replace-plugin" \
semantic-release
targets:
tasks:
dry:
help: Run semantic release in dry-run mode
run: ${{ vars.app }} --dry-run
Expand All @@ -54,7 +54,7 @@ groups:
run: ${{ vars.app }} --ci

tests:
targets:
tasks:
lint:
help: Run linter tools
run: pre-commit run --all-files --verbose
Expand Down
2 changes: 1 addition & 1 deletion conda/dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ dependencies:
- compilers
- pip
- pip:
- makim==1.12.0
- makim==1.15.1
- paginate
1,234 changes: 614 additions & 620 deletions poetry.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ mkdocs-material = ">=8.3.9"
mkdocstrings-python = ">=0.7.1"
mkdocstrings-python-legacy = ">=0.2.3"
pymdown-extensions = ">=9.5"
makim = ">=1.14.0,<1.15"
makim = "1.15.1"

[build-system]
requires = ["poetry-core>=1.0.0"]
Expand Down
13 changes: 7 additions & 6 deletions src/scicookie/cookiecutter.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@
"pybind11"
],
"use_bandit": "no",
"use_black": "yes",
"use_conda": "yes",
"use_makim": "yes",
"use_black": "no",
"use_conda": "no",
"use_makim": "no",
"use_make": "no",
"use_containers": ["None", "Docker", "Podman"],
"use_coverage": "no",
Expand All @@ -51,11 +51,12 @@
"use_isort": "no",
"use_mccabe": "no",
"use_mypy": "no",
"use_pre_commit": "yes",
"use_pre_commit": "no",
"use_prettier": "no",
"use_pydocstyle": "no",
"use_pytest": "yes",
"use_ruff": "yes",
"use_pyenv": "no",
"use_pytest": "no",
"use_ruff": "no",
"use_shellcheck": "no",
"use_vulture": "no",
"git_username": "zoro_roronoa",
Expand Down
47 changes: 34 additions & 13 deletions src/scicookie/hooks/post_gen_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@
USE_MAKIM = {{ cookiecutter.use_makim == "yes" }}
USE_MYPY = {{ cookiecutter.use_mypy == "yes" }}
USE_PRETTIER = {{ cookiecutter.use_prettier == "yes" }}
USE_PRE_COMMIT = {{ cookiecutter.use_pre_commit == "yes" }}
USE_PYTEST = {{ cookiecutter.use_pytest == "yes" }}
USE_HYPOTHESIS = {{ cookiecutter.use_hypothesis == "yes" }}
{% if cookiecutter.code_of_conduct == "contributor-covenant" -%}
COC_PATH = PROJECT_DIRECTORY / 'coc' / 'CONTRIBUTOR_COVENANT.md'
{%- elif cookiecutter.code_of_conduct == "citizen-code-of-conduct" -%}
Expand Down Expand Up @@ -119,6 +122,11 @@ def move_selected_doc_dir():
shutil.rmtree(DOCS_SPEC_DIR)


def clean_up_tests():
if not USE_PYTEST and not USE_HYPOTHESIS:
remove_project_file("tests/test_main.py")


def clean_up_automation():
if not USE_MAKE:
remove_project_file("Makefile")
Expand Down Expand Up @@ -185,11 +193,6 @@ def clean_up_cli():
remove_package_file("cli.py")


def clean_up_prettier():
if not USE_PRETTIER:
remove_project_file(".prettierrc.yaml")
remove_project_file(".prettierignore")

def clean_up_build_system():
build_system_dir = PROJECT_DIRECTORY / "build-system"

Expand Down Expand Up @@ -274,6 +277,28 @@ def http2ssh(url):
url = url.replace("https://", "git@")
return url.replace("/", ":", 1)

def clean_up_linter():
if not USE_MYPY:
remove_package_file("py.typed")

if not USE_PRE_COMMIT:
remove_project_file(".pre-commit-config.yaml")

if not USE_PRETTIER:
remove_project_file(".prettierrc.yaml")
remove_project_file(".prettierignore")

# keep this one at the end
if USE_PRETTIER:
subprocess.call([
"npx",
"--yes",
"prettier",
"--write",
"--ignore-unknown",
PROJECT_DIRECTORY
])


def prepare_git() -> None:
git_https_origin = http2ssh("{{cookiecutter.git_https_origin}}")
Expand Down Expand Up @@ -362,27 +387,23 @@ def add_binding_source_files():
pass


def clean_up_mypy():
if not USE_MYPY:
remove_package_file("py.typed")


def post_gen():

# keep this one first, because it changes the package folder
clean_up_project_layout()
add_binding_source_files()
clean_up_automation()
clean_up_cli()
clean_up_mypy()
clean_up_code_of_conduct()
clean_up_conda()
clean_up_containers()
clean_up_docs()
clean_up_governance()
clean_up_roadmap()
clean_up_build_system()
clean_up_prettier()
clean_up_tests()

# keep it before the prepare_git function call
clean_up_linter()

# keep it at the end, because it will create a new git commit
prepare_git()
Expand Down
22 changes: 14 additions & 8 deletions src/scicookie/{{cookiecutter.project_slug}}/.makim.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
version: 1.0
groups:
clean:
targets:
tasks:
all:
help: Clean unnecessary temporary files
run: |
Expand All @@ -26,7 +26,7 @@ groups:
find . -name '*~' -exec rm -f {} +
docs:
targets:
tasks:
build:
help: Build documentation
run: |
Expand All @@ -47,7 +47,7 @@ groups:
preview:
help: Preview documentation page locally
dependencies:
- target: docs.build
- task: docs.build
run: |
{%- if cookiecutter.documentation_engine == "jupyter-book" %}
cd docs/_build/html/ && python -m http.server
Expand All @@ -60,7 +60,7 @@ groups:
{%- endif %}
tests:
targets:
tasks:
linter:
help: Run linter tools
run: |
Expand All @@ -79,16 +79,22 @@ groups:
type: string
default: "-vv"
run: |
{%- if cookiecutter.use_pytest == "yes" %}
pytest {{ "${{ args.path }} ${{ args.params }}" }}
{%- elif cookiecutter.use_hypothesis == "yes" %}
python -m unittest discover
{%- else %}
echo "No test library installed."
{%- endif %}
ci:
help: run the sames tests executed on CI
dependencies:
- target: tests.unit
- target: tests.linter
- task: tests.unit
- task: tests.linter

package:
targets:
tasks:
build:
help: "Build the package"
run: |
Expand Down Expand Up @@ -124,7 +130,7 @@ groups:
-p "@google/semantic-release-replace-plugin" \
semantic-release
targets:
tasks:
ci:
help: run semantic release on CI
run: {{ "${{ vars.app }} --ci" }}
Expand Down
2 changes: 1 addition & 1 deletion src/scicookie/{{cookiecutter.project_slug}}/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ test: ## run tests quickly with the default Python
{%- elif cookiecutter.use_hypothesis == "yes" %}
python -m unittest discover
{%- else %}
@echo "No test library selected."
@echo "No test library installed."
{%- endif %}

{% if cookiecutter.documentation_engine == 'mkdocs' -%}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,4 +86,5 @@ warn_unused_ignores = true
warn_redundant_casts = true
warn_unused_configs = true
{% endif -%}
{#- keep this line at the end of the file -#}
{# keep this line at the end of the file #}
# Add more configuration here!
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,16 @@ dynamic = ["version"]
{% endif -%}
requires-python = ">=3.8.1,<4"
dependencies = [
# note: add your dependencies here
]
{# keep this line here #}
{%- if cookiecutter.build_system == "pdm" %}
[tool.pdm.dev-dependencies]
{%- else %}
# NOTE: it is not actually optional, instead it is development dependencies
[project.optional-dependencies]
{%- endif %}
dev = [
{#- keep this line here -#}
{%- if cookiecutter.build_system in ["setuptools", "pybind11"] %}
"build>=0.10.0",
Expand Down Expand Up @@ -91,7 +101,7 @@ dependencies = [
"pydocstyle >= 6.3.0",
{%- endif -%}
{%- if cookiecutter.use_makim == "yes" %}
"makim>=1.14.0,<1.15",
"makim == 1.15.1",
{%- endif -%}
{%- if cookiecutter.use_vulture == "yes" %}
"vulture >= 2.7",
Expand All @@ -115,23 +125,20 @@ dependencies = [
"mkdocs-material >= 9.1.15",
"mkdocstrings >= 0.21.2",
"mkdocstrings-python >= 1.1.2",
{# keep this line here #}
{%- elif cookiecutter.documentation_engine == 'sphinx' %}
"Sphinx >= 6.2.1",
"sphinx-rtd-theme >= 1.2.2",
"importlib-metadata >= 6.5.1",
"myst-parser >= 0.19.2",
"nbsphinx >= 0.9.2",
"pandoc >= 2.3",
{# keep this line here #}
{%- elif cookiecutter.documentation_engine == 'jupyter-book' %}
"jupyter-book >= 0.15.1",
"myst-parser >= 0.18.1",
{# keep this line here #}
{%- elif cookiecutter.documentation_engine == 'quarto' %}
"quarto-cli >= 1.4.550",
"quartodoc >= 0.7.2",
{% endif -%}
{%- endif %}
# 'PosixPath' object has no attribute 'endswith'
"virtualenv<=20.25.1",
]
Expand All @@ -141,3 +148,4 @@ Homepage = "{{ cookiecutter.project_url }}"
"Bug Tracker" = "{{ cookiecutter.project_url }}/issues"
Discussions = "{{ cookiecutter.project_url }}/discussions"
Changelog = "{{ cookiecutter.project_url }}/releases"
{#- keep this line at the end of the file -#}
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ quarto-cli = ">=1.4.550"
quartodoc = ">=0.7.2"
{% endif -%}
{%- if cookiecutter.use_makim == "yes" -%}
makim = ">=1.14.0,<1.15"
makim = "1.15.1"
{% endif -%}
# 'PosixPath' object has no attribute 'endswith'
virtualenv = "<=20.25.1"
Expand Down
Loading

0 comments on commit ed65b11

Please sign in to comment.