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

Build distribution packages #3

Merged
merged 17 commits into from
Jan 10, 2024
Merged

Build distribution packages #3

merged 17 commits into from
Jan 10, 2024

Conversation

nalourie
Copy link

Update the packaging, add a nox session, and create continuous integration jobs to build the distribution package for opda.

Since opda is a library rather than an application, it is more
accurate to speak of releases rather than deployments.
The environment and concurrency group used in release.yml are
intended to handle all release-related tasks, so update their names
to reflect this intention.
Artifacts made with actions/upload-artifact default to 90 retention
days. In contrast, actions/upload-pages-artifact defaults to 1
retention day. Increase the retention days from 60 to 90 so that
the github-pages artifact will be retained for the same amount of
time as other artifacts from the same workflow run.
Move the definition of the lint session before the definition of
the docs session so that their order is consistent everywhere: the
noxfile source, the default session order, and the order in the
continuous integration workflow (build.yml).
The optional dependencies are frequently installed in nox sessions
and continuous integration. Thus, it is beneficial to have each set
of optional dependencies be minimal for the desired use case. Only
the notebooks (nbs) and testing (tests) optional dependencies
require the experiments package. It can be removed from the rest.
After removing the experiments package from the documentation
(docs) dependencies, matplotlib must be added back in, as it is no
longer included transitively.
Rename the "tests" optional dependency to "test" so that it matches
the nox session's name to reduce confusion. Similarly, reorder the
optional dependencies to match the nox sessions' order.
Some code, like the experiments package, is only intended for use
in the research behind opda. Such code is valuable to keep in this
repository so that the research can be reproduced; however, it is
not useful to distribute that code to end-users who only want to
use the methods. Thus, split the local and distribution package
builds for these two different use cases. Implement this split
using comments in the pyproject.toml file. Each line ending in a
`# build: local-only` comment should be removed before building the
distribution package. Similarly, everything after the header:
`# -- build: local-only -----` should be removed.

Using these comments, the distribution package's pyproject.toml
file can be constructed with simple text processing. For example,
using awk:

  awk \
    '/# -- build: local-only --/ {exit} !(/# build: local-only/) {print}' \
    pyproject.toml

Even using this mechanism to exclude the experiments package,
setuptools will still include the source for it in the sdist. So,
also create a MANIFEST.in file intended solely for the distribution
package and adapt pyproject.toml to make sure it builds the local
and distribution packages correctly (excluding all local-only files
from the distribution package's sdist and wheel).
@nalourie nalourie force-pushed the build-distribution-packages branch from a7448f5 to 74249f1 Compare January 10, 2024 03:31
Tests for the project, including local-only code like the
experiments package, should be run frequently. Tests for
distribution packages should be run against all supported
combinations of dependencies. Thus, testing distribution packages
is expensive and should be run less frequently. For this reason, it
makes sense to split the "test" nox session into two sessions:
"test" for testing the whole project, and "testpackage" for testing
distribution packages. Similarly, split the "test" job in build.yml
into corresponding "test" and "testpackage" jobs. Finally, update
the default nox sessions to reflect these changes.
The generic name, docs, is more immediately obvious and less tied
to the infrastructure we happen to use for the project.
@nalourie nalourie force-pushed the build-distribution-packages branch from 74249f1 to bea4e39 Compare January 10, 2024 03:48
@nalourie nalourie merged commit 76fb8cc into main Jan 10, 2024
12 checks passed
@nalourie nalourie deleted the build-distribution-packages branch January 10, 2024 17:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants