Git Product home page Git Product logo

rustenv's Introduction

Build Status PyPI version

rustenv

Create virtual, activate-able environments for Rust, similar to virtualenv for Python.

A virtual environment is a self-contained installation of Rust, Cargo, etc., which is completely isolated from any user-level installations you may have.

For example:

# Create a new rustenv
$ rustenv renv

# Run a command in it
$ renv/bin/rustc --version
rustc 1.26.1 (827013a31 2018-05-25)
$ renv/bin/cargo --version
cargo 1.26.0 (0e7c5a931 2018-04-06)

# Activate it to avoid having to prefix your commands
$ . renv/bin/activate
(renv) $ rustc --version
rustc 1.26.1 (827013a31 2018-05-25)

# Install hello-cli: https://crates.io/crates/hello-cli
(renv) $ cargo install hello-cli
(renv) $ hello
Hello World!

# Deactivate it to restore your PATH and PS1
(renv) $ deactivate_rustenv
$ rustc --version
command not found: rustc

Installation

rustenv is available via PyPI and can be installed using pip:

$ pip install rustenv

Project status

What works right now

  • Everything in the example above.

Remaining work

  • Provide some additional options when creating the rustenv:
    • Allow specifying rustc / cargo version
    • Allow disabling PS1 modification, similar to virtualenv
  • ...and more? (file an issue! :))

rustenv's People

Contributors

asottile avatar cblegare avatar chriskuehl avatar pre-commit-ci[bot] avatar schang412 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

rustenv's Issues

feature: embed rustenv within a Python venv

Hello there @chriskuehl !

Thank you for this simple yet useful piece of software. I often use python instead of shell script for quick tools, even when I'm not working on Python projects. Hence I always have a venv around and I leverage the fact that its built around a normal UNIX filesystem to install tools into it (awscli, gcloud, terraform, installed under venv/opt/<thing> for instance).

I wanted to do the same thing with rust and wrote a rust env management script that will optionally embed the rust env within an existing virtualenv.

Instead of pushing my tool to pypi, I could simply contribute it here. Would you be interested?

Here is the command line interface

rustenv somepath # unstall rust under somepath/rust, exactly as it is today
python -m venv somepath
rustenv somepath  # install rust under somepath/opt/rust
python -m venv somepath
source somepath/bin/activate
rustenv # install rust under somepath/opt/rust
python -m venv somepath
source somepath/bin/activate
rustenv someotherpath # install rust under someotherpath/rust

When embedding the rustenv within a Python virtualenv, the activate script is updated.


I (and a couple people I work with) am really interested in this feature. I also see that you did not feel the need to make any changes in the last couple years, so here are the options I'd like your opinion about.

  • Accept this feature as a contribution
  • Not interested in rustenv anymore? transfer it to me so I can add the feature and maintain it
  • Not interested/not responding at all? No problem, I'll simply distribute it under another name.

Have a nice day!

rustenv should probably silence some of the rustup output

currently it produces output like this:

$ rustenv renv
info: downloading installer
info: profile set to 'default'
info: default host triple is x86_64-unknown-linux-gnu
info: syncing channel updates for 'stable-x86_64-unknown-linux-gnu'
info: latest update on 2022-08-11, rust version 1.63.0 (4b91a6ea7 2022-08-08)
info: downloading component 'cargo'
info: downloading component 'clippy'
info: downloading component 'rust-docs'
info: downloading component 'rust-std'
info: downloading component 'rustc'
info: downloading component 'rustfmt'
info: installing component 'cargo'
info: installing component 'clippy'
info: installing component 'rust-docs'
 18.3 MiB /  18.3 MiB (100 %)   9.5 MiB/s in  1s ETA:  0s
info: installing component 'rust-std'
 26.1 MiB /  26.1 MiB (100 %)  14.4 MiB/s in  1s ETA:  0s
info: installing component 'rustc'
 54.3 MiB /  54.3 MiB (100 %)  15.9 MiB/s in  3s ETA:  0s
info: installing component 'rustfmt'
info: default toolchain set to 'stable-x86_64-unknown-linux-gnu'

  stable-x86_64-unknown-linux-gnu installed - rustc 1.63.0 (4b91a6ea7 2022-08-08)


Rust is installed now. Great!

To get started you need Cargo's bin directory (/tmp/explains/renv/rust/bin) in 
your PATH
environment variable. This has not been done automatically.

To configure your current shell, run:
source "/tmp/explains/renv/rust/env"

the last little bit there is especially problematic since it's not how rustenv is intended to work

readlink issues on Mac OS

The script called rustenv-proxy use readlink -f but in Mac OS uses BSD like commands and this option is not supported. It seems that the easiest fix is to remove rustenv-proxy and create links for each rust binary. Is there any reason to use rustenv-proxy?

Implement --version-flag

It would be nice to be able to check the version:

´´´

bin/rustenv --version
usage: rustenv [-h] destination
rustenv: error: the following arguments are required: destination

´´´´

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.