From 9b494ea3870e3b5ddeb684293a112fa9f614d457 Mon Sep 17 00:00:00 2001 From: Laurent Modolo <laurent@modolo.fr> Date: Thu, 3 Sep 2020 14:46:55 +0200 Subject: [PATCH] fix typos --- README.html | 86 ++++++++++++++++++++++---------------------- README.md | 100 ++++++++++++++++++++++++++-------------------------- 2 files changed, 93 insertions(+), 93 deletions(-) diff --git a/README.html b/README.html index c52a4cf..4fb53d0 100644 --- a/README.html +++ b/README.html @@ -114,7 +114,7 @@ <h2 id="installing-packages-with-pip">installing packages with <code>pip</code></h2> <p>And then you can install any packages you want on <a href="https://pypi.org/">https://pypi.org/</a></p> <div class="sourceCode" id="cb4"><pre class="sourceCode bash"><code class="sourceCode bash"><span id="cb4-1"><a href="#cb4-1" aria-hidden="true"></a><span class="fu">sudo</span> pip3 install setuptools==50.0.2 <span class="co"># system wide install</span></span> -<span id="cb4-2"><a href="#cb4-2" aria-hidden="true"></a><span class="fu">sudo</span> pip3 install setuptools==50.0.2 --user <span class="co"># user install</span></span> +<span id="cb4-2"><a href="#cb4-2" aria-hidden="true"></a><span class="ex">pip3</span> install setuptools==50.0.2 --user # user install</span> <span id="cb4-3"><a href="#cb4-3" aria-hidden="true"></a><span class="ex">pip3</span> install twine wheel --user</span></code></pre></div> <p><code>pip</code> is just another python module</p> <div class="sourceCode" id="cb5"><pre class="sourceCode bash"><code class="sourceCode bash"><span id="cb5-1"><a href="#cb5-1" aria-hidden="true"></a><span class="ex">python3</span> -m pip install --user --upgrade pip</span></code></pre></div> @@ -143,7 +143,7 @@ <div class="sourceCode" id="cb8"><pre class="sourceCode python"><code class="sourceCode python"><span id="cb8-1"><a href="#cb8-1" aria-hidden="true"></a><span class="im">import</span> setuptools</span> <span id="cb8-2"><a href="#cb8-2" aria-hidden="true"></a></span> <span id="cb8-3"><a href="#cb8-3" aria-hidden="true"></a><span class="cf">with</span> <span class="bu">open</span>(<span class="st">"../README.md"</span>, <span class="st">"r"</span>) <span class="im">as</span> fh:</span> -<span id="cb8-4"><a href="#cb8-4" aria-hidden="true"></a>long_description <span class="op">=</span> fh.read()</span> +<span id="cb8-4"><a href="#cb8-4" aria-hidden="true"></a> long_description <span class="op">=</span> fh.read()</span> <span id="cb8-5"><a href="#cb8-5" aria-hidden="true"></a></span> <span id="cb8-6"><a href="#cb8-6" aria-hidden="true"></a>setuptools.setup(</span> <span id="cb8-7"><a href="#cb8-7" aria-hidden="true"></a> name<span class="op">=</span><span class="st">"example-pkg-YOUR-USERNAME-HERE"</span>, <span class="co"># Replace with your own username</span></span> @@ -180,7 +180,7 @@ <p>It will create files in the <code>dist/</code> directory</p> <pre><code>dist/ example_pkg_YOUR_USERNAME_HERE-0.0.1-py3-none-any.whl -example_pkg_YOUR_USERNAME_HERE-0.0.1.tar.gz</code></pre> + example_pkg_YOUR_USERNAME_HERE-0.0.1.tar.gz</code></pre> <p>The <code>tar.gz</code> file is a Source Archive whereas the <code>.whl</code> file is a Built Distribution. Newer pip versions preferentially install built distributions, but will fall back to source archives if needed. <strong>You should always upload a source archive and provide built archives for the platforms your project is compatible with.</strong></p> <p>What can you do with those two files ?</p> <h3 id="install-them">Install them:</h3> @@ -252,7 +252,7 @@ example_pkg_YOUR_USERNAME_HERE-0.0.1.tar.gz</code></pre> <span id="cb19-4"><a href="#cb19-4" aria-hidden="true"></a> ...</span> <span id="cb19-5"><a href="#cb19-5" aria-hidden="true"></a>)</span></code></pre></div> <h2 id="pybind11-and-other-unnecessary-complications">pybind11 and other unnecessary complications</h2> -<p>Sometime, you code is slow and instead of blaming yourself for your poor algorithm, you can blame python. <a href="https://github.com/pybind/pybind11">pybind1</a> allows you to do just that.</p> +<p>Sometime, you code is slow and instead of blaming yourself for your poor algorithm, you can blame python. <a href="https://github.com/pybind/pybind11">pybind11</a> allows you to do just that.</p> <blockquote> <p><strong>pybind11</strong> is a lightweight header-only library that exposes C++ types in Python and vice versa, mainly to create Python bindings of existing C++ code. Its goals and syntax are similar to the excellent <a href="http://www.boost.org/doc/libs/1_58_0/libs/python/doc/">Boost.Python</a> library by David Abrahams: to minimize boilerplate code in traditional extension modules by inferring type information using compile-time introspection.</p> </blockquote> @@ -279,55 +279,55 @@ example_pkg_YOUR_USERNAME_HERE-0.0.1.tar.gz</code></pre> <span id="cb20-10"><a href="#cb20-10" aria-hidden="true"></a></span> <span id="cb20-11"><a href="#cb20-11" aria-hidden="true"></a></span> <span id="cb20-12"><a href="#cb20-12" aria-hidden="true"></a><span class="kw">class</span> CMakeExtension(Extension):</span> -<span id="cb20-13"><a href="#cb20-13" aria-hidden="true"></a><span class="kw">def</span> <span class="fu">__init__</span>(<span class="va">self</span>, name, sourcedir<span class="op">=</span><span class="st">''</span>):</span> -<span id="cb20-14"><a href="#cb20-14" aria-hidden="true"></a> Extension.<span class="fu">__init__</span>(<span class="va">self</span>, name, sources<span class="op">=</span>[])</span> -<span id="cb20-15"><a href="#cb20-15" aria-hidden="true"></a><span class="va">self</span>.sourcedir <span class="op">=</span> os.path.abspath(sourcedir)</span> +<span id="cb20-13"><a href="#cb20-13" aria-hidden="true"></a> <span class="kw">def</span> <span class="fu">__init__</span>(<span class="va">self</span>, name, sourcedir<span class="op">=</span><span class="st">''</span>):</span> +<span id="cb20-14"><a href="#cb20-14" aria-hidden="true"></a> Extension.<span class="fu">__init__</span>(<span class="va">self</span>, name, sources<span class="op">=</span>[])</span> +<span id="cb20-15"><a href="#cb20-15" aria-hidden="true"></a> <span class="va">self</span>.sourcedir <span class="op">=</span> os.path.abspath(sourcedir)</span> <span id="cb20-16"><a href="#cb20-16" aria-hidden="true"></a></span> <span id="cb20-17"><a href="#cb20-17" aria-hidden="true"></a></span> <span id="cb20-18"><a href="#cb20-18" aria-hidden="true"></a><span class="kw">class</span> CMakeBuild(build_ext):</span> -<span id="cb20-19"><a href="#cb20-19" aria-hidden="true"></a><span class="kw">def</span> run(<span class="va">self</span>):</span> -<span id="cb20-20"><a href="#cb20-20" aria-hidden="true"></a><span class="cf">try</span>:</span> -<span id="cb20-21"><a href="#cb20-21" aria-hidden="true"></a> out <span class="op">=</span> subprocess.check_output([<span class="st">'cmake'</span>, <span class="st">'--version'</span>])</span> -<span id="cb20-22"><a href="#cb20-22" aria-hidden="true"></a><span class="cf">except</span> <span class="pp">OSError</span>:</span> -<span id="cb20-23"><a href="#cb20-23" aria-hidden="true"></a><span class="cf">raise</span> <span class="pp">RuntimeError</span>(<span class="st">"CMake must be installed to build the following extensions: "</span> <span class="op">+</span></span> -<span id="cb20-24"><a href="#cb20-24" aria-hidden="true"></a> <span class="st">", "</span>.join(e.name <span class="cf">for</span> e <span class="kw">in</span> <span class="va">self</span>.extensions))</span> +<span id="cb20-19"><a href="#cb20-19" aria-hidden="true"></a> <span class="kw">def</span> run(<span class="va">self</span>):</span> +<span id="cb20-20"><a href="#cb20-20" aria-hidden="true"></a> <span class="cf">try</span>:</span> +<span id="cb20-21"><a href="#cb20-21" aria-hidden="true"></a> out <span class="op">=</span> subprocess.check_output([<span class="st">'cmake'</span>, <span class="st">'--version'</span>])</span> +<span id="cb20-22"><a href="#cb20-22" aria-hidden="true"></a> <span class="cf">except</span> <span class="pp">OSError</span>:</span> +<span id="cb20-23"><a href="#cb20-23" aria-hidden="true"></a> <span class="cf">raise</span> <span class="pp">RuntimeError</span>(<span class="st">"CMake must be installed to build the following extensions: "</span> <span class="op">+</span></span> +<span id="cb20-24"><a href="#cb20-24" aria-hidden="true"></a> <span class="st">", "</span>.join(e.name <span class="cf">for</span> e <span class="kw">in</span> <span class="va">self</span>.extensions))</span> <span id="cb20-25"><a href="#cb20-25" aria-hidden="true"></a></span> -<span id="cb20-26"><a href="#cb20-26" aria-hidden="true"></a> <span class="cf">if</span> platform.system() <span class="op">==</span> <span class="st">"Windows"</span>:</span> -<span id="cb20-27"><a href="#cb20-27" aria-hidden="true"></a>cmake_version <span class="op">=</span> LooseVersion(re.search(<span class="vs">r'version\s*([\d.]+)'</span>, out.decode()).group(<span class="dv">1</span>))</span> -<span id="cb20-28"><a href="#cb20-28" aria-hidden="true"></a> <span class="cf">if</span> cmake_version <span class="op"><</span> <span class="st">'3.1.0'</span>:</span> -<span id="cb20-29"><a href="#cb20-29" aria-hidden="true"></a><span class="cf">raise</span> <span class="pp">RuntimeError</span>(<span class="st">"CMake >= 3.1.0 is required on Windows"</span>)</span> +<span id="cb20-26"><a href="#cb20-26" aria-hidden="true"></a> <span class="cf">if</span> platform.system() <span class="op">==</span> <span class="st">"Windows"</span>:</span> +<span id="cb20-27"><a href="#cb20-27" aria-hidden="true"></a> cmake_version <span class="op">=</span> LooseVersion(re.search(<span class="vs">r'version\s*([\d.]+)'</span>, out.decode()).group(<span class="dv">1</span>))</span> +<span id="cb20-28"><a href="#cb20-28" aria-hidden="true"></a> <span class="cf">if</span> cmake_version <span class="op"><</span> <span class="st">'3.1.0'</span>:</span> +<span id="cb20-29"><a href="#cb20-29" aria-hidden="true"></a> <span class="cf">raise</span> <span class="pp">RuntimeError</span>(<span class="st">"CMake >= 3.1.0 is required on Windows"</span>)</span> <span id="cb20-30"><a href="#cb20-30" aria-hidden="true"></a></span> -<span id="cb20-31"><a href="#cb20-31" aria-hidden="true"></a> <span class="cf">for</span> ext <span class="kw">in</span> <span class="va">self</span>.extensions:</span> -<span id="cb20-32"><a href="#cb20-32" aria-hidden="true"></a><span class="va">self</span>.build_extension(ext)</span> +<span id="cb20-31"><a href="#cb20-31" aria-hidden="true"></a> <span class="cf">for</span> ext <span class="kw">in</span> <span class="va">self</span>.extensions:</span> +<span id="cb20-32"><a href="#cb20-32" aria-hidden="true"></a> <span class="va">self</span>.build_extension(ext)</span> <span id="cb20-33"><a href="#cb20-33" aria-hidden="true"></a></span> -<span id="cb20-34"><a href="#cb20-34" aria-hidden="true"></a> <span class="kw">def</span> build_extension(<span class="va">self</span>, ext):</span> -<span id="cb20-35"><a href="#cb20-35" aria-hidden="true"></a>extdir <span class="op">=</span> os.path.abspath(os.path.dirname(<span class="va">self</span>.get_ext_fullpath(ext.name)))</span> -<span id="cb20-36"><a href="#cb20-36" aria-hidden="true"></a> <span class="co"># required for auto-detection of auxiliary "native" libs</span></span> -<span id="cb20-37"><a href="#cb20-37" aria-hidden="true"></a><span class="cf">if</span> <span class="kw">not</span> extdir.endswith(os.path.sep):</span> -<span id="cb20-38"><a href="#cb20-38" aria-hidden="true"></a>extdir <span class="op">+=</span> os.path.sep</span> +<span id="cb20-34"><a href="#cb20-34" aria-hidden="true"></a> <span class="kw">def</span> build_extension(<span class="va">self</span>, ext):</span> +<span id="cb20-35"><a href="#cb20-35" aria-hidden="true"></a> extdir <span class="op">=</span> os.path.abspath(os.path.dirname(<span class="va">self</span>.get_ext_fullpath(ext.name)))</span> +<span id="cb20-36"><a href="#cb20-36" aria-hidden="true"></a> <span class="co"># required for auto-detection of auxiliary "native" libs</span></span> +<span id="cb20-37"><a href="#cb20-37" aria-hidden="true"></a> <span class="cf">if</span> <span class="kw">not</span> extdir.endswith(os.path.sep):</span> +<span id="cb20-38"><a href="#cb20-38" aria-hidden="true"></a> extdir <span class="op">+=</span> os.path.sep</span> <span id="cb20-39"><a href="#cb20-39" aria-hidden="true"></a></span> -<span id="cb20-40"><a href="#cb20-40" aria-hidden="true"></a> cmake_args <span class="op">=</span> [<span class="st">'-DCMAKE_LIBRARY_OUTPUT_DIRECTORY='</span> <span class="op">+</span> extdir,</span> -<span id="cb20-41"><a href="#cb20-41" aria-hidden="true"></a> <span class="st">'-DPYTHON_EXECUTABLE='</span> <span class="op">+</span> sys.executable]</span> +<span id="cb20-40"><a href="#cb20-40" aria-hidden="true"></a> cmake_args <span class="op">=</span> [<span class="st">'-DCMAKE_LIBRARY_OUTPUT_DIRECTORY='</span> <span class="op">+</span> extdir,</span> +<span id="cb20-41"><a href="#cb20-41" aria-hidden="true"></a> <span class="st">'-DPYTHON_EXECUTABLE='</span> <span class="op">+</span> sys.executable]</span> <span id="cb20-42"><a href="#cb20-42" aria-hidden="true"></a></span> -<span id="cb20-43"><a href="#cb20-43" aria-hidden="true"></a> cfg <span class="op">=</span> <span class="st">'Debug'</span> <span class="cf">if</span> <span class="va">self</span>.debug <span class="cf">else</span> <span class="st">'Release'</span></span> -<span id="cb20-44"><a href="#cb20-44" aria-hidden="true"></a> build_args <span class="op">=</span> [<span class="st">'--config'</span>, cfg]</span> +<span id="cb20-43"><a href="#cb20-43" aria-hidden="true"></a> cfg <span class="op">=</span> <span class="st">'Debug'</span> <span class="cf">if</span> <span class="va">self</span>.debug <span class="cf">else</span> <span class="st">'Release'</span></span> +<span id="cb20-44"><a href="#cb20-44" aria-hidden="true"></a> build_args <span class="op">=</span> [<span class="st">'--config'</span>, cfg]</span> <span id="cb20-45"><a href="#cb20-45" aria-hidden="true"></a></span> -<span id="cb20-46"><a href="#cb20-46" aria-hidden="true"></a> <span class="cf">if</span> platform.system() <span class="op">==</span> <span class="st">"Windows"</span>:</span> -<span id="cb20-47"><a href="#cb20-47" aria-hidden="true"></a>cmake_args <span class="op">+=</span> [<span class="st">'-DCMAKE_LIBRARY_OUTPUT_DIRECTORY_</span><span class="sc">{}</span><span class="st">=</span><span class="sc">{}</span><span class="st">'</span>.<span class="bu">format</span>(cfg.upper(), extdir)]</span> -<span id="cb20-48"><a href="#cb20-48" aria-hidden="true"></a><span class="cf">if</span> sys.maxsize <span class="op">></span> <span class="dv">2</span><span class="op">**</span><span class="dv">32</span>:</span> -<span id="cb20-49"><a href="#cb20-49" aria-hidden="true"></a>cmake_args <span class="op">+=</span> [<span class="st">'-A'</span>, <span class="st">'x64'</span>]</span> -<span id="cb20-50"><a href="#cb20-50" aria-hidden="true"></a>build_args <span class="op">+=</span> [<span class="st">'--'</span>, <span class="st">'/m'</span>]</span> -<span id="cb20-51"><a href="#cb20-51" aria-hidden="true"></a><span class="cf">else</span>:</span> -<span id="cb20-52"><a href="#cb20-52" aria-hidden="true"></a>cmake_args <span class="op">+=</span> [<span class="st">'-DCMAKE_BUILD_TYPE='</span> <span class="op">+</span> cfg]</span> -<span id="cb20-53"><a href="#cb20-53" aria-hidden="true"></a>build_args <span class="op">+=</span> [<span class="st">'--'</span>, <span class="st">'-j2'</span>]</span> +<span id="cb20-46"><a href="#cb20-46" aria-hidden="true"></a> <span class="cf">if</span> platform.system() <span class="op">==</span> <span class="st">"Windows"</span>:</span> +<span id="cb20-47"><a href="#cb20-47" aria-hidden="true"></a> cmake_args <span class="op">+=</span> [<span class="st">'-DCMAKE_LIBRARY_OUTPUT_DIRECTORY_</span><span class="sc">{}</span><span class="st">=</span><span class="sc">{}</span><span class="st">'</span>.<span class="bu">format</span>(cfg.upper(), extdir)]</span> +<span id="cb20-48"><a href="#cb20-48" aria-hidden="true"></a> <span class="cf">if</span> sys.maxsize <span class="op">></span> <span class="dv">2</span><span class="op">**</span><span class="dv">32</span>:</span> +<span id="cb20-49"><a href="#cb20-49" aria-hidden="true"></a> cmake_args <span class="op">+=</span> [<span class="st">'-A'</span>, <span class="st">'x64'</span>]</span> +<span id="cb20-50"><a href="#cb20-50" aria-hidden="true"></a> build_args <span class="op">+=</span> [<span class="st">'--'</span>, <span class="st">'/m'</span>]</span> +<span id="cb20-51"><a href="#cb20-51" aria-hidden="true"></a> <span class="cf">else</span>:</span> +<span id="cb20-52"><a href="#cb20-52" aria-hidden="true"></a> cmake_args <span class="op">+=</span> [<span class="st">'-DCMAKE_BUILD_TYPE='</span> <span class="op">+</span> cfg]</span> +<span id="cb20-53"><a href="#cb20-53" aria-hidden="true"></a> build_args <span class="op">+=</span> [<span class="st">'--'</span>, <span class="st">'-j2'</span>]</span> <span id="cb20-54"><a href="#cb20-54" aria-hidden="true"></a></span> -<span id="cb20-55"><a href="#cb20-55" aria-hidden="true"></a> env <span class="op">=</span> os.environ.copy()</span> -<span id="cb20-56"><a href="#cb20-56" aria-hidden="true"></a> env[<span class="st">'CXXFLAGS'</span>] <span class="op">=</span> <span class="st">'</span><span class="sc">{}</span><span class="st"> -DVERSION_INFO=</span><span class="ch">\\</span><span class="st">"</span><span class="sc">{}</span><span class="ch">\\</span><span class="st">"'</span>.<span class="bu">format</span>(env.get(<span class="st">'CXXFLAGS'</span>, <span class="st">''</span>),</span> -<span id="cb20-57"><a href="#cb20-57" aria-hidden="true"></a> <span class="va">self</span>.distribution.get_version())</span> -<span id="cb20-58"><a href="#cb20-58" aria-hidden="true"></a> <span class="cf">if</span> <span class="kw">not</span> os.path.exists(<span class="va">self</span>.build_temp):</span> -<span id="cb20-59"><a href="#cb20-59" aria-hidden="true"></a>os.makedirs(<span class="va">self</span>.build_temp)</span> -<span id="cb20-60"><a href="#cb20-60" aria-hidden="true"></a> subprocess.check_call([<span class="st">'cmake'</span>, ext.sourcedir] <span class="op">+</span> cmake_args, cwd<span class="op">=</span><span class="va">self</span>.build_temp, env<span class="op">=</span>env)</span> -<span id="cb20-61"><a href="#cb20-61" aria-hidden="true"></a> subprocess.check_call([<span class="st">'cmake'</span>, <span class="st">'--build'</span>, <span class="st">'.'</span>] <span class="op">+</span> build_args, cwd<span class="op">=</span><span class="va">self</span>.build_temp)</span> +<span id="cb20-55"><a href="#cb20-55" aria-hidden="true"></a> env <span class="op">=</span> os.environ.copy()</span> +<span id="cb20-56"><a href="#cb20-56" aria-hidden="true"></a> env[<span class="st">'CXXFLAGS'</span>] <span class="op">=</span> <span class="st">'</span><span class="sc">{}</span><span class="st"> -DVERSION_INFO=</span><span class="ch">\\</span><span class="st">"</span><span class="sc">{}</span><span class="ch">\\</span><span class="st">"'</span>.<span class="bu">format</span>(env.get(<span class="st">'CXXFLAGS'</span>, <span class="st">''</span>),</span> +<span id="cb20-57"><a href="#cb20-57" aria-hidden="true"></a> <span class="va">self</span>.distribution.get_version())</span> +<span id="cb20-58"><a href="#cb20-58" aria-hidden="true"></a> <span class="cf">if</span> <span class="kw">not</span> os.path.exists(<span class="va">self</span>.build_temp):</span> +<span id="cb20-59"><a href="#cb20-59" aria-hidden="true"></a> os.makedirs(<span class="va">self</span>.build_temp)</span> +<span id="cb20-60"><a href="#cb20-60" aria-hidden="true"></a> subprocess.check_call([<span class="st">'cmake'</span>, ext.sourcedir] <span class="op">+</span> cmake_args, cwd<span class="op">=</span><span class="va">self</span>.build_temp, env<span class="op">=</span>env)</span> +<span id="cb20-61"><a href="#cb20-61" aria-hidden="true"></a> subprocess.check_call([<span class="st">'cmake'</span>, <span class="st">'--build'</span>, <span class="st">'.'</span>] <span class="op">+</span> build_args, cwd<span class="op">=</span><span class="va">self</span>.build_temp)</span> <span id="cb20-62"><a href="#cb20-62" aria-hidden="true"></a></span> <span id="cb20-63"><a href="#cb20-63" aria-hidden="true"></a>setup(</span> <span id="cb20-64"><a href="#cb20-64" aria-hidden="true"></a> name<span class="op">=</span><span class="st">'cmake_example'</span>,</span> diff --git a/README.md b/README.md index 5a3c852..d27df7e 100644 --- a/README.md +++ b/README.md @@ -50,7 +50,7 @@ And then you can install any packages you want on [https://pypi.org/](https://py ```bash sudo pip3 install setuptools==50.0.2 # system wide install -sudo pip3 install setuptools==50.0.2 --user # user install +pip3 install setuptools==50.0.2 --user # user install pip3 install twine wheel --user ``` @@ -100,7 +100,7 @@ Here is a basic `setup.py` file: import setuptools with open("../README.md", "r") as fh: -long_description = fh.read() + long_description = fh.read() setuptools.setup( name="example-pkg-YOUR-USERNAME-HERE", # Replace with your own username @@ -145,7 +145,7 @@ It will create files in the `dist/` directory ``` dist/ example_pkg_YOUR_USERNAME_HERE-0.0.1-py3-none-any.whl -example_pkg_YOUR_USERNAME_HERE-0.0.1.tar.gz + example_pkg_YOUR_USERNAME_HERE-0.0.1.tar.gz ``` The `tar.gz` file is a Source Archive whereas the `.whl` file is a Built Distribution. Newer pip versions preferentially install built distributions, but will fall back to source archives if needed. @@ -273,7 +273,7 @@ setup( ## pybind11 and other unnecessary complications -Sometime, you code is slow and instead of blaming yourself for your poor algorithm, you can blame python. [pybind1](https://github.com/pybind/pybind11) allows you to do just that. +Sometime, you code is slow and instead of blaming yourself for your poor algorithm, you can blame python. [pybind11](https://github.com/pybind/pybind11) allows you to do just that. > **pybind11** is a lightweight header-only library that exposes C++ types in Python and vice versa, mainly to create Python bindings of existing C++ code. Its goals and syntax are similar to the excellent [Boost.Python](http://www.boost.org/doc/libs/1_58_0/libs/python/doc/) library by David Abrahams: to minimize boilerplate code in traditional extension modules by inferring type information using compile-time introspection. @@ -306,55 +306,55 @@ from distutils.version import LooseVersion class CMakeExtension(Extension): -def __init__(self, name, sourcedir=''): - Extension.__init__(self, name, sources=[]) -self.sourcedir = os.path.abspath(sourcedir) + def __init__(self, name, sourcedir=''): + Extension.__init__(self, name, sources=[]) + self.sourcedir = os.path.abspath(sourcedir) class CMakeBuild(build_ext): -def run(self): -try: - out = subprocess.check_output(['cmake', '--version']) -except OSError: -raise RuntimeError("CMake must be installed to build the following extensions: " + - ", ".join(e.name for e in self.extensions)) - - if platform.system() == "Windows": -cmake_version = LooseVersion(re.search(r'version\s*([\d.]+)', out.decode()).group(1)) - if cmake_version < '3.1.0': -raise RuntimeError("CMake >= 3.1.0 is required on Windows") - - for ext in self.extensions: -self.build_extension(ext) - - def build_extension(self, ext): -extdir = os.path.abspath(os.path.dirname(self.get_ext_fullpath(ext.name))) - # required for auto-detection of auxiliary "native" libs -if not extdir.endswith(os.path.sep): -extdir += os.path.sep - - cmake_args = ['-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=' + extdir, - '-DPYTHON_EXECUTABLE=' + sys.executable] - - cfg = 'Debug' if self.debug else 'Release' - build_args = ['--config', cfg] - - if platform.system() == "Windows": -cmake_args += ['-DCMAKE_LIBRARY_OUTPUT_DIRECTORY_{}={}'.format(cfg.upper(), extdir)] -if sys.maxsize > 2**32: -cmake_args += ['-A', 'x64'] -build_args += ['--', '/m'] -else: -cmake_args += ['-DCMAKE_BUILD_TYPE=' + cfg] -build_args += ['--', '-j2'] - - env = os.environ.copy() - env['CXXFLAGS'] = '{} -DVERSION_INFO=\\"{}\\"'.format(env.get('CXXFLAGS', ''), - self.distribution.get_version()) - if not os.path.exists(self.build_temp): -os.makedirs(self.build_temp) - subprocess.check_call(['cmake', ext.sourcedir] + cmake_args, cwd=self.build_temp, env=env) - subprocess.check_call(['cmake', '--build', '.'] + build_args, cwd=self.build_temp) + def run(self): + try: + out = subprocess.check_output(['cmake', '--version']) + except OSError: + raise RuntimeError("CMake must be installed to build the following extensions: " + + ", ".join(e.name for e in self.extensions)) + + if platform.system() == "Windows": + cmake_version = LooseVersion(re.search(r'version\s*([\d.]+)', out.decode()).group(1)) + if cmake_version < '3.1.0': + raise RuntimeError("CMake >= 3.1.0 is required on Windows") + + for ext in self.extensions: + self.build_extension(ext) + + def build_extension(self, ext): + extdir = os.path.abspath(os.path.dirname(self.get_ext_fullpath(ext.name))) + # required for auto-detection of auxiliary "native" libs + if not extdir.endswith(os.path.sep): + extdir += os.path.sep + + cmake_args = ['-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=' + extdir, + '-DPYTHON_EXECUTABLE=' + sys.executable] + + cfg = 'Debug' if self.debug else 'Release' + build_args = ['--config', cfg] + + if platform.system() == "Windows": + cmake_args += ['-DCMAKE_LIBRARY_OUTPUT_DIRECTORY_{}={}'.format(cfg.upper(), extdir)] + if sys.maxsize > 2**32: + cmake_args += ['-A', 'x64'] + build_args += ['--', '/m'] + else: + cmake_args += ['-DCMAKE_BUILD_TYPE=' + cfg] + build_args += ['--', '-j2'] + + env = os.environ.copy() + env['CXXFLAGS'] = '{} -DVERSION_INFO=\\"{}\\"'.format(env.get('CXXFLAGS', ''), + self.distribution.get_version()) + if not os.path.exists(self.build_temp): + os.makedirs(self.build_temp) + subprocess.check_call(['cmake', ext.sourcedir] + cmake_args, cwd=self.build_temp, env=env) + subprocess.check_call(['cmake', '--build', '.'] + build_args, cwd=self.build_temp) setup( name='cmake_example', -- GitLab