atg / chocolat-public

Public bug tracker for the private chocolat project
http://chocolatapp.com
180 stars 4 forks source link

Assignment of environment variables. #600

Open amcgregor opened 12 years ago

amcgregor commented 12 years ago

Friendly tl;dr warning.

Use Case

With scripts in language bundles (truffles), regardless of the underlying language for the script (JS, BASH, Ruby, Python, etc.) it is a requirement for my projects to have environment variables set to simulate a UNIX "chroot" at the language level. I primarily program Python, in which case my packages and their dependancies are isolated using a system called virtualenv. Virtualenv is usable one of two ways:

There are other useful environment variables to control SCM systems, for use in truffle-based templates and snippets (e.g. my name, organization name, etc.) and can be used to configure more advanced truffle scripts on a per-project basis without modifying the truffles themselves.

Behaviour

This mockup[1] demonstrates a simple addition to the project sidebar as a new collapsable section called, appropriately, "ENVIRONMENT". Behaviour would be thus:

CarterA commented 12 years ago

I like this idea. What do you think, @fileability?

kraih commented 12 years ago

+1

There needs to be a way to edit environment variables.

blaflamme commented 12 years ago

+1

amcgregor commented 12 years ago

The way I've coded my replacement build.sh and friends for Python allows you to run a custom script instead of the default behaviour by setting CHOC_RUN, CHOC_REPL, CHOC_DEBUG, CHOC_BUILD, etc. These are placed in a temporary file and exec used to pass control. The contents of these variables is the script.

amcgregor commented 11 years ago

Now I have this need for my LaTeX documents: most need to be compiled with lualatex, some don't care. Some need additional command-line arguments to the compiler. Per-project environment variable support would solve this.

locks commented 11 years ago

+One

amcgregor commented 11 years ago

As some use cases, I need to provide the following variables for the system Python to understand the project I'm working on:

If I can set VIRTUAL_ENV, I don't need to set PYTHONHOME or PYTHONPATH.

Python alone understands several additional environment variables:

For C~ projects, being able to override LDPATH, CFLAGS, and CXXFLAGS are important. For larger C~ projects, MAKEOPTS is useful. Additionally, the standard build scripts can be extended (like the Python ones) to support environment variable configuration or replacement. For example, defining CHOC_TEST on a Python project then choosing Check from the Actions menu would execute the contents of the variable as a BASH script.

The latter is useful in my case as setup.py test won't work… our project has no setup.py file. I need to direct 'check/test' execution through fab unittest; fab integration test, while the default behaviour is quite acceptable for the majority of Python projects… unless you develop using virtualenvwrapper, in which case the build scripts won't be able to auto-detect the correct Python executable to run. (Solved by setting a PATH environment variable.)

amcgregor commented 11 years ago

Bump.