This project has moved and is read-only. For the latest updates, please go here.

.pyproj and .py files in separate directories?

Mar 2, 2012 at 7:53 AM

I have a C++ library with a Python wrapper. I would like to organize the source code and the project files in separate directories. Keeping source code and project files in the same directory works fine if you are targeting a single platform, but gets messy if you are targeting multiple platforms. I would like to have a directory structure with one directory for the source code (with different subdirectories for different projects) and one directory for the project files (with different subdirectories for different compilers (MSVS 2008, MSVS 2010, X-Code, Eclipse, ...))

This works well for the C++ code. But I don't see how to do that with the Python code. It seems the .pyproj file must be in the same directory as the .py files. Is that right?


Mar 2, 2012 at 5:42 PM

In 1.1 we've added "linked files" - these are files that can live outside of the directory where the .pyproj lives and can be specified using a relative file path.  You can add them via the UI using Add New Item in Project Explorer and then selecting the chevron on the Add button and choose Add as Link.  But if you're setting up a large project by hand it might be easier to edit the project by hand and specify the relative paths (or write a script to generate it).

By default a linked file will show up at the top level of the project, but you can also specify where it should show up in solution explorer to preserve a hierarchy there.  That's done using this format in the pyproj file:

     <Compile Include="..\ParentDir\" >

And this will cause "" to show up under "Bar" in the project in solution explorer.

Mar 2, 2012 at 6:22 PM
Edited Mar 2, 2012 at 6:23 PM

That should solve my problem, but is a little messy.

It would be nice if you could specify a source root folder that by default is the same as the folder where the pyproj file lives.

Mar 2, 2012 at 10:28 PM

Could you open a feature request for this?  I don't think we'd treat it as super high pri, but you're right, it would be nice, and seems like something we could provide.

Mar 3, 2012 at 1:56 PM
Edited Mar 3, 2012 at 1:57 PM

Done: item #669.