Skip to content

Commit

Permalink
fix release_helper lazy gl property (#2448)
Browse files Browse the repository at this point in the history
* fix release_helper lazy gl property

* make osx build script work with pyenv

---------

Co-authored-by: Manolis <[email protected]>
  • Loading branch information
k9ert and moneymanolis authored May 29, 2024
1 parent 50b5d63 commit c2cd77f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 13 deletions.
15 changes: 9 additions & 6 deletions utils/build-osx.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,14 @@ function create_virtualenv_for_pyinstaller {
# This currently assumes to be run with: Python 3.10.11
# Important: pyinstaller needs a Python binary with shared library files
# With pyenv, for example, you get this like so: env PYTHON_CONFIGURE_OPTS="--enable-shared" pyenv install 3.10.4
# Use pyenv if available
#if command -v pyenv >/dev/null 2>&1; then
if /bin/false ; then
# Use pyenv if set as environment variable
if [ $USE_PYENV_FOR_SPECTER_BUILD = true ]; then
echo "Trying to use pyenv ..."
if ! command -v pyenv >/dev/null 2>&1; then
echo "Error: pyenv is not available. Please make sure pyenv is installed and configured properly." >&2
exit 1
fi
### This is usually in .zshrc, putting it in .bashrc didn't work ###
###
export PYENV_ROOT="$HOME/.pyenv"
command -v pyenv >/dev/null || export PATH="$PYENV_ROOT/bin:$PATH"
eval "$(pyenv init -)"
Expand All @@ -26,11 +29,11 @@ function create_virtualenv_for_pyinstaller {
### ------------------------------------------------------------ ###
PYTHON_VERSION=3.10.11
export PYENV_VERSION=$PYTHON_VERSION
echo "pyenv is available. Setting PYENV_VERSION to 3.10.4, using pyenv-virtualenv to create the buildenv..."
echo "Setting PYENV_VERSION to 3.10.11, using pyenv-virtualenv to create the buildenv..."
echo " --> Deleting .buildenv"
pyenv uninstall -f .buildenv
rm -rf "$HOME/.pyenv/versions/$PYTHON_VERSION/envs/.buildenv"
pyenv virtualenv 3.10.4 .buildenv
pyenv virtualenv 3.10.11 .buildenv
pyenv activate .buildenv
else
echo "pyenv is not available. Using system Python version."
Expand Down
17 changes: 10 additions & 7 deletions utils/release_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,25 +217,26 @@ def __init__(self):

@property
def gl(self):
# https://python-gitlab.readthedocs.io/en/stable/api-usage.html
import gitlab
"""https://python-gitlab.readthedocs.io/en/stable/api-usage.html"""
if hasattr(self, "_gl"):
return self._gl

if os.environ.get("GITLAB_PRIVATE_TOKEN"):
logger.info("Using GITLAB_PRIVATE_TOKEN")
gl = gitlab.Gitlab(
self._gl = gitlab.Gitlab(
"http://gitlab.com",
private_token=os.environ.get("GITLAB_PRIVATE_TOKEN"),
)
elif os.environ.get("CI_JOB_TOKEN"):
logger.info("Using CI_JOB_TOKEN")
self.gl = gitlab.Gitlab(
self._gl = gitlab.Gitlab(
"http://gitlab.com", job_token=os.environ["CI_JOB_TOKEN"]
)
else:
raise Exception(
"Can't authenticate against Gitlab ( export GITLAB_PRIVATE_TOKEN )"
)
return gl
return self._gl

@property
def gitlab_project(self):
Expand Down Expand Up @@ -277,7 +278,9 @@ def ci_project_id(self):
)
if project.name_with_namespace.startswith("cryptoadvance"):
self._ci_project_id = project.id
logger.warn("{self._ci_project_id} has been chosen as self._ci_project_id")
logger.warning(
f"{self._ci_project_id} has been chosen as self._ci_project_id"
)
return self._ci_project_id

@property
Expand Down Expand Up @@ -312,7 +315,7 @@ def ci_project_root_namespace(self):
)
else:
self._ci_project_root_namespace = "cryptoadvance"
logger.warn(
logger.warning(
f"Using project_root_namespace: {self._ci_project_root_namespace} ( export CI_PROJECT_ROOT_NAMESPACE={self._ci_project_root_namespace} )"
)
return self._ci_project_root_namespace
Expand Down

0 comments on commit c2cd77f

Please sign in to comment.