summaryrefslogtreecommitdiff
path: root/lib/license/management/python.rb
diff options
context:
space:
mode:
authormo khan <mo.khan@gmail.com>2020-07-13 09:57:29 -0600
committermo khan <mo.khan@gmail.com>2020-08-21 16:31:57 -0600
commitcbc4d1e328fd0e578f038d57fbd6b9354dafa79e (patch)
tree99b53a90cd7c0996a2d0993b41eb56a695bcc996 /lib/license/management/python.rb
parenteb11eeb1018c4d32e8dbaf3f734e588205f0671f (diff)
Install tools from .deb package
Diffstat (limited to 'lib/license/management/python.rb')
-rw-r--r--lib/license/management/python.rb61
1 files changed, 0 insertions, 61 deletions
diff --git a/lib/license/management/python.rb b/lib/license/management/python.rb
deleted file mode 100644
index ede792e..0000000
--- a/lib/license/management/python.rb
+++ /dev/null
@@ -1,61 +0,0 @@
-# frozen_string_literal: true
-
-module License
- module Management
- class Python
- attr_reader :shell
-
- def initialize(shell: ::License::Management.shell)
- @shell = shell
- end
-
- def major_version
- version.split('.')[0]
- end
-
- def version
- ENV.fetch('ASDF_PYTHON_VERSION') do
- _stdout, stderr, status = shell.execute([:python, '--version'])
- status.success? ? stderr.split(' ')[-1] : 3
- end
- end
-
- def pip_index_url
- ENV.fetch('PIP_INDEX_URL', 'https://pypi.org/simple/')
- end
-
- def pip_licenses(venv: '.venv', detection_path:)
- _stdout, _stderr, status = shell.sh([
- ". #{venv}/bin/activate &&",
- :pip, :install,
- '--no-index',
- '--find-links /opt/gitlab/.config/virtualenv/app-data', 'pip-licenses', '&&',
- 'pip-licenses',
- '--ignore-packages prettytable',
- '--with-description',
- '--with-urls',
- '--from=meta',
- '--format=json',
- '--output-file pip-licenses.json'
- ], env: { 'PATH' => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin' })
- return [] unless status.success?
-
- JSON.parse(IO.read('pip-licenses.json')).map do |dependency|
- ::LicenseFinder::Dependency.new(
- 'Pip',
- dependency['Name'],
- dependency['Version'],
- description: dependency['Description'],
- detection_path: detection_path,
- homepage: dependency['URL'],
- spec_licenses: [dependency['License']]
- )
- end
- end
-
- def default_env
- { 'PIP_CERT' => ENV.fetch('PIP_CERT', shell.default_certificate_path).to_s }
- end
- end
- end
-end