News for hackers. Stuff that matters.
Re:Shell Scripting with Elixir by datadeft on Tuesday February 13, 2024 @04:07AM (#39355897)
One detail I really like about this is that you can install packages during the script run.

    Mix.install([
     {:req, "~> 0.2"},
     {:floki, "~> 0.30.0"}
   ])
Re:Shell Scripting with Elixir by lambdaba on Tuesday February 13, 2024 @04:35AM (#39356041)
Ruby can do this too:

  require 'bundler/inline'
  
  gemfile do
    source 'https://rubygems.org'
    gem 'json', require: false
    gem 'nap', require: 'rest'
    gem 'cocoapods', '~> 0.34.1'
  end
Re:Shell Scripting with Elixir by behnamoh on Tuesday February 13, 2024 @09:47AM (#39358058)
Can't Python do the same? Like !pip install blahblah
Re:Shell Scripting with Elixir by gkbrk on Tuesday February 13, 2024 @09:49AM (#39358077)
That's not Python syntax. It's a Jupyter extension.
Re:Shell Scripting with Elixir by behnamoh on Tuesday February 13, 2024 @09:53AM (#39358119)
Right, but Python can run command line code in subprocesses too, so it should be possible to run a pip install jupyter command inside Python.
Re:Shell Scripting with Elixir by networked on Wednesday February 14, 2024 @08:11AM (#39369386)
The problem is that installing dependencies for the user or globally will lead to version conflicts. You need a separate virtual environment or a custom installation directory for each script to avoid conflicts. There are script runners and copy-pastable code snippets for Python that handle this by creating the virtual environment and installing the dependencies in it. Check out https://github.com/stars/dbohdan/lists/python-scripts-with-d... (disclosure: my list, and it includes my repository).
Re:Shell Scripting with Elixir by behnamoh on Thursday February 15, 2024 @12:12AM (#39379351)
Thanks, I checked out the link, it's quite handy!