Skip to content

Set PYTHONPATH in olbase image to avoid manually specifying it for scripts#12811

Merged
RayBB merged 1 commit into
internetarchive:masterfrom
cdrini:chore/dockerfile-pythonpath-copydocs
May 27, 2026
Merged

Set PYTHONPATH in olbase image to avoid manually specifying it for scripts#12811
RayBB merged 1 commit into
internetarchive:masterfrom
cdrini:chore/dockerfile-pythonpath-copydocs

Conversation

@cdrini

@cdrini cdrini commented May 27, 2026

Copy link
Copy Markdown
Collaborator

I got tired of having to specify PYTHONPATH=. everywhere ; we can bake this into the image and then in theory never specify it again.

Technical

Testing

To test it, I added the ENV line to our oldev file, and then rebuilt it and confirmed copydocs worked without having to set the environment variable.

# Before
$ docker compose exec web ./scripts/copydocs.py --help
Traceback (most recent call last):
  File "/openlibrary/./scripts/copydocs.py", line 12, in <module>
    from scripts.solr_builder.solr_builder.fn_to_cli import FnToCLI
ModuleNotFoundError: No module named 'scripts'

# After
# Add the ENV file to oldev for testing; last line is fastest
docker compose build web
docker compose up -d --no-deps web
$ docker compose exec web ./scripts/copydocs.py --help
usage: copydocs.py [-h] [--src SRC] [--dest DEST] [--comment COMMENT]
                   [--recursive | --no-recursive] [--editions | --no-editions]
                   [--lists [LISTS ...]] [--search SEARCH] [--search-limit SEARCH_LIMIT]
                   [keys ...]
...

Needs another pass of testing to confirm the site comes up normally with this set though.

Screenshot

Stakeholders

@RayBB

Copilot AI review requested due to automatic review settings May 27, 2026 10:19
@cdrini cdrini changed the title Set PYTHONPATH for copydocs scripts Set PYTHONPATH in olbase image to avoid manually specifying it for scripts May 27, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the olbase Docker image to set a default PYTHONPATH so repository scripts (e.g., scripts/copydocs.py) can be executed inside the container without manually prefixing commands with PYTHONPATH=..

Changes:

  • Set ENV PYTHONPATH=/openlibrary in the base Docker image to make local modules importable by default.

Comment thread docker/Dockerfile.olbase
@mekarpeles mekarpeles assigned mekarpeles and RayBB and unassigned mekarpeles May 27, 2026
@github-project-automation github-project-automation Bot moved this to Waiting Review/Merge from Staff in Ray's Project May 27, 2026
@mekarpeles

Copy link
Copy Markdown
Member

LGTM; @cdrini + @RayBB let me know if there's any further testing we should do to ensure it runs smoothly on prod

@RayBB RayBB left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We build and tested locally on the call.

@RayBB RayBB merged commit 3fd610c into internetarchive:master May 27, 2026
4 checks passed
@github-project-automation github-project-automation Bot moved this from Waiting Review/Merge from Staff to Done in Ray's Project May 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants