Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions python/helpers/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ hashin==0.15.0
pipenv==2018.11.26
pipfile==0.0.2
poetry==1.1.4
wheel==0.36.0

# Some dependencies will only install if Cython is present
Cython==0.29.21
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,15 @@ class PipCompileVersionResolver
/git clone -q (?<url>[^\s]+).* /.freeze
GIT_REFERENCE_NOT_FOUND_REGEX =
/egg=(?<name>\S+).*.*WARNING: Did not find branch or tag \'(?<tag>[^\n"]+)\'/m.freeze
NATIVE_COMPILATION_ERROR = "pip._internal.exceptions.InstallationError: Command errored out with exit status 1"

attr_reader :dependency, :dependency_files, :credentials

def initialize(dependency:, dependency_files:, credentials:)
@dependency = dependency
@dependency_files = dependency_files
@credentials = credentials
@build_isolation = true
end

def latest_resolvable_version(requirement: nil)
Expand Down Expand Up @@ -90,10 +92,22 @@ def fetch_latest_resolvable_version_string(requirement:)
parse_updated_files
end
rescue SharedHelpers::HelperSubprocessFailed => e
retry_count ||= 0
retry_count += 1

if compilation_error?(e) && retry_count <= 1
@build_isolation = false
retry
end

handle_pip_compile_errors(e)
end
end

def compilation_error?(error)
error.message.include?(NATIVE_COMPILATION_ERROR)
end

# rubocop:disable Metrics/AbcSize
def handle_pip_compile_errors(error)
if error.message.include?("Could not find a version")
Expand Down Expand Up @@ -194,7 +208,7 @@ def run_command(command, env: python_env)
end

def pip_compile_options(filename)
options = ["--build-isolation"]
options = @build_isolation ? ["--build-isolation"] : ["--no-build-isolation"]
options += pip_compile_index_options

if (requirements_file = compiled_file_for_filename(filename))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -454,6 +454,16 @@
end
end
end

context "with native dependencies that are not pre-built" do
let(:manifest_fixture_name) { "native_dependencies.in" }
let(:generated_fixture_name) { "pip_compile_native_dependencies.txt" }
let(:dependency_name) { "cryptography" }
let(:dependency_version) { "2.2.2" }
let(:updated_requirement) { "> 3.0.0" }

it { is_expected.to eq(Gem::Version.new("3.2.1")) }
end
end

describe "#resolvable?" do
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
numpy
cryptography
pandas
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#
# This file is autogenerated by pip-compile
# To update, run:
#
# pip-compile --no-build-isolation
#
asn1crypto==1.4.0 # via cryptography
cffi==1.11.5 # via cryptography
cryptography==2.2.2 # via -r requirements.in
idna==2.10 # via cryptography
numpy==1.14.2 # via -r requirements.in, pandas
pandas==0.22.0 # via -r requirements.in
pycparser==2.18 # via cffi
python-dateutil==2.8.1 # via pandas
pytz==2020.4 # via pandas
six==1.11.0 # via cryptography, python-dateutil