Python helpers and utilities with no dependencies
Project description
NoDeps
Features
Globals to set with nodeps commands
- IPython Profile :mod:
ipython_profile.profile_default.ipython_config
:export IPYTHONDIR="$(ipythondir)"
- Python Startup :mod:
python_startup.__init__
:export PYTHONSTARTUP="$(pythonstartup)"
IPython extension
Add the following to PyCharm Console:
from nodeps import load_ipython_extension
load_ipython_extension()
In [1]: %load_ext nodeps
In [2]: %reload_ext nodeps
In [3]: nodeps # magic command
It is the same as:
import IPython
IPython.start_ipython(["--ext=nodeps"])
Env class and LOG
Searches for .env
in cwd and up using envbash
function
Usage: env = Env()
.
LOGURU_LEVEL
will be set inos.environ
.LOG_LEVEL
will be set and parsed to int forlogging
module.logger.setLevel(env.LOG_LEVEL)
Posible values for LOGURU_LEVEL
and LOG_LEVEL
: "TRACE", "DEBUG", "INFO", "SUCCESS", "WARNING", "ERROR", "CRITICAL".
LOG_LEVEL
also accepts lower case or int.
Searches for settings.ini
in cwd and up. If file is found python-decouple
is used.
Usage:
var = Env()._config("VAR", default=False, cast=bool)
extensions = {*Env()._config('EXTENSIONS', default=str(extensions), cast=decouple.Csv(post_process=set)), *extensions}
To change decouple to use both settings.ini
and .env
:
import collections
import decouple # type: ignore[attr-defined]
from nodeps import Path
EXTENSIONS = ["foo", "boo"]
cwd = Path.cwd()
files = (
decouple.RepositoryIni(path.absolute()) if path.suffix == ".ini" else decouple.RepositoryEnv(".env")
for file in ("settings.ini", ) # ".env" process by envbash()
if (path := cwd.find_up())
)
config = decouple.Config(collections.ChainMap(*files))
EXTENSIONS = {
*config(
"EXTENSIONS", default=",".join(EXTENSIONS), cast=decouple.Csv(post_process=set)
),
*EXTENSIONS,
}
Automatic installation of packages
PipMetaPathFinder
is a sys.meta_path
finder that automatically installs packages when they are imported.
Task dependencies
venv
runswrite
andrequirements
build
runsvenv
,completions
,docs
andclean
.tests
runsbuild
,ruff
,pytest
andtox
publish
runstests
,commit
,tag
,push
,twine
andclean
Completions
To install completions after a package is installed:
p completions [name]
or completions [name]
Repos
To synchronize (push or pull) all repos under ~/Archive
and $HOME
run: repos --sync
or p repos --sync
pyproject.toml
Project
Project section information in pyproject.toml
is automatically updated when Project.write()
is called, is key is not in project.
An empty pyproject.toml
is needed.
Extras
To use all extras from nodeps to your project, add the following to your pyproject.toml
:
[project.optional-dependencies]
dev = [
"nodeps[dev]",
]
docs conf.py and requirements.txt
doc conf.py
, reference.md
and requirements.txt
are automatically updated when Project.write()
is called.
usage.md
requires a click instance in __main__.py
:
<app_name>_click = typer.main.get_command(<Typer instance>)
# Usage
```{eval-rst}
.. click:: pdf.__main__:<app_name>_click
:prog: reembolsos
:nested: full
Makefile
brew:
@p $@
browser:
@$@
.PHONY: build
build: # run: write, docs, clean and venv (requirements)
@$@
builds: # run: write, docs, clean and venv (requirements)
@$@
clean:
@$@
commit: tests
@$@
completions:
@$@
coverage:
@p $@
.PHONY: docs
docs:
@$@
latest:
@$@
next:
@$@
nodeps:
@python3 -m pip install --upgrade -q $@[all,dev]
publish: # runs: docs, tests (build (clean, venv (requirements)), pytest, ruff & tox), commit, tag, push, twine & clean
@$@
pyenv:
@pyenv install 3.11
@pyenv install 3.12-dev
pytest:
@p $@
pytests:
@$@
requirement:
@$@ --install
requirements:
@$@
ruff:
@p $@
secrets:
@$@
test:
@p $@
.PHONY: tests
tests: # runs: build (clean, venv (requirements)), pytest, ruff and tox
@$@
tox:
@p $@
twine:
@p $@
.PHONY: venv
venv: # runs: requirements
@$@
venvs: # runs: requirements
@$@
write:
@p $@
.DEFAULT_GOAL := publish
Extras:
ansi
: forgetstdout
andstrip
function usingstrip-ansi
librarycli
: fortyper
to have CLI forp
command (autoinstall withpipmetapathfinder
)echo
: forecho
package usingclick
libraryenv
: forEnv
class usingpython-decouple
librarylog
: forlogger
function usingloguru
librarypickle
: forcache
function usingjsonpickle
andstructlog
librariespth
: forPTHBuildPy
,PTHDevelop
,PTHEasyInstall
andPTHInstallLib
classes usingsetuptools
librarypretty
: forrich
library install andicecream.ic
configurationrepo
: forRepo
class usinggitpython
libraryrequests
: forpython_latest
,python_versions
andrequest_x_api_key_json
functions that use therequests
andbeautifulsoup4
libraries
tomlkit
package is autoinstall with pipmetapathfinder
for pyproject.toml
file manipulation in Project
class and __main__.py
.
Aggregated extras:
- nodeps[all] includes all extras except dev.
- nodeps[dev] includes all dev extras.
- nodeps[full] includes all extras including dev [all,dev].
Test imports uninstalling: pip uninstall loguru beautifulsoup4 click jsonpickle strip_ansi structlog typer
PTH
Add to your setup.cfg
and <mypackage>.pth
file in your package.
[options]
cmdclass =
build_py = nodeps.PTHBuildPy
develop = nodeps.PTHDevelop
easy_install = nodeps.PTHEasyInstall
install_lib = nodeps.PTHInstallLib
[options.package_data]
mypackage =
*.pth
Add to your pyproject.toml
:
[build-system]
requires = [
"nodeps",
"setuptools >= 68.2.2, <69",
"setuptools_scm >= 8.0.3, <9",
"wheel >= 0.41.2, <1"
]
To verify that nodeps.pth
is being installed use:
python -c "import venv; print(venv.CORE_VENV_DEPS)"
Post install
File _post_install.py
is automatically executed after pip install
with the pip
install patch.
Installation
You can install nodeps via pip from PyPI:
$ pip install nodeps
You can install nodeps with extras pip from PyPI:
$ pip install nodeps[repo]
To install all extras but [dev] (not including development extras):
$ pip install nodeps[all]
License
Distributed under the terms of the MIT license, nodeps is free and open source software.
Issues
If you encounter any problems, please file an issue along with a detailed description.
Credits
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.