<jupyter_start><jupyter_text>convert pip wheel -> conda packagewhl   zip - contains cymem-2.0.2.dist-info : LICENSE  METADATA  RECORD  top_level.txt  WHEELconda tgz - includes lib/python{v}/site-packages/ - contains info : "about.json  files  git  hash_input.json  index.json  paths.json"conversion:1. move main modules to lib/...2. create info---- about: home license summary- files: list- git: empty- hash_input: empty- index.json: create- paths: files with sha256 and size<jupyter_code>from fastai2.torch_basics import *
import zipfile,tarfile
from email.parser import Parser
from wheel import wheelfile
from conda.gateways.disk.read import read_python_record
path = Path('~/git/spacy_conda/cymem').expanduser()
pkg = path/'pkg/cymem-2.0.2-py37_0.tar.bz2'
whl = path/'whl/cymem-2.0.2-cp37-cp37m-manylinux1_x86_64.whl'
pkg.exists(),whl.exists()
zpkg = tarfile.open(pkg,"r:bz2")
lpkg = zpkg.getmembers()
[(i,o.name) for i,o in enumerate(lpkg) if o.name.startswith('info/')]
f = (zpkg.extractfile('info/about.json').read().decode())
print(f)
fn.name
fwhl = wheelfile.WheelFile(whl)
fwhl.parsed_filename.groupdict()
fwhl.dist_info_path
fwhl.record_path
read_python_record(whl.parent, fwhl.record_path, '3.7')['paths_data'].paths
fwhl.namelist()
from wheel.metadata import pkginfo_to_metadata
meta = fwhl.read(f'{fwhl.dist_info_path}/METADATA').decode()
m = Parser().parsestr(meta)
m.items()
zip_ref = zipfile.ZipFile(whl,"r")
ls = zip_ref.filelist
[(i,o.filename) for i,o in enumerate(ls)]
fn = ls[11]
f = zip_ref.read(fn)
print(f.decode())
fn.filename<jupyter_output>Wheel-Version: 1.0
Generator: bdist_wheel (0.32.1)
Root-Is-Purelib: false
Tag: cp37-cp37m-manylinux1_x86_64
{'fraction_non_alphanumeric': 0.14755077658303464, 'fraction_numerical': 0.02867383512544803, 'mean_word_length': 5.34469696969697, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '73227', 'license': 'Apache-2.0', 'n_tokens_mistral': 690, 'n_tokens_neox': 665, 'n_words': 128, 'path': 'nbs/_whl2conda.ipynb', 'repo_name': 'Peshlex/fastai', 'size': '1674'}