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

Using glide for go package vendor #2627

Merged
merged 9 commits into from
Jul 3, 2017

Conversation

typhoonzero
Copy link
Contributor

@typhoonzero typhoonzero commented Jun 27, 2017

Fixes: #2605
Related descussions: #2583
Using glide for go vendoring.

@@ -48,6 +48,7 @@ option(COVERALLS_UPLOAD "Package code coverage data to coveralls" OFF)
option(ON_TRAVIS "Exclude special unit test on Travis CI" OFF)
option(WITH_C_API "Compile PaddlePaddle with C-API(Prediction)" OFF)
option(WITH_GOLANG "Compile PaddlePaddle with GOLANG" OFF)
option(GLIDE_INSTALL "Download and install go dependencies " ON)
Copy link
Collaborator

@wangkuiyi wangkuiyi Jun 27, 2017

Choose a reason for hiding this comment

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

Thanks for this PR!

I think we need a design doc for this work. In particular,

  1. Why we need package manager for Go, or say, why the default toolchain is not enough.
  2. Why we choose glide, comparing with other possible choices.

The design doc, together with discussions with it, would be a deposit of the reasons/thoughts we have in mind, and would be valuable for future contributors to understand the situation so could they move on towards further improvements.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, I'll add a design doc before going on working with this PR.

I thought previous discussions in #2583 is the reason why I'm working on this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Posted here: #2643

if(EXISTS $ENV{GOPATH}/bin/glide)
set(GLIDE "$ENV{GOPATH}/bin/glide")
else()
message(FATAL_ERROR "no glide executeble found: $ENV{GOPATH}/bin/glide")
Copy link
Contributor

@helinwang helinwang Jun 27, 2017

Choose a reason for hiding this comment

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

Maybe instead of fail, we can do something like execute_process(env GOPATH ${PADDLE_GO_PATH} ${CMAKE_Go_COMPILER} get github.com/Masterminds/glide (I forgot the exact cmake command to temporarily set environment variable).

@@ -280,7 +282,7 @@ function(go_library TARGET_NAME)
add_library(${TARGET_NAME} STATIC ${dummyfile})
endif()
if(go_library_DEPS)
add_dependencies(${TARGET_NAME} ${go_library_DEPS})
add_dependencies(${TARGET_NAME} ${go_library_DEPS} paddle_go_path_link)
Copy link
Contributor

Choose a reason for hiding this comment

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

Where is paddle_go_path_link declared?

WORKING_DIRECTORY ${PADDLE_GO_SRC})
add_custom_command(TARGET ${TARGET_NAME} POST_BUILD
# Automatically get all dependencies specified in the source code
#COMMAND env GOPATH=${GOPATH} ${CMAKE_Go_COMPILER} get -d ./...
Copy link
Contributor

@gangliao gangliao Jun 30, 2017

Choose a reason for hiding this comment

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

delete this line

@typhoonzero typhoonzero changed the title [WIP]Using glide for go package vendor Using glide for go package vendor Jul 1, 2017
${GO_SOURCE}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
add_dependencies(${TARGET_NAME} go_path)
"./${CMAKE_CURRENT_SOURCE_REL_DIR}/${GO_SOURCE}"
Copy link
Contributor

Choose a reason for hiding this comment

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

I am curious the code works before, why now need to be under GOPATH?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

When compiling with vendor package, go build must run under GOPATH or it will fail. And this also removes warnings when glide install.

add_custom_target(${TARGET_NAME} ALL DEPENDS ${TARGET_NAME}_timestamp ${go_binary_DEPS})
"./${CMAKE_CURRENT_SOURCE_REL_DIR}/${go_binary_SRCS}"
WORKING_DIRECTORY "${PADDLE_IN_GOPATH}/go")
# add_custom_target(${TARGET_NAME} ALL DEPENDS go_vendor ${TARGET_NAME}_link ${TARGET_NAME}_timestamp ${go_binary_DEPS})
Copy link
Contributor

Choose a reason for hiding this comment

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

No commended out code please.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

if(EXISTS $ENV{GOPATH}/bin/glide)
set(GLIDE "$ENV{GOPATH}/bin/glide")
else()
message(FATAL_ERROR "no glide executeble found: $ENV{GOPATH}/bin/glide")
Copy link
Contributor

Choose a reason for hiding this comment

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

This requires user to install glide, maybe we can install for them using go get github.com/Masterminds/glide?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

  1. go get will always install the latest version from default branch, which does not guarantee the behavior.
  2. Thought glide is like cmake or gcc, put it into Dockerfileis better?

Copy link
Contributor

Choose a reason for hiding this comment

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

I see, good point. Thanks.

Copy link
Contributor

@helinwang helinwang left a comment

Choose a reason for hiding this comment

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

LGTM++

@typhoonzero typhoonzero dismissed wangkuiyi’s stale review July 3, 2017 08:23

The design doc already merged. Dismiss this change request to merge.

@typhoonzero typhoonzero merged commit 0ca4988 into PaddlePaddle:develop Jul 3, 2017
@typhoonzero typhoonzero deleted the cmake_go_vendor branch August 11, 2017 06:52
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.

4 participants