Skip to content

Commit 244e84d

Browse files
committed
Rename pyrootutils to rootutils
1 parent a80ac07 commit 244e84d

File tree

7 files changed

+30
-31
lines changed

7 files changed

+30
-31
lines changed

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ jobs:
5959
pip install -r requirements.txt
6060
6161
- name: Run tests and collect coverage
62-
run: pytest --cov pyrootutils
62+
run: pytest --cov rootutils
6363

6464
- name: Upload coverage to Codecov
6565
uses: codecov/codecov-action@v3

README.md

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
1-
# pyrootutils
1+
# rootutils
22

33
[![Python](https://img.shields.io/badge/python-3.7+-blue.svg)](https://www.python.org/downloads/release/python-370/)
4-
[![Tests](https://github.com/ashleve/pyrootutils/actions/workflows/test.yml/badge.svg?branch=main&event=push)](https://github.com/ashleve/pyrootutils/actions/workflows/test.yml)
5-
[![Codecov](https://codecov.io/gh/ashleve/pyrootutils/branch/main/graph/badge.svg)](https://codecov.io/gh/ashleve/pyrootutils)
6-
[![Build](https://github.com/ashleve/pyrootutils/actions/workflows/publish_package.yml/badge.svg)](https://github.com/ashleve/pyrootutils/actions/workflows/publish_package.yml)
7-
[![Issues](https://img.shields.io/github/issues/ashleve/pyrootutils)](https://github.com/ashleve/pyrootutils/issues)
8-
[![License](https://img.shields.io/github/license/ashleve/pyrootutils)](https://github.com/ashleve/pyrootutils/blob/main/LICENSE)
9-
[![Release](https://img.shields.io/pypi/v/pyrootutils)](pypi.org/project/pyrootutils/1.0.0/)
10-
[![PyPi](https://img.shields.io/pypi/dm/pyrootutils)](pypi.org/project/pyrootutils/1.0.0/)
4+
[![Tests](https://github.com/ashleve/rootutils/actions/workflows/test.yml/badge.svg?branch=main&event=push)](https://github.com/ashleve/rootutils/actions/workflows/test.yml)
5+
[![Codecov](https://codecov.io/gh/ashleve/rootutils/branch/main/graph/badge.svg)](https://codecov.io/gh/ashleve/rootutils)
6+
[![Build](https://github.com/ashleve/rootutils/actions/workflows/publish_package.yml/badge.svg)](https://github.com/ashleve/rootutils/actions/workflows/publish_package.yml)
7+
[![Issues](https://img.shields.io/github/issues/ashleve/rootutils)](https://github.com/ashleve/rootutils/issues)
8+
[![License](https://img.shields.io/github/license/ashleve/rootutils)](https://github.com/ashleve/rootutils/blob/main/LICENSE)
9+
[![Release](https://img.shields.io/pypi/v/rootutils)](pypi.org/project/rootutils/1.0.5/)
10+
[![PyPi](https://img.shields.io/pypi/dm/rootutils)](pypi.org/project/rootutils/1.0.5/)
1111

1212
A simple python package to solve all your problems with pythonpath, working directory, file paths, module imports and environment variables.
1313

14-
## Why pyrootutils?
14+
## Why rootutils?
1515

1616
**Problem:** I would like to be able to:
1717

@@ -21,35 +21,35 @@ A simple python package to solve all your problems with pythonpath, working dire
2121
- Always have access to environment variables from `.env` file without having to load them manually
2222
- Have all the above benefits in notebooks even if they're nested in subdirectories
2323

24-
**Solution:** The `pyrootutils` package provides a flexible way to setup the python project with a simple one-liner. It finds the project root based on the location of specified file name, e.g. `.project-root` or `.git`.
24+
**Solution:** The `rootutils` package provides a flexible way to setup the python project with a simple one-liner. It finds the project root based on the location of specified file name, e.g. `.project-root` or `.git`.
2525

2626
The package is tiny and continuosly maintained.
2727

2828
## Setup
2929

3030
```bash
31-
pip install pyrootutils
31+
pip install rootutils
3232
```
3333

3434
## Usage
3535

3636
```python
37-
import pyrootutils
37+
import rootutils
3838

3939
# find absolute root path (searches for directory containing .project-root file)
4040
# search starts from current file and recursively goes over parent directories
4141
# returns pathlib object
42-
path = pyrootutils.find_root(search_from=__file__, indicator=".project-root")
42+
path = rootutils.find_root(search_from=__file__, indicator=".project-root")
4343

4444
# find absolute root path (searches for directory containing any of the files on the list)
45-
path = pyrootutils.find_root(search_from=__file__, indicator=[".git", "setup.cfg"])
45+
path = rootutils.find_root(search_from=__file__, indicator=[".git", "setup.cfg"])
4646

4747
# take advantage of the pathlib syntax
4848
data_dir = path / "data"
4949
assert data_dir.exists(), f"path doesn't exist: {data_dir}"
5050

5151
# set root directory
52-
pyrootutils.set_root(
52+
rootutils.set_root(
5353
path=path # path to the root directory
5454
project_root_env_var=True, # set the PROJECT_ROOT environment variable to root directory
5555
dotenv=True, # load environment variables from .env if exists in root directory
@@ -60,8 +60,8 @@ pyrootutils.set_root(
6060

6161
Simplest usage with one-liner (combines `find_root()` and `set_root()` into one method):
6262
```python
63-
import pyrootutils
64-
root = pyrootutils.setup_root(__file__, dotenv=True, pythonpath=True, cwd=False)
63+
import rootutils
64+
root = rootutils.setup_root(__file__, dotenv=True, pythonpath=True, cwd=False)
6565
```
6666

6767
## Defaults
@@ -74,7 +74,7 @@ Default root indicators (used when you don't specify `indicator` arg):
7474

7575
## Autoroot
7676

77-
`autoroot` is an experimental package that reduces `pyrootutils` to single import, without the need to execute any setup calls. This means just the act of importing this dependency (`import autorootcwd`) causes execution of recurrent search for `.project-root` file.
77+
`autoroot` is an experimental package that reduces `rootutils` to single import, without the need to execute any setup calls. This means just the act of importing this dependency (`import autorootcwd`) causes execution of recurrent search for `.project-root` file.
7878

7979
Installation:
8080
```bash

pyrootutils/__init__.py

Lines changed: 0 additions & 3 deletions
This file was deleted.

rootutils/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from .rootutils import find_root, set_root, setup_root
2+
3+
__all__ = ["find_root", "set_root", "setup_root"]
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from dotenv import load_dotenv
77

88

9-
def _pyrootutils_recursive_search(path: Path, indicators: Iterable[str]) -> Optional[Path]:
9+
def _rootutils_recursive_search(path: Path, indicators: Iterable[str]) -> Optional[Path]:
1010
"""Recursively search for files from the `indicators` list, starting from given path.
1111
1212
Args:
@@ -24,7 +24,7 @@ def _pyrootutils_recursive_search(path: Path, indicators: Iterable[str]) -> Opti
2424
if path.parent == path:
2525
return None
2626

27-
return _pyrootutils_recursive_search(path.parent, indicators)
27+
return _rootutils_recursive_search(path.parent, indicators)
2828

2929

3030
def find_root(
@@ -64,7 +64,7 @@ def find_root(
6464
if not hasattr(indicator, "__iter__") or not all(isinstance(i, str) for i in indicator):
6565
raise TypeError("indicator must be a string or list of strings.")
6666

67-
path = _pyrootutils_recursive_search(search_from, indicator)
67+
path = _rootutils_recursive_search(search_from, indicator)
6868

6969
if not path or not path.exists():
7070
raise FileNotFoundError(f"Project root directory not found. Indicators: {indicator}")

setup.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@
55

66

77
setup(
8-
name="pyrootutils",
9-
version="1.0.4",
8+
name="rootutils",
9+
version="1.0.5",
1010
license="MIT",
1111
description="Simple package for easy project root setup",
1212
long_description=long_description,
1313
long_description_content_type="text/markdown",
14-
url="https://github.com/ashleve/pyrootutils",
14+
url="https://github.com/ashleve/rootutils",
1515
author="ashleve",
1616
author_email="ashlevegalaxy@gmail.com",
1717
packages=find_packages(),
Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44

55
import pytest
66

7-
from pyrootutils import find_root, set_root, setup_root
7+
from rootutils import find_root, set_root, setup_root
88

99

10-
def test_pyrootutils():
10+
def test_rootutils():
1111
assert find_root
1212
assert set_root
1313
assert setup_root
@@ -55,7 +55,6 @@ def test_find_root():
5555

5656

5757
def test_set_root():
58-
5958
path = find_root(__file__)
6059
assert path.exists()
6160

0 commit comments

Comments
 (0)