yelp / aactivator Goto Github PK
View Code? Open in Web Editor NEWAutomatically source and unsource a project's environment
License: MIT License
Automatically source and unsource a project's environment
License: MIT License
Would be nice to brew install aactivator
Here is a working forumla for doing so:
class Aactivator < Formula
desc "Automatically source and unsource a project's environment"
homepage "https://github.com/Yelp/aactivator"
url "https://github.com/Yelp/aactivator/archive/v1.0.0.tar.gz"
sha256 "395430f9dbabd2644a030d534761899165e2d5c8cb5aa71bf620808543cdfb02"
include Language::Python::Virtualenv
depends_on :python if MacOS.version <= :snow_leopard
def install
virtualenv_install_with_resources
end
def caveats; <<-EOS.undent
To add aactivator to your shell, add the following line to your .bashrc or .zshrc:
eval "$(aactivator init)"
More information: https://github.com/Yelp/aactivator
EOS
end
test do
assert_match "aactivator", shell_output("#{bin}/aactivator -h")
end
end
Does anyone have any objections to me submitting this to homebrew?
It would be nice to add support for fish shell users. This would require targeting a different virtualenv activation script (activate.fish) and using fish syntax for the output eval command.
If fully supporting fish is too much scope, then maybe we can expose additional sub-commands (like security-check
) that will enable fish users to implement remainder of the logic.
If you're receptive to this idea, I can investigate further once we decide on general direction.
Add windows support NOW!
Problem:
precmd_aactivator
causes the following warning if #!/usr/bin/env python3
evals to python 3.11 or newer:
/usr/bin/aactivator:35: DeprecationWarning: 'pipes' is deprecated and slated for removal in Python 3.13
from pipes import quote
Reference: python 3.11 docs
When I navigate into a path with unicode in the name, I get the following error:
$ cd ~/妹; pwd
/Users/kedo/妹
Traceback (most recent call last):
File "/usr/local/bin/aactivator.py", line 342, in <module>
sys.exit(main())
File "/usr/local/bin/aactivator.py", line 334, in main
print(aactivator(tuple(sys.argv), os.environ.copy()))
File "/usr/local/bin/aactivator.py", line 323, in aactivator
return get_output(env, arg0=args[0])
File "/usr/local/bin/aactivator.py", line 304, in get_output
activate_path = config.find_allowed(pwd)
File "/usr/local/bin/aactivator.py", line 221, in find_allowed
return first(search_parent_paths(path), self.is_allowed)
File "/usr/local/bin/aactivator.py", line 89, in first
if predicate(x):
File "/usr/local/bin/aactivator.py", line 224, in is_allowed
activate = os.path.join(path, ACTIVATE)
File "/usr/local/Cellar/python/2.7.12_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/posixpath.py", line 73, in join
path += '/' + b
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe5 in position 12: ordinal not in range(128)
I tried to get a branch working to support unicode, but making code + tests compatible with both py2 and py3 without requiring third party libraries caused great anguishment.
To anyone else facing this issue, changing first line from #!/usr/bin/env python2.7
to #!/usr/bin/env python3.5
made unicode work perfectly.
Currently aactivator will not source any script that is "writeable by others":
Line 81 in 6a6ac54
In my case the files are just writeable by me and group members but not "others". While I can see that you really want to have tight restrictions in some places, I'm willing to accept group writeable files and directories.
It would be nice if there was an option to loosen the restriction a bit.
ckuehl@dev18-devc:~/proj/workflow$ aactivator
ckuehl@dev18-devc:~/proj/workflow$
it should probably print usage or something.
Hey im trying to use aactivator with zsh on ubuntu 22.04
I setup a venv in my project with virtualenv venv
and then created a symlink with ln -s venv/bin/activate .activate.sh
But aactivator is then telling me that its cowardly refusing to source .activate.sh because it is writable by others.
But permissions of venv/bin/activate are 0664
In the code here
Line 81 in 6a6ac54
This is not mentioned in the docs and also the error message is misleading.
Is this intended? Or am i just not seeing something?
I followed the steps shown here https://youtu.be/q8DkatMZvUs?t=1519
I think that the most prominent project with similar goals/functionality is direnv, but it isn't mentioned in the alternatives section in the README. Are there any security/functionality problems with direnv?
The script currently has from pipes import quote
. pipes
is deprecated in python3.11, and will be removed in 3.13 (https://docs.python.org/3/library/pipes.html).
Would anyone mind if I made a PR to replace that import with from shlex import quote
, since that's where pipes
was getting that function from anyways (https://github.com/python/cpython/blob/3.11/Lib/pipes.py#L66)?
Setup:
Problem:
.activate.sh
doesn't activate.
Currently it does not-so-great checks for number of arguments.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.