tvalentyn commented on a change in pull request #11067: [BEAM-9136]Add licenses for dependencies for Python URL: https://github.com/apache/beam/pull/11067#discussion_r399747239
########## File path: sdks/python/container/license_scripts/dep_urls_py.yaml ########## @@ -0,0 +1,116 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +pip_dependencies: + # this is a list of packages whose license cannot be pulled with pip-licenses tool. + # pip-licenses scans site-packages/ directory to get a list of packages installed. + # for the packages who missing licenses in distributed package should be pulled from a url or manually added. + # An entry is needed if license cannot be pull with pip-licenses in ANY Python environment. + + # template: + # dependency_name: + # license: url_to_license, "skip" or "manual" + # # skip: don't add license for the dependency + # # manual: license is manually added. The license is copied from manual_licenses/{dep}/LICENSE. + # notice: it's optional, url_to_notice + apache-beam: + license: "skip" # don't include self dependency. + appdirs: + license: "https://raw.githubusercontent.com/ActiveState/appdirs/master/LICENSE.txt" + avro: + license: "https://raw.githubusercontent.com/apache/avro/master/LICENSE.txt" + notice: "https://raw.githubusercontent.com/apache/avro/master/NOTICE.txt" + avro-python3: + license: "https://raw.githubusercontent.com/apache/avro/master/LICENSE.txt" + notice: "https://raw.githubusercontent.com/apache/avro/master/NOTICE.txt" + backports.weakref: + license: "https://raw.githubusercontent.com/PiDelport/backports.weakref/master/LICENSE" + chardet: + license: "https://raw.githubusercontent.com/chardet/chardet/master/LICENSE" + certifi: + license: "https://raw.githubusercontent.com/certifi/python-certifi/master/LICENSE" + cython: + license: "https://raw.githubusercontent.com/cython/cython/master/LICENSE.txt" + enum34: + license: "manual" + fastavro: + license: "https://raw.githubusercontent.com/fastavro/fastavro/master/LICENSE" + notice: "https://raw.githubusercontent.com/fastavro/fastavro/master/NOTICE.txt" + funcsigs: + license: "https://raw.githubusercontent.com/aliles/funcsigs/master/LICENSE" + futures: + license: "https://raw.githubusercontent.com/agronholm/pythonfutures/master/LICENSE" + google-apitools: + license: "https://raw.githubusercontent.com/google/apitools/master/LICENSE" + googledatastore: + license: "https://raw.githubusercontent.com/GoogleCloudPlatform/google-cloud-datastore/master/LICENSE" + grpcio: + license: "https://raw.githubusercontent.com/grpc/grpc/master/LICENSE" + notice: "https://raw.githubusercontent.com/grpc/grpc/master/NOTICE.txt" + grpcio-gcp: + license: "https://raw.githubusercontent.com/GoogleCloudPlatform/grpc-gcp-python/master/LICENSE" + guppy: + license: "https://raw.githubusercontent.com/joshwcomeau/guppy/master/LICENSE.md" + guppy3: + license: "https://raw.githubusercontent.com/zhuyifei1999/guppy3/master/LICENSE" + h5py: + license: "https://raw.githubusercontent.com/h5py/h5py/master/LICENSE" + hdfs: + license: "https://raw.githubusercontent.com/mtth/hdfs/master/LICENSE" + httplib2: + license: "https://raw.githubusercontent.com/httplib2/httplib2/master/LICENSE" + mock: + license: "https://raw.githubusercontent.com/testing-cabal/mock/master/LICENSE.txt" + monotonic: + license: "https://raw.githubusercontent.com/atdt/monotonic/master/LICENSE" + nose: + license: "https://raw.githubusercontent.com/nose-devs/nose2/master/license.txt" + numpy: + license: "https://raw.githubusercontent.com/numpy/numpy/master/LICENSE.txt" + oauth2client: + license: "https://raw.githubusercontent.com/googleapis/oauth2client/master/LICENSE" + pandas: + license: "https://raw.githubusercontent.com/pandas-dev/pandas/master/LICENSE" + pathlib2: + license: "https://raw.githubusercontent.com/mcmtroffaes/pathlib2/develop/LICENSE.rst" + protobuf: + license: "https://raw.githubusercontent.com/protocolbuffers/protobuf/master/LICENSE" + protorpc: + license: "https://raw.githubusercontent.com/google/protorpc/master/LICENSE" + pyarrow: + license: "https://raw.githubusercontent.com/apache/arrow/master/LICENSE.txt" + notice: "https://raw.githubusercontent.com/apache/arrow/master/NOTICE.txt" + pyhamcrest: + license: "https://raw.githubusercontent.com/hamcrest/PyHamcrest/master/LICENSE.txt" + pymongo: + license: "https://raw.githubusercontent.com/mongodb/mongo-python-driver/master/LICENSE" + python-gflags: + license: "manual" + notice: "https://raw.githubusercontent.com/google/python-gflags/master/COPYING" + pyvcf: + license: "https://raw.githubusercontent.com/jamescasbon/PyVCF/master/LICENSE" + scipy: + license: "https://raw.githubusercontent.com/scipy/scipy/master/LICENSE.txt" + termcolor: + license: "manual" Review comment: Consider changing the semantic of dep_urls_py.yaml so that the keys in the inner dictionary are the actual file names, such as 'LICENSE', 'NOTICE',... and values are the path. The path can be http://, local (retrieved from pip-licenses), or local path. Manual licenses that are copied in Beam repo can be referenced via path like: `{'LICENSE': '/tmp/manual_licences/enum34/LICENSE'}`. So the flow might look similar to: ``` preconfigured_licenses = yaml.full_load(...) installed_packages = run_pip_licenses() # Remove self-dependency del installed_packages['apache-beam'] dep_licenses = { # We will assemble a map of license files for each dependency: # 'dependency1 : {'LICENSE' : '/path/to/LICENSE'} # 'dependency2' : {'NOTICE' : 'http://path.to/NOTICE.txt'} # etc... } # pip-licences will not include itself in the list, but we still install it in containers. dep_licenses['pip-licenses'] = dep_licenses_manual['pip-licenses'] for dep in installed_packages: dep_licenses[dep] = {} if dep in preconfigured_licenses: dep_licenses[dep] = preconfigured_licenses[dep] # Prefer the actual license file retrieved from site-packages, if available. if installed_packages[dep]['LicenseFile'].lowercase() != "unknown": dep_licenses[dep]['LICENSE'] = installed_packages[dep]['LicenseFile'] # TODO: Also retrieve NOTICE files in the future? I am still not sure if this is necessary... for dep, license_files in dep_licenses.items(): if not license_files: ... missing license ... else: for name, path in license_files.items(): if path.startswith('http'): path = save_to_tempfile(path) # save the 'path' under 'name' in the folder for 'dep' ``` Take this as a suggestion, you can keep current logic if you think it's simpler. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected] With regards, Apache Git Services
