Skip to content
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

chore: Make license script used in build more portable #4861

Closed
wants to merge 1 commit into from

Conversation

garethr
Copy link
Contributor

@garethr garethr commented Sep 16, 2023

The current script cliv2/ scripts/prepare_licenses.sh assumes it can run python directly on the host. If someone is using python actively for development that's likely disabled. It's good practice to disable pip from installing in the global namespace using one of:

pip config set global.require-virtualenv True
PIP_REQUIRE_VIRTUALENV=1

That means when running a build it will fail like so:

-- Preparing 3rd Party Licenses
make[1]: *** [/Users/garethr/Documents/cli/cliv2/_cache/prepare-3rd-party-licenses] Error 3
make: *** [build] Error 

This PR changes the script to use virtualenv if it's installed. It will create a venv if needed, or reuse an existing one. If virtualenv is not installed it will fall back on the current behaviour.

What does this PR do?

Makes the build process more portable, by using virtualenv when present to avoid clashes with the system python configuration.

Where should the reviewer start?

By running the script directly, followed by running a full build.

How should this be manually tested?

  • Run a build in a previously working environment, this shouldn't change anything there
  • Run the script directly, again, this should work as previously
  • Install virtualenv on your path, and then run the script directly. Note the use and creation of a virtualenv
  • Run a full clean build in the presense of the virtualenv

@garethr garethr requested a review from a team as a code owner September 16, 2023 07:40
@github-actions
Copy link
Contributor

github-actions bot commented Sep 16, 2023

Fails
🚫

"Chore: Make build script more portable" is not using a valid commit message format. For commit guidelines, see: CONTRIBUTING.

Generated by 🚫 dangerJS against 2b66466

@garethr garethr changed the title Make build script more portable chore: Make license script used in build more portable Sep 16, 2023
The current script `cliv2/ scripts/prepare_licenses.sh` assumes it can run python directly on the host.  If someone is using python actively for development that's likely disabled. It's good practice to disable pip from installing in the global namespace using one of:

```
pip config set global.require-virtualenv True
PIP_REQUIRE_VIRTUALENV=1
```

That means when running a build it will fail like so:

```
-- Preparing 3rd Party Licenses
make[1]: *** [/Users/garethr/Documents/cli/cliv2/_cache/prepare-3rd-party-licenses] Error 3
make: *** [build] Error
```

This PR changes the script to use `virtualenv` if it's installed. It will create a venv if needed, or reuse an existing one. If virtualenv is not installed it will fall back on the current behaviour.

This should make the build more portable.
@garethr garethr force-pushed the use-virtualenv-for-build-script branch from 43bbdce to 2b66466 Compare September 16, 2023 14:49
@PeterSchafer
Copy link
Collaborator

Hey @garethr, thanks a lot for the contribution. I double checked and it is actually not required anymore to install from within the script. Since it is always better to remove code, I removed the install step in another PR and would propose to close this PR.
I hope this makes sense.

@PeterSchafer
Copy link
Collaborator

Closing this PR, since we removed the installation completely in #4863 so we don't require a virtual environment anymore.

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