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

Migrate to uv #84

Merged
merged 1 commit into from
Jan 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 16 additions & 18 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,32 +29,30 @@ jobs:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- uses: tlambert03/setup-qt-libs@v1
- name: Setup for Qt testing
run: |
/sbin/start-stop-daemon --start --quiet --pidfile /tmp/custom_xvfb_99.pid --make-pidfile --background --exec /usr/bin/Xvfb -- :99 -screen 0 1920x1200x24 -ac +extension GLX

- name: Install pytest and dependencies
- name: Install uv
uses: astral-sh/setup-uv@v5
with:
enable-cache: true
python-version: ${{ matrix.python-version }}

- name: Install project with all extras
run: |
python -m pip install --upgrade pip
python -m pip install -v .[viz,io,perf,misc,dev] ${{ matrix.qt-api }}
python -m pip list
uv sync --all-extras --dev --group ${{ matrix.qt-api }}
export QT_API=${{ matrix.qt-api }}

- name: Test with pytest
if: matrix.python-version != '3.12' || matrix.qt-api != 'pyside6'
run: |
python -u -m pytest -v
run: uv run pytest

- name: Test with pytest with coverage
if: matrix.python-version == '3.12' && matrix.qt-api == 'pyside6'
run: |
python -u -m pytest -v --cov erlab --junitxml=junit.xml
run: uv run pytest -v --cov erlab --junitxml=junit.xml

- name: Upload coverage to Codecov
if: matrix.python-version == '3.12' && matrix.qt-api == 'pyside6'
Expand All @@ -73,18 +71,18 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5

- name: Install uv
uses: astral-sh/setup-uv@v5
with:
enable-cache: true
python-version: "3.12"

- name: Install mypy and dependencies
run: |
python -m pip install --upgrade pip
python -m pip install .[viz,io,perf,misc,dev] mypy[reports,faster-cache] pyqt6
python -m pip list
run: uv sync --all-extras --dev --group pyqt6

- name: Run mypy
run: mypy --install-types --non-interactive --html-report mypy-report .
run: uv run mypy --install-types --non-interactive --html-report mypy-report .

- name: Upload mypy results
uses: actions/upload-artifact@v4
Expand Down
21 changes: 9 additions & 12 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,21 +37,18 @@ jobs:
changelog_increment_filename: body.md
extra_requirements: "cz-changeup"

- name: Build package distributions
id: build
- name: Install uv
if: env.REVISION != env.PREVIOUS_REVISION
run: |
python -m venv venv
source venv/bin/activate
python -m pip install --upgrade build
python -m build
uses: astral-sh/setup-uv@v5
with:
enable-cache: true
python-version: "3.12"

- name: Publish package distributions to PyPI
id: pypi-publish
- name: Build and publish package distributions to PyPI
if: env.REVISION != env.PREVIOUS_REVISION
uses: pypa/gh-action-pypi-publish@release/v1
with:
verbose: true
run: |
uv build
uv publish --trusted-publishing always

- name: Publish package distributions to GitHub Releases
id: github-release
Expand Down
13 changes: 5 additions & 8 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@ version: 2
build:
os: ubuntu-24.04
tools:
python: "3.11"
python: "3.12"
jobs:
post_install:
- pip install uv
- UV_PROJECT_ENVIRONMENT=$READTHEDOCS_VIRTUALENV_PATH uv sync --all-extras --group docs --link-mode=copy

# Build documentation in the "docs/" directory with Sphinx
sphinx:
Expand All @@ -18,10 +22,3 @@ sphinx:
# Optionally build your docs in additional formats such as PDF and ePub
formats:
- pdf

# Optional but recommended, declare the Python requirements required
# to build your documentation
# See https://docs.readthedocs.io/en/stable/guides/reproducible-builds.html
python:
install:
- requirements: docs/requirements.txt
93 changes: 19 additions & 74 deletions docs/source/contributing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ report <https://stackoverflow.com/help/mcve>`_, and this `article on minimal bug
Creating a development environment
==================================

First, you will need to install ``git`` and ``conda`` (or ``mamba``).
First, you will need to install ``git`` if you do not already have it.

Installing git
--------------
Expand Down Expand Up @@ -84,21 +84,15 @@ Cloning the repository
(main project) *erlabpy* repository.


.. _Installing conda:
.. _Installing uv:

Installing conda
----------------
Installing uv
-------------

Before starting any development, you'll need to create an isolated environment under a
package manager like conda. If you don't have conda installed, the recommended way is to
install `miniforge <https://github.com/conda-forge/miniforge>`_. The Scikit-HEP project
has a `great guide <https://scikit-hep.org/user/installing-conda>`_ for installing
conda.

