Skip to content

Commit

Permalink
fix: Fix support for pipx (#286)
Browse files Browse the repository at this point in the history
  • Loading branch information
xmnlab authored May 13, 2024
1 parent fb60094 commit 0e5b125
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 17 deletions.
34 changes: 20 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,18 @@ developers to simplify the project creation process and save considerable amount
of time. SciCookie enables projects with an initial layout that includes
recommended tools, workflows, and project structure.

Cookiecutter also offers other features that can enhance the workflow of the
SciCookie also offers other features that can enhance the workflow of the
development process. Features such as _automatic documentation generation,
automated testing,_ and _project-specific configuration_ are part of this.
Overall, Cookiecutter is an efficient tool that gives users the ability to
Overall, SciCookie is an efficient tool that gives users the ability to
effortlessly create consistent, high-quality projects.

Open Science Labs Scientific Python cookiecutter template is primarily based on
the **PyOpenSci** recommendations who is actively conducting research to
determine the tools, libraries, best practices, and workflows utilized by
significant scientific Python groups. As a result, this template offers to
authors a starting point for their project that adheres with industry standards
and can be adjusted to meet particular project requirements.

[Cookiecutter](https://github.com/cookiecutter/cookiecutter) template for a
Python package.
SciCookie is primarily based on the **PyOpenSci** recommendations who is
actively conducting research to determine the tools, libraries, best practices,
and workflows utilized by significant scientific Python groups. As a result,
this template offers to authors a starting point for their project that adheres
with industry standards and can be adjusted to meet particular project
requirements.

- GitHub repo: <https://github.com/osl-incubator/scicookie/>
- Software License: BSD license
Expand Down Expand Up @@ -80,9 +77,6 @@ Python package.

## Quickstart

Install the latest Cookiecutter if you haven't installed it yet (this requires
Cookiecutter 1.0.0):

```bash
pip install scicookie
```
Expand All @@ -99,6 +93,18 @@ Generate a Python package project:
scicookie
```

You can also select a specific profile, for example:

```bash
scicookie --profile osl
```

You can also use it with `pipx`:

```bash
pipx run scicookie --profile osl
```

## Development

For testing your changes locally, you can run:
Expand Down
16 changes: 13 additions & 3 deletions src/scicookie/cli.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
"""Module with CLI functions."""

from __future__ import annotations

import argparse
import json
import os
import platform
import sys

from pathlib import Path
from typing import Union
Expand Down Expand Up @@ -97,9 +102,14 @@ def call_cookiecutter(profile: Profile, answers: dict):
choice_id = f"use_{choice.replace('-', '_')}"
answers_profile[choice_id] = "yes"

cookiecutter(
str(PACKAGE_PATH), no_input=True, extra_context=answers_profile
)
env_path_sep = ";" if platform.system() == "Windows" else ":"
pipx_path: list[str] = list(filter(lambda v: ".local/pipx" in v, sys.path))
new_path: list[str] = [*pipx_path, os.getenv("PATH", "")]
os.environ["PATH"] = env_path_sep.join(new_path)

cookiecutter(
str(PACKAGE_PATH), no_input=True, extra_context=answers_profile
)


def app():
Expand Down
1 change: 1 addition & 0 deletions src/scicookie/hooks/post_gen_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import os
import shutil
import subprocess
import sys

from pathlib import Path

Expand Down

0 comments on commit 0e5b125

Please sign in to comment.