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

Switch to poetry for dependency management #78

Closed
willzeng opened this issue Nov 11, 2024 · 9 comments
Closed

Switch to poetry for dependency management #78

willzeng opened this issue Nov 11, 2024 · 9 comments
Assignees
Labels
infrastructure Non-quantum things to improve the robustness of our package, e.g. CI/CD
Milestone

Comments

@willzeng
Copy link
Collaborator

We can switch to using poetry for dependency management like in mitiq and in metriq-gym. We can add the linter/formatter as well like in unitaryfund/metriq-gym#22

@willzeng willzeng added the feature New feature or request label Nov 11, 2024
@jordandsullivan jordandsullivan added infrastructure Non-quantum things to improve the robustness of our package, e.g. CI/CD and removed feature New feature or request labels Nov 15, 2024
@jordandsullivan jordandsullivan added this to the 0.4.3 milestone Jan 29, 2025
@jordandsullivan
Copy link
Collaborator

@vprusso @cosenal Would you be able to help support the UCC team on this one since you set this up recently for Metriq gym? :)

@vprusso
Copy link

vprusso commented Jan 30, 2025

Hey @jordandsullivan

I think the general approach here that I would take would be:

  1. Remove setup.py and requirements.txt from the root directory of the project.
  2. Include a pyproject.toml file in the root directory that looks something like this:
[tool.poetry]
name = "ucc"
version = "0.1.0"
description = "Unitary Compiler Collection: A quantum circuit interface and compiler for multiple quantum frameworks"
authors = ["Jordan Sullivan <jordan@unitary.foundation>", "Misty Wahl", "Nate Stemen"]
license = "GPL-3.0"
readme = "README.md"
repository = "https://github.com/unitaryfund/ucc"
packages = [{ include = "ucc" }]

[tool.poetry.dependencies]
python = ">=3.12"
qiskit = ">=1.3.0"
qiskit-qasm3-import = "0.5.1"
cirq-core = ">=1.4.0"
pytket = ">=1.3.0"
qbraid = ">=0.7.3"
ply = ">=3.11"

[tool.poetry.group.dev.dependencies]
pytest = ">=6.0"
pytest-cov = ">=2.10"

[tool.poetry.group.doc.dependencies]
sphinx = "8.1.3"
myst-parser = ">=0.15"

[tool.poetry.scripts]
ucc = "ucc.__main__:main"

[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
  1. I would remove VERSION.txt as well as this information should be able to be managed by the pyproject.toml file and is also captured in the _version.py file (but perhaps this can be removed as well and consolidated in one location to minimize version number changes).
  2. The Dockerfile will also need to use poetry and not requirements.txt. So something like:
FROM python:3.12-slim

# Install system dependencies (including GNU Parallel)
RUN apt-get update && apt-get install -y parallel curl && rm -rf /var/lib/apt/lists/*

# Install Poetry
ENV POETRY_VERSION=1.8.3
RUN curl -sSL https://install.python-poetry.org | python3 -

# Ensure Poetry is added to PATH
ENV PATH="/root/.local/bin:$PATH"

# Copy the entire project into the container
COPY . /ucc

# Set the working directory to the root of your project
WORKDIR /ucc

# Install dependencies using Poetry
RUN poetry install --no-root --no-interaction --no-ansi

# Install the `ucc` package itself
RUN poetry install --no-interaction --no-ansi

# Ensure the virtual environment is properly activated
ENV VIRTUAL_ENV=/ucc/.venv
ENV PATH="/ucc/.venv/bin:$PATH"

# Show installed package details
RUN poetry show ucc
  1. Now the readthedocs.yml file also needs to be changed, but I'm not sure how best to do this. Perhaps there are some templates we can borrow from mitiq?

There might be some minor things I am missing (like updating the README.md to include steps to use poetry instead of pip), but that should be the bulk of it!

Hope that helps, and feel free to reach out if we can help more!

@bachase
Copy link
Collaborator

bachase commented Feb 4, 2025

In addition to #208 I also created #209 to demonstrate uv as an alternative. Its not a huge difference at this stage, but uv feels like it has stronger momentum going forward. Can always park for now and revisit.

@willzeng
Copy link
Collaborator Author

willzeng commented Feb 4, 2025

I have no preference either way for uv or poetry. Main thing on this issue was to update from just using setup.py. Will let you all on the dev team decide which of those you want to go with.

@willzeng
Copy link
Collaborator Author

willzeng commented Feb 4, 2025

Also, one day in and first PR by @bachase! Great :)

@cosenal
Copy link

cosenal commented Feb 4, 2025

I have no strong preference either, but I would like for us to be consistent across projects in the organization.

Yay to @bachase's first PR first two PRs!

@Misty-W
Copy link
Collaborator

Misty-W commented Feb 4, 2025

+1 for consistency and for the 2 PRs on the first day! ✨

@bachase
Copy link
Collaborator

bachase commented Feb 4, 2025

Thanks all -- lets focus on the poetry one for review and release. I don't think its that urgent to change, and it won't be too painful if we decide to change later on.

@bachase
Copy link
Collaborator

bachase commented Feb 5, 2025

Closing this based on #208, but will open a followup to introduce the linter/formatter changes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
infrastructure Non-quantum things to improve the robustness of our package, e.g. CI/CD
Projects
None yet
Development

No branches or pull requests

6 participants