src-d / hercules

Gaining advanced insights from Git repository history.
Other
2.63k stars 334 forks source link

pip install labours returns an error #397

Open slavaGanzin opened 2 months ago

slavaGanzin commented 2 months ago

python -V Python 3.12.5

pip 24.2 (python 3.12)

pip install labours Collecting labours Using cached labours-10.7.2-py3-none-any.whl.metadata (24 kB) Collecting matplotlib<4.0,>=2.0 (from labours) Using cached matplotlib-3.9.2-cp312-cp312-macosx_10_12_x86_64.whl.metadata (11 kB) Collecting numpy<2.0,>=1.12.0 (from labours) Using cached numpy-1.26.4-cp312-cp312-macosx_10_9_x86_64.whl.metadata (61 kB) Collecting pandas<1.0,>=0.20.0 (from labours) Using cached pandas-0.25.3.tar.gz (12.6 MB) Installing build dependencies ... done Getting requirements to build wheel ... error error: subprocess-exited-with-error

× Getting requirements to build wheel did not run successfully. │ exit code: 1 ╰─> [31 lines of output]

:12: DeprecationWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html :489: DeprecationWarning: distutils Version classes are deprecated. Use packaging.version instead. Traceback (most recent call last): File "/Users/slava/work/helpmetest2/.venv/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 353, in main() File "/Users/slava/work/helpmetest2/.venv/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 335, in main json_out['return_val'] = hook(**hook_input['kwargs']) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/slava/work/helpmetest2/.venv/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 118, in get_requires_for_build_wheel return hook(config_settings) ^^^^^^^^^^^^^^^^^^^^^ File "/private/var/folders/4w/9vtd0tnn0b322q0pcjsmwcmw0000gp/T/pip-build-env-dwxuvvmb/overlay/lib/python3.12/site-packages/setuptools/build_meta.py", line 332, in get_requires_for_build_wheel return self._get_build_requires(config_settings, requirements=[]) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/private/var/folders/4w/9vtd0tnn0b322q0pcjsmwcmw0000gp/T/pip-build-env-dwxuvvmb/overlay/lib/python3.12/site-packages/setuptools/build_meta.py", line 302, in _get_build_requires self.run_setup() File "/private/var/folders/4w/9vtd0tnn0b322q0pcjsmwcmw0000gp/T/pip-build-env-dwxuvvmb/overlay/lib/python3.12/site-packages/setuptools/build_meta.py", line 503, in run_setup super().run_setup(setup_script=setup_script) File "/private/var/folders/4w/9vtd0tnn0b322q0pcjsmwcmw0000gp/T/pip-build-env-dwxuvvmb/overlay/lib/python3.12/site-packages/setuptools/build_meta.py", line 318, in run_setup exec(code, locals()) File "", line 812, in File "/private/var/folders/4w/9vtd0tnn0b322q0pcjsmwcmw0000gp/T/pip-install-b_n9jimi/pandas_1acb2128c43e411c9a09fb5d8b34c4ef/versioneer.py", line 1440, in get_version return get_versions()["version"] ^^^^^^^^^^^^^^ File "/private/var/folders/4w/9vtd0tnn0b322q0pcjsmwcmw0000gp/T/pip-install-b_n9jimi/pandas_1acb2128c43e411c9a09fb5d8b34c4ef/versioneer.py", line 1369, in get_versions cfg = get_config_from_root(root) ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/private/var/folders/4w/9vtd0tnn0b322q0pcjsmwcmw0000gp/T/pip-install-b_n9jimi/pandas_1acb2128c43e411c9a09fb5d8b34c4ef/versioneer.py", line 401, in get_config_from_root parser = configparser.SafeConfigParser() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ AttributeError: module 'configparser' has no attribute 'SafeConfigParser'. Did you mean: 'RawConfigParser'? [end of output] note: This error originates from a subprocess, and is likely not a problem with pip. error: subprocess-exited-with-error × Getting requirements to build wheel did not run successfully. │ exit code: 1 ╰─> See above for output. note: This error originates from a subprocess, and is likely not a problem with pip.
BenBE commented 1 month ago

I had to comment out Pandas and PyYAML in requirements.in as those versions are referring to very old releases that are no longer available with Python 3.12. Also seriate doesn't install as there's no recent release for ortool available for Python 3.12. Same goes for scipy, where a recent version would be 1.13, not 1.2 …

Please update your dependencies to make this project usable with Python 3.12.

chucker commented 1 month ago

I was able to get a bit further with this fork: https://github.com/ryzhakar/hercules

However, the Python dependencies still wouldn't build. I wrote a requirements.in that looks like this:

fastdtw==0.3.4
hdbscan==0.8.38.post1
lifelines==0.29.0
matplotlib==3.9.2
munch==4.0.0
numpy==1.26.4
ortools==7.8.7959
pandas==2.2.3
protobuf==5.28.2
python_dateutil==2.9.0.post0
PyYAML==6.0.2
scipy==1.14.1
seriate==1.1.2
setuptools==75.1.0
tensorflow==2.17.0
tqdm==4.66.5

But it couldn't find a matching ortools version.

BenBE commented 1 month ago

ortools is unavailable for python 3.12. Thus seriate will never have its dependencies satisfied.

Also, the code in e.g. models/burndown.py uses DataFrame.append which was removed in pandas>=2.0, thus even with recent dependencies installed, this code won't properly work without refactoring.

gwenzek commented 1 month ago

I was able to run labours -m burndown-project using the following install instructions:

https://github.com/gwenzek/hercules?tab=readme-ov-file#installation

I've tried to put the most up to date versions of each dep that would work with the current code. Only tested with burndown-project so far which was my main interest.

Updating further is non trivial, cause it also requires updating some of the dependencies.

chucker commented 1 month ago

I was able to run labours -m burndown-project using the following install instructions

That gets me a lot further!

Now I get:

  File "/Users/chucker/hercules/venv/bin/labours", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/Users/chucker/hercules/python/labours/cli.py", line 154, in main
    reader = read_input(args)
             ^^^^^^^^^^^^^^^^
  File "/Users/chucker/hercules/python/labours/readers.py", line 439, in read_input
    reader.read(ins)
  File "/Users/chucker/hercules/python/labours/readers.py", line 220, in read
    from labours.pb_pb2 import AnalysisResults
  File "/Users/chucker/hercules/python/labours/pb_pb2.py", line 35, in <module>
    _descriptor.FieldDescriptor(
  File "/Users/chucker/hercules/venv/lib/python3.12/site-packages/google/protobuf/descriptor.py", line 621, in __new__
    _message.Message._CheckCalledFromGeneratedFile()
TypeError: Descriptors cannot be created directly.
If this call came from a _pb2.py file, your generated code is out of date and must be regenerated with protoc >= 3.19.0.
If you cannot immediately regenerate your protos, some other possible workarounds are:
 1. Downgrade the protobuf package to 3.20.x or lower.
 2. Set PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python (but this will use pure-Python parsing and will be much slower).

If I set that environment variable, it proceeds, then eventually says:

Traceback (most recent call last):
  File "/Users/chucker/hercules/venv/bin/labours", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/Users/chucker/hercules/python/labours/cli.py", line 154, in main
    reader = read_input(args)
             ^^^^^^^^^^^^^^^^
  File "/Users/chucker/hercules/python/labours/readers.py", line 439, in read_input
    reader.read(ins)
  File "/Users/chucker/hercules/python/labours/readers.py", line 233, in read
    for key, val in self.data.contents.items():
                    ^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'RepeatedCompositeFieldContainer' object has no attribute 'items'

Does this suggest I need to recreate the generated code? (How?)

gwenzek commented 1 month ago

I think the protobuffer integration is broken in my branch, but you don't have to use protobuffer to save Hercules analysis

chucker commented 1 month ago

Ah yes. It does work if I don't specify ProtoBuf. For example:

./hercules --burndown --first-parent some/path/to/local/repo | labours -m burndown-project

Thanks!