-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
docs: split some policies by the implicated method #14211
docs: split some policies by the implicated method #14211
Conversation
# Build and Package | ||
|
||
This document gathers all the relevant information regarding the general lines to follow while writing either the `build()` or the `package()` methods. | ||
Both of these methods often take advantage of build helpers build binaries and install to the `package_folder`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not have build.md
+ package.md
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's not enough docs written to justify it yet 😄
|
||
* `build()` method should focus on build only, not installation. During the build, nothing should be written in `package` folder. Installation step should only occur in `package()` method. | ||
|
||
* The build itself should only rely on local files. Nothing should be downloaded from internet during this step. If external files are required, they should come from `requirements` or `build_requirements`, in addition to source files downloaded in `source()` or coming from recipe itself. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if think if sources are different per platform, we do downloads in build
method (e.g. android-ndk).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thats not the case - theres plenty of those and they work in source()
--- maybe I misunderstood you?
Why would it not work?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thats downloading pre compiled tooling which is why it's in the build method -- not the arch specific nature in this case
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fair, but we have more cases like that (not just for pre-built tools):
conan-center-index/recipes/cspice/all/conanfile.py
Lines 92 to 111 in e907fe2
def _get_sources(self): | |
with chdir(self, self._parent_source_folder): | |
host_os = self._get_os_or_subsystem() | |
compiler = str(self.settings.compiler) | |
arch = str(self.settings.arch) | |
data = self.conan_data["sources"][self.version][host_os][compiler][arch] | |
url = data["url"] | |
if url.endswith(".tar.Z"): # Python doesn't have any module to uncompress .Z files | |
tarball = os.path.basename(url) | |
download(self, url, tarball, sha256=data["sha256"]) | |
self.run(f"zcat {tarball} | tar -xf -") | |
os.remove(tarball) | |
else: | |
get(self, **data) | |
rmdir(self, self.source_folder) | |
rename(self, "cspice", os.path.basename(self.source_folder)) | |
def build(self): | |
self._get_sources() | |
apply_conandata_patches(self) |
|
||
* `build()` method should focus on build only, not installation. During the build, nothing should be written in `package` folder. Installation step should only occur in `package()` method. | ||
|
||
* The build itself should only rely on local files. Nothing should be downloaded from internet during this step. If external files are required, they should come from `requirements` or `build_requirements`, in addition to source files downloaded in `source()` or coming from recipe itself. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* The build itself should only rely on local files. Nothing should be downloaded from internet during this step. If external files are required, they should come from `requirements` or `build_requirements`, in addition to source files downloaded in `source()` or coming from recipe itself. | |
* The build itself should only rely on local files. Nothing should be downloaded from internet during this step. If external files are required, they should come from `requirements` or `tool_requirements`, in addition to source files downloaded in `source()` or coming from recipe itself. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's consufising the method is called build_requirements
which is what sentence is referring too I think
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suppose we need to avoid confusion and use consistent naming/terminology across the docs. either tool_requires everywhere, or build_requires everywhere.
|
||
* It is forbidden to run other conan client commands during build. In other words, if upstream build files call conan under the hood (through `cmake-conan` for example or any other logic), this logic must be removed. | ||
|
||
* Settings from profile should be honored (`build_type`, `compiler.libcxx`, `compiler.cppstd`, `compiler.runtime` etc). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* Settings from profile should be honored (`build_type`, `compiler.libcxx`, `compiler.cppstd`, `compiler.runtime` etc). | |
* Settings from profile should be honored (`build_type`, 'os', 'arch', `compiler.libcxx`, `compiler.cppstd`, `compiler.runtime` etc). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was intended to call out problematic settings not all of them 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure which are more problematic 🤔
|
||
* Settings from profile should be honored (`build_type`, `compiler.libcxx`, `compiler.cppstd`, `compiler.runtime` etc). | ||
|
||
* These env vars from profile should be honored and properly propagated to underlying build system during the build: `CC`, `CXX`, `CFLAGS`, `CXXFLAGS`, `LDFLAGS`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it deserves an example. for newcomers, it's kinda unclear. can you illustrate how to honor these variables, e.g. for CMake?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes the docs are bad - I am not trying to fix them in this PR 😄 I got many more too come!
|
||
* It is forbidden to run other conan client commands during build. In other words, if upstream build files call conan under the hood (through `cmake-conan` for example or any other logic), this logic must be removed. | ||
|
||
* Settings from profile should be honored (`build_type`, `compiler.libcxx`, `compiler.cppstd`, `compiler.runtime` etc). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same, it deserves an example. for newcomers, it's kinda unclear, how to to it exactly. it would be nice if you illustrate with a small code block, e.g. for CMake.
|
||
* pkg-config files must be removed (they will be generated for consumers by `pkg_config` or `PkgConfigDeps` generators). | ||
|
||
* On *nix systems, executables and shared libraries should have empty `RPATH`/`RUNPATH`/`LC_RPATH`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how do I achieve that? how do I ensure that? examples are needed.
|
||
* On *nix systems, executables and shared libraries should have empty `RPATH`/`RUNPATH`/`LC_RPATH`. | ||
|
||
* On macOS, install name in `LC_ID_DYLIB` section of shared libs must be `@rpath/<libfilename>`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how do I achieve that? how do I ensure that? examples are needed.
|
||
* On macOS, install name in `LC_ID_DYLIB` section of shared libs must be `@rpath/<libfilename>`. | ||
|
||
* Installed files must not contain absolute paths specific to build machine. Relative paths to other packages is also forbidden since relative paths of dependencies during build may not be the same for consumers. Hardcoded relative paths pointing to a location in the package itself are allowed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how do I check for that? how do I prevent/fix that? examples are needed.
|
||
* pkg-config files must be removed (they will be generated for consumers by `pkg_config` or `PkgConfigDeps` generators). | ||
|
||
* On *nix systems, executables and shared libraries should have empty `RPATH`/`RUNPATH`/`LC_RPATH`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we also need to put some links to the relevant documentation for:
RPATH
RUNPATH
LC_RPATH
LC_ID_DYLIB
@rpath
maybe with some brief examples on how to inspect them (commands like objdump
, readelf
, otool
, etc.).
these are very technical and low-level things, we cannot expect all the readers to know about them.
|
||
* Except CMake and a working build toolchain (compiler, linker, archiver etc), the recipe should not assume that any other build tool is installed on user build machine (like Meson, autotools or pkg-config). On Windows, recipe should not assume that a shell is available (like MSYS2). Therefore, if the build requires additional tools, they should be added to `build_requirements()`. | ||
|
||
* It is forbidden to run other conan client commands during build. In other words, if upstream build files call conan under the hood (through `cmake-conan` for example or any other logic), this logic must be removed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how do I check for that?
symbols, it may be acceptable. | ||
* Only other ConanCenter recipes are allowed in `requires`/`requirements()` and `build_requires`/`build_requirements()`. | ||
* If a requirement is conditional, this condition must not depend on build context. Build requirements don't have this constraint. | ||
* Forcing options of dependencies inside a recipe should be avoided, except if it is mandatory for the library - in which case it must |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
example would be nice
@@ -0,0 +1,33 @@ | |||
# Sources and Patches | |||
|
|||
This documents contains everything related to the `source()`. This includes picking sources, where they should come from and goes into when and how to modify sources. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This documents contains everything related to the `source()`. This includes picking sources, where they should come from and goes into when and how to modify sources. | |
This documents contains everything related to the `source()`. This includes picking sources, where they should come from. |
in another section, we already stated sources are immutable
* Library sources should come from an official origin like the library source code repository or the official | ||
release/download webpage. | ||
|
||
* If an official source archive is available, it should be preferred over an auto-generated archive. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe we should explain it a little bit more, on how to distinguish these two.
e.g., in GitHub projects, prefer archives from the releases
tab, rather code
- download zip
|
||
**Source immutability:** Downloaded source code stored under `source` folder should not be modified. Any patch should be applied to the copy of this source code when a build is executed (basically in `build()` method). | ||
|
||
**Building from sources:** Recipes should always build packages from library sources. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we have some known exceptions to this rule (MSYS2, Android NDK, etc.)
|
||
* Library sources that are not publicly available will not be allowed in this repository even if the license allows their redistribution. | ||
|
||
* If library sources cannot be downloaded from their official origin or cannot be consumed directly due to their |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we had some special cases for that, e.g. for gSOAP
. maybe explain it here.
I believe that:
|
@SSE4 I really appreciate the detailed and quality review but I have no intention of fixing the docs in this PR - my goal is to simply just move them. Once the structure is improved and things are grouped we can worry about fixing them. Right now it's very difficult to reason about them because the examples you are suggesting already exist just in a place that does not make sense -- please see #13673 I just want to move them right now so I will not be applying most of ur suggestions as of now. You suggestion are really good and I will note them for my future self 👍 |
@SpaceIm I love the way you are thinking! I've gathered a lot of feedback and most contributors do not like the current system (which is have a super long list of rules which are numbered -- aka the hooks). In the long run we need to have self documenting linter rules that annotate the code and suggest solutions. No more have the same information on three different pages saying different things. I have an open ticket to start a list of linter "best practices" we should add - think conventions we already have (like how we write the source method) - for now you can put your ideas in #11393 and we'll consider them 😄 My goal is delete some of the docs (in like 6-8 months time frame) and replace them with linters - a prime example is the "you should order methods in the way they are called" which is broken almost everywhere. I absolutely agree we need more linters - and they should explain themselves with nice annotations. |
df6451a
to
b4db96a
Compare
Sorry about the force push - the merge conflicts did not like me |
if examples are already there, why not put links to them? otherwise, it's hard to discover corresponding examples for newcomers. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
docs need more examples
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall, I think it's a good job! 👏 For newbies, it could not be enough to understand everything, but it's a good start to keep improving this current documentation. Looking forward to the following PRs!
EDITED: my comments are only suggestions about punctuation, clarity, etc.
Co-authored-by: Francisco Ramírez <[email protected]> Co-authored-by: SSE4 <[email protected]>
I am not fixing the docs in this PR. I have many other PRs waiting -- I just would like to go through them in smaller bit size pieces so everyone has time to adjust. Every single change here means I spent 30-45 min fixing my 3 other branches and it's not fun having merge conflicts. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Docs!
This is yet another step to #13673 - for this one I just want to create new files and removed only "packaging_policy".
The goal is to breakout methods into pairs to it's easy know where to look for related information.
Feedback welcomed - my goal is to close in on this branch https://github.com/prince-chrismc/conan-center-index/tree/docs/seperate-by-method which is my current plan