Hi Team. Any idea how I can overcome this issue. (...
# general
n
Hi Team. Any idea how I can overcome this issue. (I use Python 2.7.15rc1, and upgrading it is not an option right now):
Copy code
root@92544bc397ef:/build# ./pants --version
New python executable in /root/.cache/pants/setup/bootstrap-Linux-x86_64/pants.TsgPCU/install/bin/python2.7
Also creating executable in /root/.cache/pants/setup/bootstrap-Linux-x86_64/pants.TsgPCU/install/bin/python
Installing setuptools, pip, wheel...done.
Collecting pantsbuild.pants==1.0.1
  Could not find a version that satisfies the requirement pantsbuild.pants==1.0.1 (from versions: )
No matching distribution found for pantsbuild.pants==1.0.1
./pants: line 84: /root/.cache/pants/setup/bootstrap-Linux-x86_64/1.0.1/bin/pants: No such file or directory
h
Hi Dheera, welcome. To confirm, you intend to use Pants 1.0.1, right? That's several years old. (Happy to help try figure it out either way)
n
Yes. I am currently using Pants 1.0.1. I understand it’s quite old 😞 I do not mind upgrading it. I need some assistance with that if you can.
h
I don't see why it would fail, the release still exists on https://pypi.org/project/pantsbuild.pants/#history Was this working before? What OS are you using?
n
Copy code
root@92544bc397ef:/build# uname --kernel-name --kernel-release --machine
Linux 5.10.25-linuxkit x86_64
h
Can you please paste the contents of your pants bash script? It has changed a bit over the years
What happens also if you change pants_version to something like 1.5.0?
n
let me DM you
Copy code
#!/usr/bin/env bash
# Copyright 2015 Pants project contributors (see CONTRIBUTORS.md).
# Licensed under the Apache License, Version 2.0 (see LICENSE).
# =============================== NOTE ===============================
# This pants bootstrap script comes from the pantsbuild/setup
# project and is intended to be checked into your code repository so
# that any developer can check out your code and be building it with
# pants with no prior setup needed.
#
# You can learn more here: <https://pantsbuild.github.io/setup>
# ====================================================================
PYTHON=${PYTHON:-$(which python2.7)}
PANTS_HOME="${PANTS_HOME:-${HOME}/.cache/pants/setup}"
PANTS_BOOTSTRAP="${PANTS_HOME}/bootstrap-$(uname -s)-$(uname -m)"
VENV_VERSION=13.1.0
VENV_PACKAGE=virtualenv-${VENV_VERSION}
VENV_TARBALL=${VENV_PACKAGE}.tar.gz
# The high-level flow:
# 1.) Grab pants version from pants.ini or default to latest.
# 2.) Check for a venv via a naming/path convention and execute if found.
# 3.) Otherwise create venv and re-exec self.
#
# After that pants itself will handle making sure any requested plugins
# are installed and up to date.
function tempdir {
  mktemp -d "$1"/pants.XXXXXX
}
# TODO(John Sirois): GC race loser tmp dirs leftover from bootstrap_XXX
# functions.  Any tmp dir w/o a symlink pointing to it can go.
function bootstrap_venv {
  if [[ ! -d "${PANTS_BOOTSTRAP}/${VENV_PACKAGE}" ]]
  then
    (
      mkdir -p "${PANTS_BOOTSTRAP}" && \
      staging_dir=$(tempdir "${PANTS_BOOTSTRAP}") && \
      cd "${staging_dir}" && \
      curl -O <https://pypi.python.org/packages/source/v/virtualenv/${VENV_TARBALL}> && \
      tar -xzf ${VENV_TARBALL} && \
      ln -s "${staging_dir}/${VENV_PACKAGE}" "${staging_dir}/latest" && \
      mv "${staging_dir}/latest" "${PANTS_BOOTSTRAP}/${VENV_PACKAGE}"
    ) 1>&2
  fi
  echo "${PANTS_BOOTSTRAP}/${VENV_PACKAGE}"
}
function bootstrap_pants {
  pants_requirement="pantsbuild.pants"
  pants_version=$(
    grep -E "^[[:space:]]*pants_version" pants.ini 2>/dev/null | \
      cut -f2 -d: | tr -d " "
  )
  if [[ -n "${pants_version}" ]]
  then
    pants_requirement="${pants_requirement}==${pants_version}"
  else
    pants_version="unspecified"
  fi
  if [[ ! -d "${PANTS_BOOTSTRAP}/${pants_version}" ]]
  then
    (
      venv_path="$(bootstrap_venv)" && \
      staging_dir=$(tempdir "${PANTS_BOOTSTRAP}") && \
      "${PYTHON}" "${venv_path}/virtualenv.py" "${staging_dir}/install" && \
      source "${staging_dir}/install/bin/activate" && \
      pip install "${pants_requirement}" && \
      ln -s "${staging_dir}/install" "${staging_dir}/${pants_version}" && \
      mv "${staging_dir}/${pants_version}" "${PANTS_BOOTSTRAP}/${pants_version}"
    ) 1>&2
  fi
  echo "${PANTS_BOOTSTRAP}/${pants_version}"
}
pants_dir=$(bootstrap_pants) && \
exec "${pants_dir}/bin/pants" "$@"
I invoke the above script using :
Copy code
./pants clean-all binary src/main/python/server::
h
I don't see anything fishy in the script. Is this working on other machines at your org?
Also it looks like Pants 1.4.0 is the first release where we uploaded prebuilt wheels, which are usually easier to install. Can you please try setting
pants_version
to 1.4.0? https://pypi.org/project/pantsbuild.pants/1.4.0/#files
n
Sure. Let me try that.
I modified pants.ini with below
Copy code
pants_version: 1.4.0
And then I ran my build. But I see the same issue again. Am I missing something?
Copy code
root@809f93390ddf:/build# ./local_build.sh 
New python executable in /root/.cache/pants/setup/bootstrap-Linux-x86_64/pants.nrbBSH/install/bin/python2.7
Also creating executable in /root/.cache/pants/setup/bootstrap-Linux-x86_64/pants.nrbBSH/install/bin/python
Installing setuptools, pip, wheel...done.
Collecting pantsbuild.pants==1.4.0
  Could not find a version that satisfies the requirement pantsbuild.pants==1.4.0 (from versions: )
No matching distribution found for pantsbuild.pants==1.4.0
./pants: line 84: /root/.cache/pants/setup/bootstrap-Linux-x86_64/1.4.0/bin/pants: No such file or directory
h
I'm not sure what's going on. What happens if you directly run
pip2 install pantsbuild.pants==1.4.0
? (Warning that will pollute your pip environment, you may want to use a virtual environment)
n
Let me check
h
Also, you may want to upgrade your
pip2
, I think
pip2 install --upgrade pip
n
I was able to overcome the above error, but now I see this when I run my pants build
Copy code
Collecting cryptography>=1.3.4 (from requests[security]<2.19,>=2.5.0->pantsbuild.pants==1.4.0)
  Downloading <https://files.pythonhosted.org/packages/9b/77/461087a514d2e8ece1c975d8216bc03f7048e6090c5166bc34115afdaa53/cryptography-3.4.7.tar.gz> (546kB)
    100% |################################| 548kB 771kB/s 
    Complete output from command python setup.py egg_info:
    
            =============================DEBUG ASSISTANCE==========================
            If you are seeing an error here please try the following to
            successfully install cryptography:
    
            Upgrade to the latest pip and try again. This will fix errors for most
            users. See: <https://pip.pypa.io/en/stable/installing/#upgrading-pip>
            =============================DEBUG ASSISTANCE==========================
    
    Traceback (most recent call last):
      File "<string>", line 20, in <module>
      File "/tmp/pip-build-MBob_E/cryptography/setup.py", line 14, in <module>
        from setuptools_rust import RustExtension
    ImportError: No module named setuptools_rust
    
    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-MBob_E/cryptography
./pants: line 84: /root/.cache/pants/setup/bootstrap-Linux-x86_64/1.4.0/bin/pants: No such file or directory
h
The above error was fixed by using Pants 2.4, right? Now try 1.8.0 please. It looks like we stopped using
setuptools_rust
and I'm wondering if that fixes things
n
I had changed my config to point to pants_version: 1.4.0, not 2.4
Should I use 1.8.0 instead? Let me give that a shot
I have a question. To upgrade pants, is changing the pants_version in pants.ini sufficient?
h
Ah yeah I meant 1.4, sorry. Yep, you only need to change
pants.ini
. And then of course fix any deprecations that have happened. I don't think these tips are all relevant to Pants 1.0, but see https://www.pantsbuild.org/docs/upgrade-tips for a general gist of upgrade tips