Package: nodeps
NoDepsFeaturesGlobals to set with nodeps commandsIPython Profile :mod:ipython_profile.profile_default.ipython_config:export IPYTHONDIR="$(ipythondir)"Python Startup :mod:python_startup.__init__:export PYTHONSTARTUP="$(pythonstartup)"pytest fixturesimportpytestfromtyper.testingimportResultfromnodeps.fixturesimportskip_docker,Repos,Cli@skip_dockerdeftest_skip_docker(local:bool):"""Fixture to see if or --local passed to pytest or DOCKER or CI.Examples:pytest --localpytest --local tests/test_fixture.py::test_fixture_localpytest tests/test_fixture.py  # docker -> 2 skippedpytest tests/test_fixture.py  # 0 skipped"""assertlocalisFalse@pytest.mark.skipif("config.getoption('local') is True",reason='--local option provided')deftest_func_skipif_local_docker(local:bool):"""Should run if local is False or not --local in command."""assertlocalisFalsedeftest_fixture_repos(repos:Repos):"""Test that repos are created and pushed."""assert(repos.local.top/"README.md").is_file()assertrepos.local.git.cat_file("-e","origin/main:README.md")==""assert(repos.clone.top/"README.md").is_file()@pytest.mark.parametrize("cli",[["command","--option"]],indirect=True)deftest_current(cli:Cli):assertcli.result.exit_code==0assertcli.result.stdout=="main"@pytest.mark.parametrize("clirun",[["command","--option"]],indirect=True)deftest_current(clirun:Result):assertclirun.exit_code==0assertclirun.stdout=="main"pytest--localtests/test_docker.py# in macos to skippytesttests/test_docker.py# in docker to skipIPython extensionAdd the following to PyCharm Console:# noinspection PyUnresolvedReferencesimportnodepsIn [1]: %load_ext reload
In [2]: %reload_ext reload
In [3]: reload  # magic commandIt is the same as:importIPythonIPython.start_ipython(["--ext=nodeps"])Env class and LOGSearches for.envin cwd and up usingenvshfunctionUsage:env = Env().LOGURU_LEVELwill be set inos.environ.LOG_LEVELwill be set and parsed to int forloggingmodule.logger.setLevel(env.LOG_LEVEL)Posible values forLOGURU_LEVELandLOG_LEVEL: "TRACE", "DEBUG", "INFO", "SUCCESS", "WARNING", "ERROR", "CRITICAL".LOG_LEVELalso accepts lower case or int.Searches forsettings.iniin cwd and up. If file is foundpython-decoupleis 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 bothsettings.iniand.env:importcollectionsimportdecouple# type: ignore[attr-defined]fromnodepsimportPathEXTENSIONS=["foo","boo"]cwd=Path.cwd()files=(decouple.RepositoryIni(path.absolute())ifpath.suffix==".ini"elsedecouple.RepositoryEnv(".env")forfilein("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 packagesPipMetaPathFinderis asys.meta_pathfinder that automatically installs packages when they are imported.Task dependenciesvenvrunswriteandrequirementsbuildrunsvenv,completions,docsandclean.testsrunsbuild,ruff,pytestandtoxpublishrunstests,commit,tag,push,twineandcleanCompletionsTo install completions after a package is installed:p completions [name]orcompletions [name]ReposTo synchronize (push or pull) all repos under~/Archiveand$HOMErun:repos --syncorp repos --syncpyproject.tomlProjectProject section information inpyproject.tomlis automatically updated whenProject.write()is called, is key is not in project.
An emptypyproject.tomlis needed.ExtrasTo use all extras from nodeps to your project, add the following to yourpyproject.toml:[project.optional-dependencies]dev=["nodeps[dev]",]docs conf.py and requirements.txtdocconf.py,reference.mdandrequirements.txtare automatically updated whenProject.write()is called.usage.mdrequires 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: fullMakefilebrew:@p$@browser:@$@.PHONY:buildbuild:# run: write, docs, clean and venv (requirements)@$@builds:# run: write, docs, clean and venv (requirements)@$@clean:@$@commit:tests@$@completions:@$@coverage:@p$@.PHONY:docsdocs:@$@latest:@$@next:@$@nodeps:@python3-mpipinstall--upgrade-q$@[all,dev]publish:# runs: docs, tests (build (clean, venv (requirements)), pytest, ruff & tox), commit, tag, push, twine & clean@$@pyenv:@pyenvinstall3.11@pyenvinstall3.12-devpytest:@p$@pytests:@$@requirement:@$@--installrequirements:@$@ruff:@p$@secrets:@$@test:@p$@.PHONY:teststests:# runs: build (clean, venv (requirements)), pytest, ruff and tox@$@tox:@p$@twine:@p$@.PHONY:venvvenv:# runs: requirements@$@venvs:# runs: requirements@$@write:@p$@.DEFAULT_GOAL:=publishExtras:ansi: forgetstdoutandstripfunction usingstrip-ansilibrarycli: fortyperto have CLI forpcommand (autoinstall withpipmetapathfinder)echo: forechopackage usingclicklibraryenv: forEnvclass usingpython-decouplelibrarylog: forloggerfunction usinglogurulibrarypickle: forcachefunction usingjsonpickleandstructloglibrariespth: forPTHBuildPy,PTHDevelop,PTHEasyInstallandPTHInstallLibclasses usingsetuptoolslibrarypretty: forrichlibrary install andicecream.icconfigurationrepo: forRepoclass usinggitpythonlibraryrequests: forpython_latest,python_versionsandrequest_x_api_key_jsonfunctions that use therequestsandbeautifulsoup4librariestomlkitpackage is autoinstall withpipmetapathfinderforpyproject.tomlfile manipulation inProjectclass 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 typerPTHAdd to yoursetup.cfgand<mypackage>.pthfile in your package.[options]
cmdclass =
  build_py = nodeps.PTHBuildPy
  develop = nodeps.PTHDevelop
  easy_install = nodeps.PTHEasyInstall
  install_lib = nodeps.PTHInstallLib
[options.package_data]
mypackage =
  *.pthAdd to yourpyproject.toml:[build-system]requires=["nodeps","setuptools >= 68.2.2, <69","setuptools_scm >= 8.0.3, <9","wheel >= 0.41.2, <1"]To verify thatnodeps.pthis being installed use:python -c "import venv; print(venv.CORE_VENV_DEPS)"Post installFile_post_install.pyis automatically executed afterpip installwith thepipinstall patch.InstallationYou can installnodepsviapipfromPyPI:$pipinstallnodepsYou can installnodepswith extraspipfromPyPI:$pipinstallnodeps[repo]To install all extras but [dev] (not including development extras):$pipinstallnodeps[all]LicenseDistributed under the terms of theMIT license,nodepsis free and open source software.IssuesIf you encounter any problems,
pleasefile an issuealong with a detailed description.Credits