Skip to main content

A simple tool to set environment variables before running a command

Project description

pysetenv is a simple Python-based program to allow users to set environment variables before executing a command, similar to the POSIX `env <https://pubs.opengroup.org/onlinepubs/9699919799/utilities/env.html>`__ command.

Why?

pysetenv is designed as a support package to help authors of other Python packages create command-line strings like you’d expect from sh or the env command. Generally, pysetenv will only be installed on Windows systems, with POSIX systems using sh or env. For example, in your setup.py, you would write:

setup(
    # ...
    install_requires=['pysetenv;platform_system=="Windows"'],
)

Then somewhere in your code, you could call pysetenv:

subprocess.call(['pysetenv', ...])

Command-line reference

Usage: pysetenv [OPTION]... [NAME=VALUE]... [COMMAND [ARG]...]

pysetenv supports a subset of common options available to various implementations of env. It executes COMMAND with any supplied arguments (ARG) after modifying the environment as specified by the previous arguments. Any arguments of the form NAME=VALUE will set an environment variable NAME to the value of VALUE. If COMMAND is not specified, pysetenv will print the resulting environment instead.

In addition, the following options are supported:

  • -i: Ignore any environment variables inherited by this process

  • -u NAME: Unset the environment variable NAME

  • -h, --help: Show a help message and exit

  • --version: Show the current version and exit

As an extension to the env command, the options above can be separated from the section for defining environment variables and/or the command to run with --.

License

This project is licensed under the BSD 3-clause license.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pysetenv-1.0.0.tar.gz (4.8 kB view hashes)

Uploaded Source

Built Distribution

pysetenv-1.0.0-py2.py3-none-any.whl (4.4 kB view hashes)

Uploaded Python 2 Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page