How to install lessc and nodejs in a Python virtualenv?

前端 未结 4 1044
星月不相逢
星月不相逢 2020-12-24 09:52

I would like to install a nodejs script (lessc) into a virtualenv.

How can I do that ?

Thanks

Natim

4条回答
  •  隐瞒了意图╮
    2020-12-24 10:13

    I will provide my generic solution to works with Gems and NPMs inside a virtualenv Gems and Npm support to be customized via env settings : GEM_HOME and npm_config_prefix

    You can stick the snippet below in your postactivate or activate script ( it s more matter if you use virtualenvwrapper or not)

    export GEM_HOME="$VIRTUAL_ENV/lib/gems"
    export GEM_PATH=""
    PATH="$GEM_HOME/bin:$PATH"
    export npm_config_prefix=$VIRTUAL_ENV
    export PATH
    

    Now , inside your virtualenv all libs installed via gem install or npm -g install will be installed in your virtualenv and binary added in your PATH if you are using virtualenvwrapper you can make the change global to all your virtualenv if you modify the postactivate living inside your $VIRTUALENVWRAPPER_HOOK_DIR

    This solution don't cover installing nodejs inside the virtualenv but I think that it s better to delegate this task to the packaging system (apt,yum,brew..) and install node and npm globally

    Edit :

    I recently created 2 plugin for virtualenvwrapper to do this automatically. There is one for gem and npm :

    http://pypi.python.org/pypi/virtualenvwrapper.npm

    http://pypi.python.org/pypi/virtualenvwrapper.gem

提交回复
热议问题