.. hint::

- `Mamba <https://mamba.readthedocs.io>`_ is a faster alternative to conda with
additional features. It is installed alongside conda when you install miniforge.
If you are used to working with virtual environments and package managers, the modern
way to install the package is with `uv <https://docs.astral.sh/uv/>`_. For installation
instructions, see the `uv documentation
<https://docs.astral.sh/uv/getting-started/installation/>`_.

Editable installation from source
---------------------------------
Expand All @@ -107,70 +101,21 @@ An editable installation allows you to make changes to the code and see the chan
reflected in the package without having to reinstall it. Before installing:

- Make sure you have `cloned the repository <#cloning-the-repository>`_.
- Make sure you have :ref:`installed conda or mamba <Installing Conda>`.
- ``cd`` to the *erlabpy* source directory.

1. Create and activate a mamba (or conda) environment.

.. note::
- Make sure you have :ref:`installed uv <Installing uv>`.

Replace :code:`<envname>` with the environment name you prefer.
1. Open a terminal and navigate to the root of the *erlabpy* repository.

.. hint::

If using conda, replace :code:`mamba` with :code:`conda`.
2. Run:

.. code-block:: sh

mamba env create -f environment.yml -n <envname>
mamba activate <envname>


2. Build and install the package.

.. note::

The ``editable_mode=compat`` setting enables static analysis tools to work with
the package. See `this issue <https://github.com/pypa/setuptools/issues/3518>`_
for more information.

.. code-block:: sh

pip install -e ".[dev]" --config-settings editable_mode=compat

These two steps will create the new environment, and not touch any of your existing
environments, nor any existing Python installation.

To view your environments::

mamba env list

To return to your root environment::

mamba deactivate
uv sync --all-extras --dev

Updating the editable installation
----------------------------------

* For minor updates with editable installs, it is sufficient to just :ref:`update the
main branch <update-main-branch>`.

* When there are changes to the dependencies, you should also update the environment:

.. hint::

If using conda, replace :code:`mamba` with :code:`conda`.

.. code-block:: bash

mamba env update -f environment.yml -n <envname>

* In case of major changes, it is recommended to rebuild the package.

.. code-block:: bash

mamba activate <envname>
pip install -e . --force-reinstall --no-deps --config-settings editable_mode=compat
main branch <update-main-branch>` and run ``uv sync`` again.

.. _development.workflow:

Expand Down Expand Up @@ -430,19 +375,19 @@ Some other important things to know about the docs:
Building the documentation locally
----------------------------------

Check whether all documentation dependencies are installed with
Clone the repository and navigate to the root of the repository. Make sure you have
:ref:`installed uv <Installing uv>`. Install the documentation dependencies by running:

.. code-block:: sh

pip install -r docs/requirements.txt
uv sync --all-extras --dev --group docs

then build the documentation by running:

.. code-block:: sh

cd docs/
make clean
make html
cd docs
uv run make html

Then you can find the HTML output files in the folder ``erlabpy/docs/build/html/``.

Expand All @@ -452,7 +397,7 @@ use Google Chrome as your browser, you could enter::

google-chrome build/html/index.html

in the terminal, running from within the ``doc/`` folder. You should now see a new tab
in the terminal, running from within the ``docs/`` folder. You should now see a new tab
pop open in your local browser showing the documentation. The different pages of this
local build of the documentation are linked together, so you can browse the whole
documentation by following links the same way you would on the hosted website.
18 changes: 13 additions & 5 deletions docs/source/getting-started.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,17 @@ ERLabPy depends on a number of scientific python libraries.
conda
-----

The recommended way to install ERLabPy is via conda. If you do not have conda installed,
follow the :ref:`conda installation instructions <Installing conda>`. Once you have a
working conda environment, you can install ERLabPy with the conda command line tool: ::
The recommended way to install ERLabPy is via conda. If you are new to conda, the
Scikit-HEP project has a `great guide <https://scikit-hep.org/user/installing-conda>`_
to get you started.

.. hint::

- `Mamba <https://mamba.readthedocs.io>`_ is a faster alternative to conda with
additional features. It is installed alongside conda when you install miniforge.

Once you have a working conda environment, you can install ERLabPy with the conda
command line tool: ::

conda install -c conda-forge erlab

Expand Down Expand Up @@ -75,8 +83,8 @@ Optional dependency groups can be installed with the following commands: ::
See the :ref:`optional dependencies` section for all available groups and their
contents.

From source
-----------
From source (uv)
----------------

If you wish to install ERLabPy from source, see the :doc:`contributing`.

Expand Down
Loading
Loading