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

Python packages #408

Closed
richburdon opened this issue May 20, 2015 · 3 comments
Closed

Python packages #408

richburdon opened this issue May 20, 2015 · 3 comments

Comments

@richburdon
Copy link

Is there a standard practice for building python protobuf packages? Since no ini.py is generated is necessary to do custom build kung-fu to create this or to move files from build/generated-sources (say) into the source tree?

@haberman
Copy link
Member

Could you clarify what you mean here? Are you talking about packages that use the protobuf-python package and want to generate code as part of the build?

I don't think we have any special support for that right now. What is ini.py?

@richburdon
Copy link
Author

OK, so my repo contains proto definitions and I want to generate a java lib and a python package distribution for use by other repos.

The way to do this in python is to create a setup.py file and then run python setup.py sdist.

The problem is the generated source files are not in the same directory as setup.py (they are in build/generated-sources/main) (in another thread I'm arguing they should be in build/generated-sources/main/python but that's a different issue).

So if I do something like this:
setup(
package_dir={'': './build/generated-sources/main'},

then the package has files called "build/generated-sources/main/foo.py" which means in the client code, you would need to do things like "import build.generated-sources.main.foo" which of course makes no sense -- and even this wouldn't work since modules need to have a init.py file in them (which isn't generated).

So, either way you look at it (I hope I'm wrong) you have to write a bunch of build cruft to get what should be trivial -- and is required by anyone doing packaging -- to work.

The workaround, which is what I assume everyone does is to manually copy the generated files into your source tree, but that just feels dead wrong.

Does it make sense?

@TeBoring
Copy link
Contributor

TeBoring commented Mar 7, 2017

Close this for cleanup. Feel free to reopen the issue if there is still problem.

@TeBoring TeBoring closed this as completed Mar 7, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants