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

Update bin path and other install fixes #119

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

mavaddat
Copy link

@mavaddat mavaddat commented Feb 24, 2023

This PR introduces multiple fixups for the broken installer.

Binaries path

The bin path for virtual env is now ../env/local/bin.

Here is one line in virtualenv tests that confirm this change:
/tests/unit/discovery/py_info/test_py_info.py#L331

Robustify virtualenv installer

The recommended zipapp way to install the latest virtualenv is given here.

Fix __version__ injection

Using exec to import the version is anti-pattern, unpythonic, and fragile. What's more, it does not work, because the Python interpreter is looking in the CWD for the bashhub/version.py whereas it actually needs to look in the script location. The script location is found using the ugly method below:

import os
import sys

exec (open(os.path.join(os.path.dirname(sys.argv[0]),'./bashhub/version.py')).read())

Using `exec` to import the version is anti-pattern, unpythonic, and fragile. What's more, it does not work, because the Python interpreter is looking in the CWD for the `bashhub/version.py` whereas it actually needs to look in the script location. The script location is found using the ugly method below:

```python3
import os
import sys

exec (open(os.path.join(os.path.dirname(sys.argv[0]),'./bashhub/version.py')).read())
```
@mavaddat mavaddat changed the title Update bin path Update bin path and other install fixes Feb 24, 2023
@rcaloras
Copy link
Owner

@mavaddat thanks for the PR!

Is the installer itself actually broken? Or is this PR about updating to always use the latest virtualenv and updating the appropriate paths for that? The implementation was using a specific version intentionally and I haven't heard any other reports of the installer being broken.

The change to setup.py makes sense and LGTM.

@@ -102,11 +102,9 @@ download_and_install_env() {
PYTHON=$(which $python_command)
echo "Using Python path $PYTHON"

VERSION=20.10.0
VERSION_URL="https://github.com/pypa/get-virtualenv/raw/$VERSION/public/virtualenv.pyz"
Copy link
Owner

Choose a reason for hiding this comment

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

Using this version and the specific version url is intentional. Is the update needed to support newer versions of Python?

@mavaddat
Copy link
Author

@rcaloras , yes the installer itself is broken. Actually, this PR doesn't solve all the issues, which I'm still trying to diagnose and fix. I will update this PR later today or tomorrow. Please standby!

@rcaloras
Copy link
Owner

rcaloras commented Feb 25, 2023 via email

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