robertmartin8 / PyPortfolioOpt

Financial portfolio optimisation in python, including classical efficient frontier, Black-Litterman, Hierarchical Risk Parity
https://pyportfolioopt.readthedocs.io/
MIT License
4.28k stars 930 forks source link

pyportfolioopt or PyPortfolioOpt inconsistency makes error in wheel installation #425

Closed AchmadFathoni closed 2 years ago

AchmadFathoni commented 2 years ago

Describe the bug When I try install wheel package using python -m build --wheel --no-isolation and python -m installer --destdir="$pkgdir" dist/*.whl I got

Traceback (most recent call last):
  File "/usr/lib/python3.10/runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/usr/lib/python3.10/site-packages/installer/__main__.py", line 85, in <module>
    _main(sys.argv[1:], "python -m installer")
  File "/usr/lib/python3.10/site-packages/installer/__main__.py", line 81, in _main
    installer.install(source, destination, {})
  File "/usr/lib/python3.10/site-packages/installer/_core.py", line 77, in install
    root_scheme = _process_WHEEL_file(source)
  File "/usr/lib/python3.10/site-packages/installer/_core.py", line 21, in _process_WHEEL_file
    stream = source.read_dist_info("WHEEL")
  File "/usr/lib/python3.10/site-packages/installer/sources.py", line 139, in read_dist_info
    return self._zipfile.read(path).decode("utf-8")
  File "/usr/lib/python3.10/zipfile.py", line 1464, in read
    with self.open(name, "r", pwd) as fp:
  File "/usr/lib/python3.10/zipfile.py", line 1503, in open
    zinfo = self.getinfo(name)
  File "/usr/lib/python3.10/zipfile.py", line 1430, in getinfo
    raise KeyError(
KeyError: "There is no item named 'PyPortfolioOpt-1.5.1.dist-info/WHEEL' in the archive"

The content of PyPortfolioOpt-1.5.1-py3-none-any.whl:

├── pypfopt
│   ├── base_optimizer.py
│   ├── black_litterman.py
│   ├── cla.py
│   ├── discrete_allocation.py
│   ├── efficient_frontier
│   │   ├── efficient_cdar.py
│   │   ├── efficient_cvar.py
│   │   ├── efficient_frontier.py
│   │   ├── efficient_semivariance.py
│   │   └── __init__.py
│   ├── exceptions.py
│   ├── expected_returns.py
│   ├── hierarchical_portfolio.py
│   ├── __init__.py
│   ├── objective_functions.py
│   ├── plotting.py
│   └── risk_models.py
└── pyportfolioopt-1.5.1.dist-info
    ├── LICENSE.txt
    ├── METADATA
    ├── RECORD
    └── WHEEL

Expected behavior The key should be 'pyportfolioopt-1.5.1.dist-info/WHEEL' or wheel name should be PyPortfolioOpt-1.5.1.dist-info

Operating system, python version, PyPortfolioOpt version Archlinux, python 3.10, PyPortfolioOpt 1.5.1

Additional Context I got the PyPortfolioOpt 1.5.1 source from pypi

robertmartin8 commented 2 years ago

Thanks for raising this. I believe it's due to my build workflow, which uses poetry. I'm not sure it respects case sensitivity when it builds the wheels, which probably explains why on PyPi the package is lower case.

I'll have a look to see if there's a fix for this, perhaps in arguments provided to poetry build and poetry publish.

AchmadFathoni commented 2 years ago

Lowering the case of the name in this line is working fix for me https://github.com/robertmartin8/PyPortfolioOpt/blob/102c593d54e979c1046ad5cf5d3e1a9c77dcd692/pyproject.toml#L2

robertmartin8 commented 2 years ago

Thanks for the fix! I'll double check that changing it to lower case doesn't lead to any problems elsewhere. If not, I will merge this in the next PR

AchmadFathoni commented 2 years ago

I think it is fixed, thank you.