Skip to content

Commit

Permalink
Remove potential leading colon from PYTHONPATH (#356)
Browse files Browse the repository at this point in the history
* Remove potential leading colon from PYTHONPATH

* Create `io.py` module in test directory as a regression test
  • Loading branch information
tetsuo-cpp authored Dec 16, 2022
1 parent 0124040 commit 2712306
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ COPY --from=build /go/pkg/mod/github.com/mwitkow/go-proto-validators@v${go_mwitk
# Copy mypy
COPY --from=build /opt/mypy-protobuf/ /opt/mypy-protobuf/
RUN mv /opt/mypy-protobuf/bin/* /usr/local/bin/
ENV PYTHONPATH="${PYTHONPATH}:/opt/mypy-protobuf/"
ENV PYTHONPATH="${PYTHONPATH:+$PYTHONPATH:}/opt/mypy-protobuf/"

ADD all/entrypoint.sh /usr/local/bin
RUN chmod +x /usr/local/bin/entrypoint.sh
Expand Down
11 changes: 11 additions & 0 deletions all/test/all_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -688,6 +688,17 @@ func (s *TestSuite) TestAllCases() {
defer os.RemoveAll(dir)
s.Require().NoError(err)
err = copy.Copy(src, path.Join(dir, "all"), opt)

// We previously had a buggy PYTHONPATH which would search the working directory for
// modules when running the Python generator.
//
// Let's add something that with the same name as a standard library module to the test
// directory as a regression test.
//
// Further context: https://github.com/namely/docker-protoc/pull/356
_, err = os.OpenFile(path.Join(dir, "io.py"), os.O_RDONLY|os.O_CREATE, 0666)
s.Require().NoError(err)

argsStr := fmt.Sprintf(DockerCmd,
dir,
container,
Expand Down

0 comments on commit 2712306

Please sign in to comment.