setenvironment


Namesetenvironment JSON
Version 2.0.3 PyPI version JSON
download
home_pagehttps://github.com/zackees/setenvironment
SummaryCross platform(ish) productivity commands written in python.
upload_time2023-10-15 20:54:54
maintainer
docs_urlNone
author
requires_python>=3.7
licenseBSD 3-Clause License
keywords setenvironment
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # setenvironment

[![MacOS_Tests](https://github.com/zackees/setenvironment/actions/workflows/push_macos.yml/badge.svg)](https://github.com/zackees/setenvironment/actions/workflows/push_macos.yml)
[![Win_Tests](https://github.com/zackees/setenvironment/actions/workflows/push_win.yml/badge.svg)](https://github.com/zackees/setenvironment/actions/workflows/push_win.yml)
[![Ubuntu_Tests](https://github.com/zackees/setenvironment/actions/workflows/push_ubuntu.yml/badge.svg)](https://github.com/zackees/setenvironment/actions/workflows/push_ubuntu.yml)

[![Linting](https://github.com/zackees/setenvironment/actions/workflows/lint.yml/badge.svg)](https://github.com/zackees/setenvironment/actions/workflows/lint.yml)

Finally, a cross platform way to set system environment variables and paths that are persistant across reboots.

Works with Windows, MacOS and Linux and github runners, see note below.

Extensively tested.

## Command line interface

```bash
# Setting environmental variables
setenvironment show
setenviornment bashrc  # unix only.
setenvironment set foo bar
setenvironment has foo
setenvironment get foo
setenvironment del foo
# Path manipulation.
setenvironment addpath /my/path
setenvironment get PATH
setenvironment delpath /my/path
setenvironment refresh "echo this command is in a refreshed environment"
```

## Python API

```python
from setenvironment import (
    set_env_var, add_env_path, unset_env_var, remove_env_path, set_config_file, reload_environment, ...
)
# by default, ~/.bashrc is used
set_env_var("FOO", "BAR")
get_env_var("FOO") # returns BAR
add_env_path("MYPATH")
unset_env_var("FOO")
remove_env_path("MYPATH")
# use ~/.bash_profile instead (no op on Windows)
set_config_file("~/.bash_profile")
set_env_var("FOO", "BAR")
add_env_path("MYPATH")
unset_env_var("FOO")
remove_env_path("MYPATH")
# Loads settings into the current environment. This reads the
# registry on windows or the ~/.bashrc file on unix.
reload_environment()
# Path groups are usefull for uninstall programs. Each add
# copies the path both into the PATH and also to the key.
# When you want to remove paths you can query the key and selectively
# remove paths that are in the set.
add_to_path_group("MYPATHKEY", "/path/to/dir")
remove_to_path_group("MYPATHKEY", "/path/to/dir")
# Or else you can just remove ALL of the paths at once.
remove_path_group("MYPATHKEY")
```


## Github

These are designed to be compatible with github runners.

Ubuntu MUST use the following to make this package work.

```
name: Ubuntu_Tests

# Directs GitHub to run tests using ~/.bashrc
defaults:
    run:
      shell: bash -ieo pipefail {0}

on: [push]
```

## Windows

Paths are set in the registery and the current os.environ

  * writes to the registery
  * broadcasts the new value (cmd.exe ignores this though) to all available processes
  * paths like `/my/path` will be converted to `\\my\\path`

## MacOS / Linux

Paths are set in either `~/.bash_aliases` or `~/.bash_profile` or `~/.bashrc` file or you can override it, see `set_config_file(...)` and the command line arguments if using the command line api.

  * export the variable (so you can source the script)
  * set the os.environ to the proper value
  * write the value to the .bashrc file (make sure it's chmod +w)


# Release Notes
  * 2.0.3: Disables the refresh.cmd, since it doesn't work for subprocesses.
  * 2.0.2: Re-enabled broadcast changes on win32, fixing new terminal launch.
  * 2.0.1: Bug fix.
  * 2.0.0: Rewrite. New command line api. Extensively tested on mac/win/ubuntu X github.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/zackees/setenvironment",
    "name": "setenvironment",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": "",
    "keywords": "setenvironment",
    "author": "",
    "author_email": "",
    "download_url": "https://files.pythonhosted.org/packages/1b/74/7cdc8d78e06e32955f14c0ac6b4905bf1375d60968a61144b8b358ae3760/setenvironment-2.0.3.tar.gz",
    "platform": null,
    "description": "# setenvironment\r\n\r\n[![MacOS_Tests](https://github.com/zackees/setenvironment/actions/workflows/push_macos.yml/badge.svg)](https://github.com/zackees/setenvironment/actions/workflows/push_macos.yml)\r\n[![Win_Tests](https://github.com/zackees/setenvironment/actions/workflows/push_win.yml/badge.svg)](https://github.com/zackees/setenvironment/actions/workflows/push_win.yml)\r\n[![Ubuntu_Tests](https://github.com/zackees/setenvironment/actions/workflows/push_ubuntu.yml/badge.svg)](https://github.com/zackees/setenvironment/actions/workflows/push_ubuntu.yml)\r\n\r\n[![Linting](https://github.com/zackees/setenvironment/actions/workflows/lint.yml/badge.svg)](https://github.com/zackees/setenvironment/actions/workflows/lint.yml)\r\n\r\nFinally, a cross platform way to set system environment variables and paths that are persistant across reboots.\r\n\r\nWorks with Windows, MacOS and Linux and github runners, see note below.\r\n\r\nExtensively tested.\r\n\r\n## Command line interface\r\n\r\n```bash\r\n# Setting environmental variables\r\nsetenvironment show\r\nsetenviornment bashrc  # unix only.\r\nsetenvironment set foo bar\r\nsetenvironment has foo\r\nsetenvironment get foo\r\nsetenvironment del foo\r\n# Path manipulation.\r\nsetenvironment addpath /my/path\r\nsetenvironment get PATH\r\nsetenvironment delpath /my/path\r\nsetenvironment refresh \"echo this command is in a refreshed environment\"\r\n```\r\n\r\n## Python API\r\n\r\n```python\r\nfrom setenvironment import (\r\n    set_env_var, add_env_path, unset_env_var, remove_env_path, set_config_file, reload_environment, ...\r\n)\r\n# by default, ~/.bashrc is used\r\nset_env_var(\"FOO\", \"BAR\")\r\nget_env_var(\"FOO\") # returns BAR\r\nadd_env_path(\"MYPATH\")\r\nunset_env_var(\"FOO\")\r\nremove_env_path(\"MYPATH\")\r\n# use ~/.bash_profile instead (no op on Windows)\r\nset_config_file(\"~/.bash_profile\")\r\nset_env_var(\"FOO\", \"BAR\")\r\nadd_env_path(\"MYPATH\")\r\nunset_env_var(\"FOO\")\r\nremove_env_path(\"MYPATH\")\r\n# Loads settings into the current environment. This reads the\r\n# registry on windows or the ~/.bashrc file on unix.\r\nreload_environment()\r\n# Path groups are usefull for uninstall programs. Each add\r\n# copies the path both into the PATH and also to the key.\r\n# When you want to remove paths you can query the key and selectively\r\n# remove paths that are in the set.\r\nadd_to_path_group(\"MYPATHKEY\", \"/path/to/dir\")\r\nremove_to_path_group(\"MYPATHKEY\", \"/path/to/dir\")\r\n# Or else you can just remove ALL of the paths at once.\r\nremove_path_group(\"MYPATHKEY\")\r\n```\r\n\r\n\r\n## Github\r\n\r\nThese are designed to be compatible with github runners.\r\n\r\nUbuntu MUST use the following to make this package work.\r\n\r\n```\r\nname: Ubuntu_Tests\r\n\r\n# Directs GitHub to run tests using ~/.bashrc\r\ndefaults:\r\n    run:\r\n      shell: bash -ieo pipefail {0}\r\n\r\non: [push]\r\n```\r\n\r\n## Windows\r\n\r\nPaths are set in the registery and the current os.environ\r\n\r\n  * writes to the registery\r\n  * broadcasts the new value (cmd.exe ignores this though) to all available processes\r\n  * paths like `/my/path` will be converted to `\\\\my\\\\path`\r\n\r\n## MacOS / Linux\r\n\r\nPaths are set in either `~/.bash_aliases` or `~/.bash_profile` or `~/.bashrc` file or you can override it, see `set_config_file(...)` and the command line arguments if using the command line api.\r\n\r\n  * export the variable (so you can source the script)\r\n  * set the os.environ to the proper value\r\n  * write the value to the .bashrc file (make sure it's chmod +w)\r\n\r\n\r\n# Release Notes\r\n  * 2.0.3: Disables the refresh.cmd, since it doesn't work for subprocesses.\r\n  * 2.0.2: Re-enabled broadcast changes on win32, fixing new terminal launch.\r\n  * 2.0.1: Bug fix.\r\n  * 2.0.0: Rewrite. New command line api. Extensively tested on mac/win/ubuntu X github.\r\n",
    "bugtrack_url": null,
    "license": "BSD 3-Clause License",
    "summary": "Cross platform(ish) productivity commands written in python.",
    "version": "2.0.3",
    "project_urls": {
        "Homepage": "https://github.com/zackees/setenvironment"
    },
    "split_keywords": [
        "setenvironment"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "bd33e023fa75cdf7965700a76e694358d75a20a83e91d9458f58891dff94bd73",
                "md5": "540cd3ff3417b8c75ac765eb61b743c8",
                "sha256": "9cee2abdf2b8a479a01f1e02dab8d03eaf99c449a1d47093517ae17992e568e4"
            },
            "downloads": -1,
            "filename": "setenvironment-2.0.3-py2.py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "540cd3ff3417b8c75ac765eb61b743c8",
            "packagetype": "bdist_wheel",
            "python_version": "py2.py3",
            "requires_python": ">=3.7",
            "size": 21631,
            "upload_time": "2023-10-15T20:54:52",
            "upload_time_iso_8601": "2023-10-15T20:54:52.775308Z",
            "url": "https://files.pythonhosted.org/packages/bd/33/e023fa75cdf7965700a76e694358d75a20a83e91d9458f58891dff94bd73/setenvironment-2.0.3-py2.py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "1b747cdc8d78e06e32955f14c0ac6b4905bf1375d60968a61144b8b358ae3760",
                "md5": "4c431fbe54df3deacd7256766d22b5d5",
                "sha256": "0d79b41981df0c7349396aaaea99c18e282795e4c20e3c5ad060003a61d7629b"
            },
            "downloads": -1,
            "filename": "setenvironment-2.0.3.tar.gz",
            "has_sig": false,
            "md5_digest": "4c431fbe54df3deacd7256766d22b5d5",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 29337,
            "upload_time": "2023-10-15T20:54:54",
            "upload_time_iso_8601": "2023-10-15T20:54:54.368972Z",
            "url": "https://files.pythonhosted.org/packages/1b/74/7cdc8d78e06e32955f14c0ac6b4905bf1375d60968a61144b8b358ae3760/setenvironment-2.0.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-10-15 20:54:54",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "zackees",
    "github_project": "setenvironment",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [],
    "tox": true,
    "lcname": "setenvironment"
}
        
Elapsed time: 0.13471s