Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remote API for Python: Missing typing-extensions dependency in pyproject.toml #1335

Open
WeeknightMVP opened this issue Mar 16, 2022 · 6 comments
Labels
remote-api Related to Cryptol's remote API
Milestone

Comments

@WeeknightMVP
Copy link

pyproject.toml is missing a dependency on typing-extensions, which is required for from typing_extensions import Literal in cryptol/__init__.py. Adding typing-extensions = "^4.1.1" (or an earlier version that correctly defines typing_extensions.Literal) to [tool.poetry.dependencies] in pyproject.toml (or running poetry add typing-extensions from cryptol-remote-api/python) would account for this dependency.

@RyanGlScott
Copy link
Contributor

Good catch. Out of curiosity, is this causing build issues for you? I ask since our test suite hasn't encountered difficulties due to the lack of an explicit typing-extensions dependency, but this may simply be because mypy (a different dependency) already depends on typing-extensions. (I'm a bit alarmed that the test suite would work without declaring an explicit dependency, but perhaps this is simply a quirk of how Python's package management works.)

@WeeknightMVP
Copy link
Author

WeeknightMVP commented Mar 21, 2022

@RyanGIScott

I encountered this when starting a fresh Python 3.10 Poetry project from a base Python 3.10 installation, something like:

$ sudo add-apt-repository ppa:deadsnakes/ppa
$ sudo apt-get update
$ sudo apt-get install python3.10 python3.10-venv
$ curl -sSL https://install.python-poetry.org | python3.10 -
$ poetry new MyExample
$ cd MyExample
$ poetry add cryptol
$ echo "import cryptol" > myexample.py

As you point out, mypy depends on typing-extensions. mypy is included among pyproject.toml's dev-dependencies, but not dependencies. poetry add pulls development dependencies when instructed (e.g. poetry add --dev cryptol), but not by default. Any packages installed by Poetry will of course appear in poetry.lock, and be available for poetry run, poetry shell, etc., after poetry install or poetry update. These commands install dev-dependencies by default, but offer a --no-dev option to omit them. Somewhere in here is an insight into why cryptol-remote-api unit tests work, and how to configure CI/CD to distinguish usage and development tests.

@pnwamk
Copy link
Contributor

pnwamk commented Mar 21, 2022

Ah yes, that nicely explains why the typing-extensions entry in the updated poetry.lock swaps the category from dev to main: https://github.com/GaloisInc/cryptol/pull/1336/files

@RyanGlScott
Copy link
Contributor

Tricky. I suppose if we really wanted to be thorough, we'd have first have to run poetry install before running mypy, then run poetry install --no-dev before running the Python unit tests. (Assuming that the poetry install --no-dev invocation removes development dependencies from the current scope, that is.)

@WeeknightMVP
Copy link
Author

WeeknightMVP commented Mar 21, 2022

@RyanGIScott I tested poetry update --no-dev, which uninstalls dev-dependencies (except as needed for dependencies, having added typing-extensions to dependencies):

$ cd cryptol-remote-api/python
$ poetry install
...
$ poetry update --no-dev
Updating dependencies
Resolving dependencies... (15.6s)

Package operations: 0 installs, 0 updates, 3 removals

  • Removing mypy (0.812): Pending...
  • Removing mypy (0.812): Removing...
  • Removing mypy (0.812)
  • Removing mypy-extensions (0.4.3): Pending...
  • Removing mypy-extensions (0.4.3): Removing...
  • Removing mypy-extensions (0.4.3)
  • Removing typed-ast (1.4.3): Pending...
  • Removing typed-ast (1.4.3): Removing...
  • Removing typed-ast (1.4.3)

(Edited to reflect typing-extensions in main dependencies.)

@RyanGlScott
Copy link
Contributor

#1336 adds an explicit typing-extensions dependency, which fixes the immediate problem. I'll leave this issue open to track the idea of only installing the non-developer dependencies in CI to catch mistakes like this in the future.

@RyanGlScott RyanGlScott added this to the 2.14.0 milestone May 10, 2022
@RyanGlScott RyanGlScott added the remote-api Related to Cryptol's remote API label Jul 5, 2022
@RyanGlScott RyanGlScott modified the milestones: 2.14.0, 2.15.0 Sep 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
remote-api Related to Cryptol's remote API
Projects
None yet
Development

No branches or pull requests

3 participants