Axelrod-Python / Axelrod

A research tool for the Iterated Prisoner's Dilemma
http://axelrod.readthedocs.org/
Other
723 stars 265 forks source link

Split requirements.txt to factor out hypothesis and prompt_toolkit #1407

Closed marcharper closed 1 year ago

marcharper commented 1 year ago

To address #1379, this PR defines three installation options for requirements:

Once merged and released, the different variants can be installed like so:

pip install axelrod[Human]

with the default case not requiring specification (e.g. pip install axelrod). I tested the variants and warnings locally in a venv but didn't add explicit tests to CI.

Strategy import is updated to check for the presence of prompt_toolkit and include the Human strategy or not accordingly (and with a warning to the user that it's not available, when applicable).

I wasn't sure whether to include prompt_toolkit by default (the Human strategy is nice for live demos). We could go that route and instead have

We could define further variants (e.g. don't import any plotting functions) if desired.

Fixes #1379

marcharper commented 1 year ago

os.listdir("requirements/") returns a list. I can tweak the file and get to it run; but why the codes work for you but not for me?

There were a couple of issues actually. I was using pip install instead of setup.py, but it seems like it should not have worked for me locally anyway (given the list vs context manager error you got). I rewrote setup.py to use pathlib and fixed that issue.

Also, there's a difference in the pip command for the package on pypy and what you'll need to use locally. I updated the documentation with the correct command.

I think it's possible to use setup.py directly, with a command like the following, but it didn't work for me locally, and easy_install is deprecated, so I'm sticking with pip.

python setup.py install easy_install "axelrod[human]"
Nikoleta-v3 commented 1 year ago

Perfect 🚀 The setup.py file now works.

Regarding pip, since I am using zsh I have to run,

pip install .\[development\]
# or
pip install ".[development]"

instead of pip install .[development]. Not sure if we want to mention it in the docs.

drvinceknight commented 1 year ago

The failure of the CI looks like a specific check we had implemented to make sure no strategies were forgotten along the way:

Run python -m pip install pylint
[2](https://github.com/Axelrod-Python/Axelrod/actions/runs/3864735683/jobs/6587748984#step:11:2)
  python -m pip install pylint
[3](https://github.com/Axelrod-Python/Axelrod/actions/runs/3864735683/jobs/6587748984#step:11:3)
  python -m pylint --disable=all --enable=unused-import axelrod/strategies/_strategies.py
[4](https://github.com/Axelrod-Python/Axelrod/actions/runs/3864735683/jobs/6587748984#step:11:4)
  shell: /usr/bin/bash -e {0}

I'm guessing this is something that can be addressed by including a pragma somewhere.

Happy to take a look if that would be helpful.