Skip to content

Script to create a self-contained installation of the EBCLI #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Apr 16, 2019

Conversation

rahulrajaram
Copy link
Contributor

@rahulrajaram rahulrajaram commented Apr 5, 2019

1. Overview

This script will:

  • create a unique virtualenv for the EBCLI
  • create .py, .bat, .ps1 wrappers around it such that when any of these wrappers is invoked to execute an 'eb' command, the unique virtualenv is activated. After the eb process is returned, the virtualenv is deactivated.

2. Installation Prerequisites

  • Python (3.7, 3.6, 2.7, 3.5, or 3.4). Preferably Python 3.7.
  • virtualenv
  • Bash/Zsh on Linux/MacOS.
  • Powershell/CMD Prompt on Windows

Typically, modern Python installations include pip, so the user shouldn't have to install pip separately.

It has been recognized that installing Python, and virtualenv (through pip) can challenge some users, so a future effort will solve this problem through pyenv.


3. Testing:

  • Without a Python in PATH:

    • if the script is executed as python bundled_installer.py, the script fails
    • if the script is executed as /path/to/python bundled_installer.py, the script fails to create a virtualenv, and hence fails
    • if the script is executed as /path/to/python bundled_installer.py --python-installation /path/to/python:
      • if virtualenv cannot be found, the script fails
      • if virtualenv exists, the script succeeds in installing eb and its wrappers
  • upon a successful installation on Linux/MacOS:

    • if the installation path is not already in PATH, the user is provided Bash and Zsh specific instructions to amend their PATH
    • if the installation path is already in PATH, the user is merely informed that eb was successfully installed
  • upon a successful installation on Windows:

    • if the installation path is not already in $PATH,:
      • Visual Basic and Batch scripts are generated (to be called from PowerShell and CMD prompt respectively) that the user may call to amend PATH. These scripts are idempotent: they will not amend PATH more than once.
      • the user will see a message indicating how PATH should be amended
      • immediately after amending PATH, eb will be unavailable; the shell needs to be restarted.
  • by default, the latest version of the EBCLI on PyPi is installed. If the isolated virtualenv already exists, an attempt to upgrade the installation will be made (the script will always perform pip install --upgrade awsebcli.

  • older versions of the EBCLI can be installed as python bundled_installer.py --version VERSION.

  • by default, the virtualenv is installed in the user's home directory. If home cannot be determined, the script is exited after informing the user that they need to pass --location LOCATION explicitly.

  • with the --location LOCATION argument, the virtualenv is installed at LOCATION. Consequently, the instructions to amend path will reference LOCATION.

  • each of the eb wrappers should exit with the exit code the real eb command returned. (use echo $?, $LASTEXITCODE, echo %ERRORLEVEL%, on Bash/Zsh, PowerShell and CMD Promp respectively).

  • if the virtualenv already exists but was not created by the script, an error message is printed asking the user to either delete the directory or to specify an alternate location using --location LOCATION.


4. Shortcomings

  • installation is not supported on Windows using Cygwin, git-bash, and other Unix-like shells.

  • Python, and virtualenv are prerequisites


By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@rahulrajaram rahulrajaram changed the title Add ebcli installer Script to create a self-contained installation of the EBCLI Apr 5, 2019
This script will:

- create a unique virtualenv for the EBCLI
- create .py, .bat, .ps1 wrappers around it such that when any of
  these wrappers is invoked to execute an 'eb' command, the unique
  virtualenv is activated. After the 'eb' process is returned, the
  virtualenv is deactivated.
This will be useful during testing specific commits/development versions
of the package

Prerequisites:

1. Python + pip (preferably Python 3.7, although Python 2.7, 3.4, 3.5,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wonder if this may be digging us a hole that leads to problems down the line. Why not just make it 3.7?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point.

There was a brief period where I felt it might be more work to restrict Python 2.7 usage, however, I don't think that is a problem anymore given that we are providing a way for them to install Python as well.

I'll make the change in future PR.

ebcli_ps1_script_path = os.path.join(executables_dir, 'eb.ps1')
ebcli_bat_script_path = os.path.join(executables_dir, 'eb.bat')

if sys.platform.startswith('win32'):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this true for both x86 and amd64 platforms?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes :)

@rahulrajaram rahulrajaram mentioned this pull request Apr 11, 2019
14 tasks
@rahulrajaram rahulrajaram merged commit 1a1b985 into master Apr 16, 2019
@rahulrajaram rahulrajaram deleted the AddEBCLIInstaller branch April 16, 2019 23:25
@rahulrajaram rahulrajaram mentioned this pull request May 2, 2019
13 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants