kiorky / croniter

MIT License
382 stars 37 forks source link

Uppercase `SHA256=` in packaging causes `mamba`/`conda` `AssertionError` #54

Closed zaneselvans closed 11 months ago

zaneselvans commented 11 months ago

I'm not exactly sure where it is happening, but with the release of 2.0.0 I am getting an AssertionError after installing croniter==2.0.0 inside a conda environment using pip, and it seems to be unhappy that the package hash starts with SHA256= rather than sha256=. Was there a change in the croniter packaging system between 1.4.1 and 2.0.0?

Or maybe this makes more sense to one of the conda feedstock maintainers @mariusvniekerk @bollwyvl? Or maybe it's a problem with how mamba/conda is parsing the package metadata? I'm unsure.

To reproduce the error:

mamba create -n "croniter-test" python=3.11
mamba activate croniter-test
pip install "croniter==2.0.0"
mamba list
    Traceback (most recent call last):
      File "/Users/zane/mambaforge/lib/python3.10/site-packages/conda/exceptions.py", line 1124, in __call__
        return func(*args, **kwargs)
      File "/Users/zane/mambaforge/lib/python3.10/site-packages/mamba/mamba.py", line 945, in exception_converter
        raise e
      File "/Users/zane/mambaforge/lib/python3.10/site-packages/mamba/mamba.py", line 938, in exception_converter
        exit_code = _wrapped_main(*args, **kwargs)
      File "/Users/zane/mambaforge/lib/python3.10/site-packages/mamba/mamba.py", line 884, in _wrapped_main
        result = do_call(parsed_args, p)
      File "/Users/zane/mambaforge/lib/python3.10/site-packages/mamba/mamba.py", line 752, in do_call
        exit_code = getattr(module, func_name)(args, parser)
      File "/Users/zane/mambaforge/lib/python3.10/site-packages/conda/cli/main_list.py", line 137, in execute
        exitcode = print_packages(prefix, regex, format, piplist=args.pip,
      File "/Users/zane/mambaforge/lib/python3.10/site-packages/conda/cli/main_list.py", line 76, in print_packages
        exitcode, output = list_packages(prefix, regex, format=format,
      File "/Users/zane/mambaforge/lib/python3.10/site-packages/conda/cli/main_list.py", line 42, in list_packages
        installed = sorted(PrefixData(prefix, pip_interop_enabled=True).iter_records(),
      File "/Users/zane/mambaforge/lib/python3.10/site-packages/conda/core/prefix_data.py", line 136, in iter_records
        return iter(self._prefix_records.values())
      File "/Users/zane/mambaforge/lib/python3.10/site-packages/conda/core/prefix_data.py", line 165, in _prefix_records
        return self.__prefix_records or self.load() or self.__prefix_records
      File "/Users/zane/mambaforge/lib/python3.10/site-packages/conda/common/io.py", line 84, in decorated
        return f(*args, **kwds)
      File "/Users/zane/mambaforge/lib/python3.10/site-packages/conda/core/prefix_data.py", line 75, in load
        self._load_site_packages()
      File "/Users/zane/mambaforge/lib/python3.10/site-packages/conda/core/prefix_data.py", line 282, in _load_site_packages
        python_record = read_python_record(self.prefix_path, af, python_pkg_record.version)
      File "/Users/zane/mambaforge/lib/python3.10/site-packages/conda/gateways/disk/read.py", line 245, in read_python_record
        paths_tups = pydist.get_paths()
      File "/Users/zane/mambaforge/lib/python3.10/site-packages/conda/common/pkg_formats/python.py", line 265, in get_paths
        records = process_csv_row(record_reader)
      File "/Users/zane/mambaforge/lib/python3.10/site-packages/conda/common/pkg_formats/python.py", line 248, in process_csv_row
        assert checksum.startswith('sha256='), (self._metadata_dir_full_path,
    AssertionError: ('/Users/zane/mambaforge/envs/croniter-test/lib/python3.11/site-packages/croniter-2.0.0.dist-info', 'lib/python3.11/site-packages/croniter-2.0.0.dist-info/LICENSE', 'SHA256=qPlS5sa7MLDPz3HDBOOTEWDSqbV41u3fpcwYyDLhftM')
bollwyvl commented 11 months ago

Hmmm... I'd wager this is not a croniter-feedstock problem, as this installs correctl. It's possible #53 would fix this. But the wheel metadata no longer reflects the LICENSE, which may confuse the conda list mechanism.

│   --- croniter-1.4.1.dist-info/METADATA
├── +++ croniter-2.0.0.dist-info/METADATA
│┄ Files 2% similar despite different names
│ @@ -1,10 +1,10 @@
│  Metadata-Version: 2.1
│  Name: croniter
│ -Version: 1.4.1
│ +Version: 2.0.0
│  Summary: croniter provides iteration for datetime object with cron like format
│  Home-page: http://github.com/kiorky/croniter
│  Author: Matsumoto Taichi, kiorky
│  Author-email: taichino@gmail.com, kiorky@cryptelium.net
│  License: MIT License
│  Keywords: datetime,iterator,cron
│  Platform: UNKNOWN
│ @@ -21,18 +21,19 @@
│  Classifier: Programming Language :: Python :: 3.5
│  Classifier: Programming Language :: Python :: 3.6
│  Classifier: Programming Language :: Python :: 3.7
│  Classifier: Programming Language :: Python :: 3.8
│  Classifier: Programming Language :: Python :: 3.9
│  Classifier: Programming Language :: Python :: 3.10
│  Classifier: Programming Language :: Python :: 3.11
│ +Classifier: Programming Language :: Python :: 3.12
│  Classifier: Topic :: Software Development :: Libraries :: Python Modules
│  Requires-Python: >=2.6, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*
│ -License-File: LICENSE
│  Requires-Dist: python-dateutil
│ +Requires-Dist: pytz (>2021.1)
bollwyvl commented 11 months ago

May be related to this:

https://github.com/conda/conda/issues/10371

iamthebot commented 11 months ago

@bollwyvl the wheel (for 2.0.0) installs correctly via pip but conda list still fails due to the bad metadata. Agreed this is not a feedstock problem.

I'll reopen conda/conda#10371 as a new issue and start working on a PR to fix the assertion. In practice, this wheel should be fixed as currently it breaks any conda environment that pulls it in. But technically https://peps.python.org/pep-0376/#record doesn't make any assertions about it being uppercase vs. lowercase.

Currently this is breaking many of our docker images so hoping to see if we can work w/ @kiorky to push a fixed wheel.

iamthebot commented 11 months ago

For anyone else running into this, I've opened a PR in conda to address some related issues there. That'll take a while to be merged in though and this package as written is technically non-conformant.

Recommended workaround is to pin <2.0.0 if installing via pip or install directly via conda (not always possible if it's pulled in as a dependency).

zaneselvans commented 11 months ago

Thanks so much for jumping on this @iamthebot! It's always nice when taking the time to report a bug results in a fix.

kiorky commented 11 months ago

For the LICENSE inclusion, 2.0.1 is out.

kiorky commented 11 months ago

Tested the failing scenario, i reproduce the error with 2.0.0, but not with 2.0.1, closing as fixed.