diff --git a/.gitignore b/.gitignore deleted file mode 100644 index bf8dcb1..0000000 --- a/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -.DS_Store - -sphinx_presentation/build/ - - - diff --git a/LICENSE b/LICENSE deleted file mode 100644 index abe0eac..0000000 --- a/LICENSE +++ /dev/null @@ -1,552 +0,0 @@ - This repository contain the materials for a tutorial. - - The code is licences under the Apache licence, version 2.0. - - Text and other non-code written materials are licenced under the - Creative Commons Attribution-ShareAlike 4.0 International licence. - - Text of both licenses below: - - - Apache License - ============== - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "{}" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright {yyyy} {name of copyright owner} - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - - -CC BY-SA 4.0 -============ - -https://creativecommons.org/licenses/by-sa/4.0/ - -Creative Commons Attribution-ShareAlike 4.0 International Public License - -By exercising the Licensed Rights (defined below), You accept and agree -to be bound by the terms and conditions of this Creative Commons -Attribution-ShareAlike 4.0 International Public License ("Public -License"). To the extent this Public License may be interpreted as a -contract, You are granted the Licensed Rights in consideration of Your -acceptance of these terms and conditions, and the Licensor grants You -such rights in consideration of benefits the Licensor receives from -making the Licensed Material available under these terms and conditions. - -Section 1 – Definitions. ------------------------- - -a. Adapted Material means material subject to Copyright and Similar -Rights that is derived from or based upon the Licensed Material and in -which the Licensed Material is translated, altered, arranged, -transformed, or otherwise modified in a manner requiring permission -under the Copyright and Similar Rights held by the Licensor. For -purposes of this Public License, where the Licensed Material is a -musical work, performance, or sound recording, Adapted Material is -always produced where the Licensed Material is synched in timed\relation -with a moving image. - -b. Adapter's License means the license You apply to Your Copyright and -Similar Rights in Your contributions to Adapted Material in accordance -with the terms and conditions of this Public License. - -c. BY-SA Compatible License means a license listed at -creativecommons.org/compatiblelicenses, approved by Creative Commons as -essentially the equivalent of this Public License. - -d. Copyright and Similar Rights means copyright and/or similar rights -closely related to copyright including, without limitation, performance, -broadcast, sound recording, and Sui Generis Database Rights, without -regard to how the rights are labeled or categorized. For purposes of -this Public License, the rights specified in Section 2(b)(1)-(2) are not -Copyright and Similar Rights. - -e. Effective Technological Measures means those measures that, in the -absence of proper authority, may not be circumvented under laws -fulfilling obligations under Article 11 of the WIPO Copyright Treaty -adopted on December 20, 1996, and/or similar international agreements. - -f. Exceptions and Limitations means fair use, fair dealing, and/or any -other exception or limitation to Copyright and Similar Rights that -applies to Your use of the Licensed Material. - -g. License Elements means the license attributes listed in the name of a -Creative Commons Public License. The License Elements of this Public -License are Attribution and ShareAlike. - -h. Licensed Material means the artistic or literary work, database, or -other material to which the Licensor applied this Public License. - -i. Licensed Rights means the rights granted to You subject to the terms -and conditions of this Public License, which are limited to all -Copyright and Similar Rights that apply to Your use of the Licensed -Material and that the Licensor has authority to license. j. Licensor -means the individual(s) or entity(ies) granting rights under this Public -License. - -k. Share means to provide material to the public by any means or process -that requires permission under the Licensed Rights, such as -reproduction, public display, public performance, distribution, -dissemination, communication, or importation, and to make material -available to the public including in ways that members of the public may -access the material from a place and at a time individually chosen by -them. - -l. Sui Generis Database Rights means rights other than copyright -resulting from Directive 96/9/EC of the European Parliament and of the -Council of 11 March 1996 on the legal protection of databases, as -amended and/or succeeded, as well as other essentially equivalent rights -anywhere in the world. - -m. You means the individual or entity exercising the Licensed Rights -under this Public License. Your has a corresponding meaning. - -Section 2 – Scope. ------------------- - -a. License grant. - - 1. Subject to the terms and conditions of this Public License, the - Licensor hereby grants You a worldwide, royalty-free, non- - sublicensable, non-exclusive, irrevocable license to exercise the - Licensed Rights in the Licensed Material to: - - A. reproduce and Share the Licensed Material, in whole or in part; - and - - B. produce, reproduce, and Share Adapted Material. - - 2. Exceptionsvand Limitations. For the avoidance of doubt, where - Exceptions and Limitations apply to Your use, this Public License - does not apply, and You do not need to comply with its terms and - conditions. - - 3. Term. The term of this Public License is specified in Section 6(a). - - 4. Media and formats; technical modifications allowed. The Licensor - authorizes You to exercise the Licensed Rights in all media and - formats whether now known or hereafter created, and to make technical - modifications necessary to do so. The Licensor waives and/or agrees - not to assert any right or authority to forbid You from making - technical modifications necessary to exercise the Licensed Rights, - including technical modifications necessary to circumvent Effective - Technological Measures. For purposes of this Public License, simply - making modifications authorized by this Section 2(a)(4) never produces - Adapted Material. - - 5. Downstream recipients. - - A. Offer from the Licensor – Licensed Material. Every recipient of - the Licensed Material automatically receives an offer from the - Licensor to exercise the Licensed Rights under the terms and - conditions of this Public License. - - B. Additional offer from the Licensor – Adapted Material. Every - recipient of Adapted Material from You automatically receives an - offer from the Licensor to exercise the Licensed Rights in the - Adapted Material under the conditions of the Adapter’s License You - apply. - - C. No downstream restrictions. You may not offer or impose any - additional or different terms or conditions on, or apply any - Effective Technological Measures to, the Licensed Material if doing - so restricts exercise of the Licensed Rights by any recipient of the - Licensed Material. - - 6. No endorsement. Nothing in this Public License constitutes or may - be construed as permission to assert or imply that You are, or that - Your use of the Licensed Material is, connected with, or sponsored, - endorsed, or granted official status by, the Licensor or others - designated to receive attribution as provided in Section - 3(a)(1)(A)(i). - -Other rights. - - 1. Moral rights, such as the right of integrity, are not licensed - under this Public License, nor are publicity, privacy, and/or other - similar personality rights; however, to the extent possible, the - Licensor waives and/or agrees not to assert any such rights held by - the Licensor to the limited extent necessary to allow You to exercise - the Licensed Rights, but not otherwise. - - 2. Patent and trademark rights are not licensed under this Public - License. - - 3. To the extent possible, the Licensor waives any right to collect - royalties from You for the exercise of the Licensed Rights, whether - directly or through a collecting society under any voluntary or - waivable statutory or compulsory licensing scheme. In all other cases - the Licensor expressly reserves any right to collect such royalties. - -Section 3 – License Conditions. -------------------------------- - -Your exercise of the Licensed Rights is expressly made subject to the -following conditions. - - a. Attribution. - - 1. If You Share the Licensed Material (including in modified form), - You must: - - A. retain the following if it is supplied by the Licensor with the - Licensed Material: - - i. identification of the creator(s) of the Licensed Material and - any others designated to receive attribution, in any reasonable - manner requested by the Licensor (including by pseudonym if - designated); - - ii. a copyright notice; - - iii. a notice that refers to this Public License; - - iv. a notice that refers to the disclaimer of warranties; - - v. a URI or hyperlink to the Licensed Material to the extent - reasonably practicable; - - B.indicate if You modified the Licensed Material and retain an - indication of any previous modifications; and - - C. indicate the Licensed Material is licensed under this Public - License, and include the text of, or the URI or hyperlink to, this - Public License. - - 2. You may satisfy the conditions in Section 3(a)(1) in any - reasonable manner based on the medium, means, and context in which - You Share the Licensed Material. For example, it may be reasonable - to satisfy the conditions by providing a URI or hyperlink to a - resource that includes the required information. - - 3. If requested by the Licensor, You must remove any of the - information required by Section 3(a)(1)(A) to the extent reasonably - practicable. - - b. ShareAlike. - - In addition to the conditions in Section 3(a), if You Share Adapted - Material You produce, the following conditions also apply. - - 1. The Adapter’s License You apply must be a Creative Commons - license with the same License Elements, this version or later, or a - BY-SA Compatible License. - - 2. You must include the text of, or the URI or hyperlink to, the - Adapter's License You apply. You may satisfy this condition in any - reasonable manner based on the medium, means, and context in which - You Share Adapted Material. - - 3. You may not offer or impose any additional or different terms or - conditions on, or apply any Effective Technological Measures to, - Adapted Material that restrict exercise of the rights granted under - the Adapter's License You apply. - -Section 4 – Sui Generis Database Rights. ----------------------------------------- - -Where the Licensed Rights include Sui Generis Database Rights that apply -to Your use of the Licensed Material: - - a. for the avoidance of doubt, Section 2(a)(1) grants You the right to - extract, reuse, reproduce, and Share all or a substantial portion of - the contents of the database; - - b. if You include all or a substantial portion of the database - contents in a database in which You have Sui Generis Database Rights, - then the database in which You have Sui Generis Database Rights (but - not its individual contents) is Adapted Material, including for - purposes of Section 3(b); and - - c. You must comply with the conditions in Section 3(a) if You Share - all or a substantial portion of the contents of the database. - -For the avoidance of doubt, this Section 4 supplements and does not -replace Your obligations under this Public License where the Licensed -Rights include other Copyright and Similar Rights. - -Section 5 – Disclaimer of Warranties and Limitation of Liability. ------------------------------------------------------------------ - - a. Unless otherwise separately undertaken by the Licensor, to the - extent possible, the Licensor offers the Licensed Material as-is and - as-available, and makes no representations or warranties of any kind - concerning the Licensed Material, whether express, implied, statutory, - or other. This includes, without limitation, warranties of title, - merchantability, fitness for a particular purpose, non-infringement, - absence of latent or other defects, accuracy, or the presence or - absence of errors, whether or not known or discoverable. Where - disclaimers of warranties are not allowed in full or in part, this - disclaimer may not apply to You. - - b. To the extent possible, in no event will the Licensor be liable to - You on any legal theory (including, without limitation, negligence) or - otherwise for any direct, special, indirect, incidental, - consequential, punitive, exemplary, or other losses, costs, expenses, - or damages arising out of this Public License or use of the Licensed - Material, even if the Licensor has been advised of the possibility of - such losses, costs, expenses, or damages. Where a limitation of - liability is not allowed in full or in part, this limitation may not - apply to You. - - c. The disclaimer of warranties and limitation of liability provided - above shall be interpreted in a manner that, to the extent possible, - most closely approximates an absolute disclaimer and waiver of all - liability. - -Section 6 – Term and Termination. ---------------------------------- - - a. This Public License applies for the term of the Copyright and - Similar Rights licensed here. However, if You fail to comply with this - Public License, then Your rights under this Public License terminate - automatically. - - b. Where Your right to use the Licensed Material has terminated under - Section 6(a), it reinstates: - - 1. automatically as of the date the violation is cured, provided it - is cured within 30 days of Your discovery of the violation; or - - 2. upon express reinstatement by the Licensor. - - For the avoidance of doubt, this Section 6(b) does not affect any - right the Licensor may have to seek remedies for Your violations of - this Public License. - - c. For the avoidance of doubt, the Licensor may also offer the - Licensed Material under separate terms or conditions or stop - distributing the Licensed Material at any time; however, doing so will - not terminate this Public License. - - d. Sections 1, 5, 6, 7, and 8 survive termination of this Public - License. - -Section 7 – Other Terms and Conditions. ---------------------------------------- - - a. The Licensor shall not be bound by any additional or different - terms or conditions communicated by You unless expressly agreed. - - b. Any arrangements, understandings, or agreements regarding the - Licensed Material not stated herein are separate from and independent - of the terms and conditions of this Public License. - -Section 8 – Interpretation. ---------------------------- - - a. For the avoidance of doubt, this Public License does not, and - shall not be interpreted to, reduce, limit, restrict, or impose - conditions on any use of the Licensed Material that could lawfully - be mad without permission under this Public License. - - b. To the extent possible, if any provision of this Public License is - deemed unenforceable, it shall be automatically reformed to the - minimum extent necessary to make it enforceable. If the provision - cannot be reformed, it shall be severed from this Public License - without affecting the enforceability of the remaining terms and - conditions. - - c. No term or condition of this Public License will be waived and no - failure to comply consented to unless expressly agreed to by the - Licensor. - - d. Nothing in this Public License constitutes or may be interpreted - as a limitation upon, or waiver of, any privileges and immunities - that apply to the Licensor or You, including from the legal - processes of any jurisdiction or authority. diff --git a/README.md b/README.md deleted file mode 100644 index 3b0e9ac..0000000 --- a/README.md +++ /dev/null @@ -1,106 +0,0 @@ -# python-packaging-tutorial -Tutorial on python packaging at SciPy 2018 - -## Installation instructions - - -### Windows - -* Install Miniconda3: https://conda.io/docs/user-guide/install/windows.html -* Install conda-build using conda: https://conda.io/docs/user-guide/tasks/build-packages/install-conda-build.html -* install Visual Studio 2017: https://www.visualstudio.com/thank-you-downloading-visual-studio/?sku=Community&rel=15&utm_source=vscom&utm_medium=clickbutton&utm_campaign=tailored_featurepgcppsp&rid=34346 -* Install Docker for Windows: https://www.docker.com/docker-windows -* create a conda environment for playing with scikit-build: ``conda create -n skbuild -c conda-forge cmake scikit-build cython`` - - -### MacOS - -* Install Miniconda3: https://conda.io/docs/user-guide/install/macos.html -* Install conda-build using conda: https://conda.io/docs/user-guide/tasks/build-packages/install-conda-build.html -* Install Xcode: ​https://itunes.apple.com/us/app/xcode/id497799835?mt=12​ . -* Follow instructions in the conda-build documentation to install an older MacOS SDK: https://conda.io/docs/user-guide/tasks/build-packages/compiler-tools.html#macos-sdk -* Install Docker for Mac: https://www.docker.com/docker-mac -* create a conda environment for playing with scikit-build: ``conda create -n skbuild -c conda-forge cmake scikit-build cython`` - - -### Linux - -* Install Miniconda3: https://conda.io/docs/user-guide/install/linux.html -* Install conda-build using conda: https://conda.io/docs/user-guide/tasks/build-packages/install-conda-build.html -* Install Docker client for your OS: - * Ubuntu: https://www.digitalocean.com/community/tutorials/how-to-install-and-use-docker-on-ubuntu-16-04 - * Fedora/RHEL: https://developer.fedoraproject.org/tools/docker/docker-installation.html -* create a conda environment for playing with scikit-build: ``conda create -n skbuild -c conda-forge cmake scikit-build cython`` - - -### Docker Image caching - -* run ```docker pull docker pull dockcross/manylinux-x64``` - - -## Testing installation - -* Clone this repository -* cd into the ``test_recipes`` folder -* run ``conda build bitarray``. Success is indicated by output like: - -``` -===== bitarray-0.8.1-py36h1de35cc_1 OK ===== -import: 'bitarray' - -Resource usage statistics from testing bitarray: - Process count: 1 - CPU time: Sys=0:00:00.0, User=0:00:00.0 - Memory: 1.1M - Disk usage: 16B - Time elapsed: 0:00:02.0 - -TEST END: /Users/msarahan/miniconda3/conda-bld/osx-64/bitarray-0.8.1-py36h1de35cc_1.tar.bz2 -Renaming work directory, /Users/msarahan/miniconda3/conda-bld/bitarray_1529267981928/work to /Users/msarahan/miniconda3/conda-bld/bitarray_1529267981928/work_moved_bitarray-0.8.1-py36h1de35cc_1_osx-64_main_build_loop -# Automatic uploading is disabled -# If you want to upload package(s) to anaconda.org later, type: - -anaconda upload /Users/msarahan/miniconda3/conda-bld/osx-64/bitarray-0.8.1-py36h1de35cc_1.tar.bz2 - -# To have conda build upload to anaconda.org automatically, use -# $ conda config --set anaconda_upload yes - -anaconda_upload is not set. Not uploading wheels: [] -#################################################################################### -Resoource usage summary: - -Total time: 0:00:36.9 -CPU usage: sys=0:00:00.2, user=0:00:00.2 -Maximum memory usage observed: 50.6M -Total disk usage observed (not including envs): 1016B - - -#################################################################################### -``` - -* cd into the ``test_recipes/hello-cython`` folder -* activate the ``skbuild`` environment: ``conda activate skbuild``. For older conda (<4.4) installations, follow legacy instructions at https://conda.io/docs/user-guide/tasks/manage-environments.html#activating-an-environment -* run ``python setup.py install``. Success is indicated by output ending in lines like: - -``` -creating 'dist/hello_cython-1.2.3-py3.5-macosx-10.9-x86_64.egg' and adding '_skbuild/setuptools/bdist.macosx-10.9-x86_64/egg' to it -removing '_skbuild/setuptools/bdist.macosx-10.9-x86_64/egg' (and everything under it) -Processing hello_cython-1.2.3-py3.5-macosx-10.9-x86_64.egg -Copying hello_cython-1.2.3-py3.5-macosx-10.9-x86_64.egg to /Users/msarahan/miniconda3/envs/skbuild/lib/python3.5/site-packages -Adding hello-cython 1.2.3 to easy-install.pth file - -Installed /Users/msarahan/miniconda3/envs/skbuild/lib/python3.5/site-packages/hello_cython-1.2.3-py3.5-macosx-10.9-x86_64.egg -Processing dependencies for hello-cython==1.2.3 -Finished processing dependencies for hello-cython==1.2.3 -``` -* You're all set! - -## Troubleshooting - -* Please file issues on this github issue tracker: https://github.com/python-packaging-tutorial/python-packaging-tutorial/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc - - -## Package hosting service accounts -Pprior to attending the tutorial, participants should set up an account on -* PyPI (​https://pypi.python.org/pypi?%3Aaction=register_form​) -* anaconda.org (​https://anaconda.org/​) diff --git a/_config.yml b/_config.yml new file mode 100644 index 0000000..cd1934b --- /dev/null +++ b/_config.yml @@ -0,0 +1,2 @@ +plugins: + - jekyll-redirect-from diff --git a/index.md b/index.md new file mode 100644 index 0000000..f84a1f8 --- /dev/null +++ b/index.md @@ -0,0 +1,3 @@ +--- +redirect_to: https://python-packaging-tutorial.readthedocs.io +--- diff --git a/sphinx_presentation/2018-AnacondaCON-PackageBuilding.pptx b/sphinx_presentation/2018-AnacondaCON-PackageBuilding.pptx deleted file mode 100644 index aa0e68a..0000000 Binary files a/sphinx_presentation/2018-AnacondaCON-PackageBuilding.pptx and /dev/null differ diff --git a/sphinx_presentation/Makefile b/sphinx_presentation/Makefile deleted file mode 100644 index f122f0d..0000000 --- a/sphinx_presentation/Makefile +++ /dev/null @@ -1,20 +0,0 @@ -# Minimal makefile for Sphinx documentation -# - -# You can set these variables from the command line. -SPHINXOPTS = -SPHINXBUILD = sphinx-build -SPHINXPROJ = TheJoyofPackaging -SOURCEDIR = source -BUILDDIR = build - -# Put it first so that "make" without argument is like "make help". -help: - @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) - -.PHONY: help Makefile - -# Catch-all target: route all unknown targets to Sphinx using the new -# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). -%: Makefile - @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) \ No newline at end of file diff --git a/sphinx_presentation/make.bat b/sphinx_presentation/make.bat deleted file mode 100644 index 6258635..0000000 --- a/sphinx_presentation/make.bat +++ /dev/null @@ -1,36 +0,0 @@ -@ECHO OFF - -pushd %~dp0 - -REM Command file for Sphinx documentation - -if "%SPHINXBUILD%" == "" ( - set SPHINXBUILD=sphinx-build -) -set SOURCEDIR=source -set BUILDDIR=build -set SPHINXPROJ=TheJoyofPackaging - -if "%1" == "" goto help - -%SPHINXBUILD% >NUL 2>NUL -if errorlevel 9009 ( - echo. - echo.The 'sphinx-build' command was not found. Make sure you have Sphinx - echo.installed, then set the SPHINXBUILD environment variable to point - echo.to the full path of the 'sphinx-build' executable. Alternatively you - echo.may add the Sphinx directory to PATH. - echo. - echo.If you don't have Sphinx installed, grab it from - echo.http://sphinx-doc.org/ - exit /b 1 -) - -%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% -goto end - -:help -%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% - -:end -popd diff --git a/sphinx_presentation/slides2rst.py b/sphinx_presentation/slides2rst.py deleted file mode 100755 index c0373f8..0000000 --- a/sphinx_presentation/slides2rst.py +++ /dev/null @@ -1,65 +0,0 @@ -#!/usr/bin/env python - -""" -hacky script to convert the txt exported from google slides to rst for hieroglyph -""" - -inlines = open("2018-AnacondaCON-PackageBuilding.pptx.txt").readlines() -outfilename = "PackageBuilding.rst" - -rst = [] - -# first line is the title: -title = inlines.pop(0).strip() -rst.append("#" * len(title)) -rst.append(title) -rst.append("#" * len(title)) -rst.append("") -# find end of title page: -line = inlines.pop(0) -while line.strip() != '1': - rst.append(line) - line = inlines.pop(0) - -while inlines: - # look for slide break: - slide_num = 0 - for i, line in enumerate(inlines): - # numbers by themselves on a line is a new slide - try: - num = int(line) - except ValueError: - continue - if num != slide_num: - slide_num = num - start_ind = i - else: - # we've hit the second numbers - end_ind = i - break - # write content - # slide header is right before slide number - header = inlines[start_ind - 1].strip() - rst.append(header) - rst.append("-" * len(header)) - - # content is the stuff above it - for line in inlines[:start_ind - 1]: - rst.append(line) - # footer is the stuff in between - rst.append("") - for line in inlines[start_ind + 1:end_ind]: - rst.append(line) - # clear it all out: - del inlines[:end_ind + 1] - # and clear out any empty lines - while inlines and (not inlines[0].strip()): - del inlines[0] - - - - - - -open(outfilename, 'w').write("\n".join(rst)) - diff --git a/sphinx_presentation/source/conf.py b/sphinx_presentation/source/conf.py deleted file mode 100644 index 4a1e83f..0000000 --- a/sphinx_presentation/source/conf.py +++ /dev/null @@ -1,160 +0,0 @@ -# -*- coding: utf-8 -*- -# -# Configuration file for the Sphinx documentation builder. -# -# This file does only contain a selection of the most common options. For a -# full list see the documentation: -# http://www.sphinx-doc.org/en/master/config - -# -- Path setup -------------------------------------------------------------- - -# If extensions (or modules to document with autodoc) are in another directory, -# add these directories to sys.path here. If the directory is relative to the -# documentation root, use os.path.abspath to make it absolute, like shown here. -# -# import os -# import sys -# sys.path.insert(0, os.path.abspath('.')) - - -# -- Project information ----------------------------------------------------- - -project = 'The Joy of Packaging' -copyright = '2018, Assorted' -author = 'Assorted' - -# The short X.Y version -version = '' -# The full version, including alpha/beta/rc tags -release = '0.1' - - -# -- General configuration --------------------------------------------------- - -# If your documentation needs a minimal Sphinx version, state it here. -# -# needs_sphinx = '1.0' - -# Add any Sphinx extension module names here, as strings. They can be -# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom -# ones. -extensions = [ - 'sphinx.ext.githubpages', - 'hieroglyph', -] - -# Add any paths that contain templates here, relative to this directory. -templates_path = ['_templates'] - -# The suffix(es) of source filenames. -# You can specify multiple suffix as a list of string: -# -# source_suffix = ['.rst', '.md'] -source_suffix = '.rst' - -# The master toctree document. -master_doc = 'index' - -# The language for content autogenerated by Sphinx. Refer to documentation -# for a list of supported languages. -# -# This is also used if you do content translation via gettext catalogs. -# Usually you set "language" from the command line for these cases. -language = None - -# List of patterns, relative to source directory, that match files and -# directories to ignore when looking for source files. -# This pattern also affects html_static_path and html_extra_path . -exclude_patterns = [] - -# The name of the Pygments (syntax highlighting) style to use. -pygments_style = 'sphinx' - - -# -- Options for HTML output ------------------------------------------------- - -# The theme to use for HTML and HTML Help pages. See the documentation for -# a list of builtin themes. -# -html_theme = 'alabaster' - -# Theme options are theme-specific and customize the look and feel of a theme -# further. For a list of options available for each theme, see the -# documentation. -# -# html_theme_options = {} - -# Add any paths that contain custom static files (such as style sheets) here, -# relative to this directory. They are copied after the builtin static files, -# so a file named "default.css" will overwrite the builtin "default.css". -html_static_path = ['_static'] - -# Custom sidebar templates, must be a dictionary that maps document names -# to template names. -# -# The default sidebars (for documents that don't match any pattern) are -# defined by theme itself. Builtin themes are using these templates by -# default: ``['localtoc.html', 'relations.html', 'sourcelink.html', -# 'searchbox.html']``. -# -# html_sidebars = {} - - -# -- Options for HTMLHelp output --------------------------------------------- - -# Output file base name for HTML help builder. -htmlhelp_basename = 'TheJoyofPackagingdoc' - - -# -- Options for LaTeX output ------------------------------------------------ - -latex_elements = { - # The paper size ('letterpaper' or 'a4paper'). - # - # 'papersize': 'letterpaper', - - # The font size ('10pt', '11pt' or '12pt'). - # - # 'pointsize': '10pt', - - # Additional stuff for the LaTeX preamble. - # - # 'preamble': '', - - # Latex figure (float) alignment - # - # 'figure_align': 'htbp', -} - -# Grouping the document tree into LaTeX files. List of tuples -# (source start file, target name, title, -# author, documentclass [howto, manual, or own class]). -latex_documents = [ - (master_doc, 'TheJoyofPackaging.tex', 'The Joy of Packaging Documentation', - 'Assorted', 'manual'), -] - - -# -- Options for manual page output ------------------------------------------ - -# One entry per manual page. List of tuples -# (source start file, name, description, authors, manual section). -man_pages = [ - (master_doc, 'thejoyofpackaging', 'The Joy of Packaging Documentation', - [author], 1) -] - - -# -- Options for Texinfo output ---------------------------------------------- - -# Grouping the document tree into Texinfo files. List of tuples -# (source start file, target name, title, author, -# dir menu entry, description, category) -texinfo_documents = [ - (master_doc, 'TheJoyofPackaging', 'The Joy of Packaging Documentation', - author, 'TheJoyofPackaging', 'One line description of project.', - 'Miscellaneous'), -] - - -# -- Extension configuration ------------------------------------------------- \ No newline at end of file diff --git a/sphinx_presentation/source/images/about_section.png b/sphinx_presentation/source/images/about_section.png deleted file mode 100644 index d599bf8..0000000 Binary files a/sphinx_presentation/source/images/about_section.png and /dev/null differ diff --git a/sphinx_presentation/source/images/build_host_run.png b/sphinx_presentation/source/images/build_host_run.png deleted file mode 100644 index 0825a9e..0000000 Binary files a/sphinx_presentation/source/images/build_host_run.png and /dev/null differ diff --git a/sphinx_presentation/source/images/conda-forge.png b/sphinx_presentation/source/images/conda-forge.png deleted file mode 100644 index 9cb7dc2..0000000 Binary files a/sphinx_presentation/source/images/conda-forge.png and /dev/null differ diff --git a/sphinx_presentation/source/images/cookiecutter.png b/sphinx_presentation/source/images/cookiecutter.png deleted file mode 100644 index 6f2f286..0000000 Binary files a/sphinx_presentation/source/images/cookiecutter.png and /dev/null differ diff --git a/sphinx_presentation/source/images/req_run_exports.png b/sphinx_presentation/source/images/req_run_exports.png deleted file mode 100644 index 5d6973f..0000000 Binary files a/sphinx_presentation/source/images/req_run_exports.png and /dev/null differ diff --git a/sphinx_presentation/source/images/run_exports.png b/sphinx_presentation/source/images/run_exports.png deleted file mode 100644 index be1e2d3..0000000 Binary files a/sphinx_presentation/source/images/run_exports.png and /dev/null differ diff --git a/sphinx_presentation/source/index.rst b/sphinx_presentation/source/index.rst deleted file mode 100644 index e40cb93..0000000 --- a/sphinx_presentation/source/index.rst +++ /dev/null @@ -1,44 +0,0 @@ -.. The Joy of Packaging documentation master file, created by - sphinx-quickstart on Fri Jul 6 14:55:10 2018. - You can adapt this file completely to your liking, but it should at least - contain the root `toctree` directive. - -The Joy of Packaging! -===================== - -.. toctree:: - :maxdepth: 1 - :caption: Contents: - - overview - package_building - -Instructors ------------ - -Michael Sarahan, PhD: Conda-build tech lead, Anaconda, Inc. - -Matt McCormick (thewtex): Maintainer of dockcross, of Python packages for the Insight Toolkit (ITK) - -Jean-Christophe Fillion-Robin (jcfr): Maintainer of scikit-build, scikit-ci, scikit-ci-addons and python-cmake-buildsystem - -Filipe Fernandes (ocefpaf): Conda-forge core team, Maintainer of folium and a variety of libraries for ocean sciences. - -Matt Craig (mwcraig): Maintainer of ccdproc, reducer, astropy, lead on conda packaging for astropy, Conda-forge core team. - -Chris Barker (PythonCHB): Python instructor for the Univ. Washington Continuing Education Program, Contributor to conda-forge project. - -Ray Donnelly (mingwandroid): Anaconda employee, working on Anaconda Distribution. MSYS2 co-founder, Likes build systems too much. - -Jonathan Helmus (jjhelmus): Anaconda employee, working on Anaconda Distribution Builds tensorflow for fun, conda-forge core team member -Contributor to various open source packages in the scientific Python ecosystem. - - - - -Indices and tables -================== - -* :ref:`genindex` -* :ref:`modindex` -* :ref:`search` diff --git a/sphinx_presentation/source/overview.rst b/sphinx_presentation/source/overview.rst deleted file mode 100644 index 353d12d..0000000 --- a/sphinx_presentation/source/overview.rst +++ /dev/null @@ -1,204 +0,0 @@ -*************************** -Packaging Tutorial Overview -*************************** - -Outline: -======== - -0:00-00:20 Overview of packaging --------------------------------- - - * Source/binary - * Wheel vs conda packages - * PyPI/anaconda.org - -0:20-0:45 setup.py ------------------- - -* Essential specifications -* Optional specifications -* Specifying requirements -* In setup.py vs requirements file -* When and how to "pin" requirements - -Exercise: -......... - -Fill in the missing pieces in a setup.py for a sample package -Build a source distribution for the package - -0:45-1:00 Building and uploading to PyPI: ------------------------------------------ - -Tools and package types - - -**flit:** great for simple packages - -**twine:** the secure way to upload to PyPI - -* Building a source distribution - -* Building a wheel - -* Multibuild - https://github.com/matthew-brett/multibuild - -* Manylinux docker image - https://github.com/pypa/manylinux - -* Delocate - https://github.com/matthew-brett/delocate - -* Auditwheel - https://github.com/pypa/auditwheel - -1:00-1:10 Break ---------------- - -1:10-1:30 Worked example/exercise: ----------------------------------- - -Building a package and uploading to pypi - -Continuing from the the previous exercise, build a wheel for the package - -Register the package on the pypi testing server - -Upload the built distributions using twine - -Delete one of the uploaded files on pypi and try re-uploading (will fail) - -Introduce the idea of .post releases (it will happen to everyone who uploads) - -1:30-1:45 Binaries and dependencies: ------------------------------------- - -how scikit-build and conda-build can make life easier - -1:45-2:00 Scikit-build overview: - -Why + Motivations - -From [distutils.core.Extension] to [scikit-build + CMake] in few lines -Support for developer mode (bonus) - -2:00-2:45 Exercise: -------------------- - -Add CMake project that generates python extension. Tie -it into previous python project. - -Cookie cutter template integrating conda, pypi, etc. will be provided. - -2:45-3:00 Break ---------------- - -3:00-3:15 Conda-build overview ------------------------------- - -3:15-3:30 Exercise: -------------------- - -Write a conda recipe for the sample package from previous exercises (pure python) - -noarch packages - -Upload to anaconda cloud - -3:15-3:45 Exercise: -------------------- - -Recipe for package with compiled extensions - -Add compiled extension (source will be provided to students) to sample package - -Modify recipe, if needed - -Rebuild the package - -Version pinning (python, numpy) - -Split packages - multi-ecosystem ones - -Compiler packages + pin_downstream - -Interoperation with scikit-build - -3:45-4:00 Automated building with cloud-based CI services: ----------------------------------------------------------- - -conda-forge (optional; as time allows) - -http://scikit-ci.readthedocs.io - -http://scikit-ci-addons.readthedocs.io - -CI service overview & Conda-forge -- what are the pieces and how do they fit together? - -Recipe format - -staged-recipes - -feedstocks - -Re-rendering and conda-smithy - -Updating package when new version released - -Future direction/community needs - -Invitation to sprints - -Contributing to Conda-forge - -Intro to conda-forge: staged-recipes, maintainer role, contributing to an existing package - -conda-smithy lint/rerender - -Example to go from the conda-skeleton to a PR on staged-recipes - -Comment on some special cases: cython extensions, non-python pkgs, the use of the CIs, etc. - -Exercise: put a package on staged-recipes - - -Tutorial code base layout: --------------------------- - -Name of the organization: python-packaging-tutorial - -All projects should be associated with a cookiecutter template - -One organization with multiple repos (or multiple branches ?) - -0_readme -1_helloworld_pure - -Install python - -Work with virtual env - -Include pytest, documentation building, … - -2_helloworld_c - -Show how C extensions are included in setup.py, and how they are made available to python - -3_helloworld_with_ci - -Introduce Appveyor, CircleCi, Travis - -Difference between CI for testing and CI for creating packages (CD) - -4_helloworld_skbuild - -Introduce C extensions with cmake - -Show how scikitbuild can help tie python and cmake together nicely - -5_helloworld_skbuild_ci - -Show how scikitbuild-ci can be used to simplify and unify CI scripts - -6_helloworld_skbuild_conda - -Show how conda-build can be used to produce conda packages and wheels, using the build files we’ve already used from previous exercises. - -7_Uploading_to_PyPI_&_anaconda.org diff --git a/sphinx_presentation/source/package_building.rst b/sphinx_presentation/source/package_building.rst deleted file mode 100644 index 1586202..0000000 --- a/sphinx_presentation/source/package_building.rst +++ /dev/null @@ -1,2439 +0,0 @@ -#################### -The Joy of Packaging -#################### - - -Scipy 2018 Tutorial -=================== - -Instructors ------------ - -Michael Sarahan, Matt McCormick, Jean-Christophe Fillion-Robin, Filipe Fernandes Matt Craig, Chris Barker, Ray Donnelly, Jonathan Helmus - - -Outline -------- - -Python Package - -Installing - -PyPi - -Conda - -Compatibility and automation - - -What is a “package”? --------------------- - -In a broad sense, anything you install using your package manager - -some kinds of packages have implied behavior and requirements - -Unfortunate overloading: python “package”: a folder that python imports - - -Package Managers and Repos --------------------------- - -NPM, apt, yum, dnf, chocolatey, pip, conda, homebrew, etc. - -PyPI, anaconda.org, CRAN, CPAN - -Some form of dependency management - -Artifact and/or source repository - - -Implicit behavior & Requirements --------------------------------- - -* Folder structure - -* Directly usable, or must be unpacked/installed? - -Python packages ---------------- - -:: - - sound/ - __init__.py - formats/ - __init__.py - wavwrite.py - effects/ - __init__.py - echo.py - -Folders must have ``__init__.py`` file to make Python able to import them - -``__init__.py`` can be empty (and is, most of the time) - - - - -Python packages - why? ----------------------- - - -import nested module - -.. code-block:: python - - import sound.effects.echo - - from sound.effects import echo - -.. code-block:: python - - from sound.effects.echo import somefunc - - -``https://docs.python.org/3/tutorial/modules.html#packages`` - - -Let’s Make a Package --------------------- - - -:: - - mypkg/ - __init__.py - subpkg/ - __init__.py - a.py - - - -.. nextslide:: - -**Windows:** - -.. code-block:: bash - - mkdir mypkg/subpkg - - echo. > mypkg/__init__.py - - echo . > mypkg/subpkg/__init__.py - - echo . > mypkg/subpkg/a.py - - -**Mac/Linux:** - -.. code-block:: bash - - mkdir -p mypkg/subpkg - - touch mypkg/__init__.py - - touch mypkg/subpkg/__init__.py - - touch mypkg/subpkg/a.py - - -How Python Finds Packages -------------------------- - -* In python interpreter: - - .. code-block:: python - - import sys - from pprint import pprint - pprint(sys.path) - - - -* ``sys.path`` explanation: - - ``https://stackoverflow.com/a/38403654/1170370`` - - -How to Get Things on ``sys.path`` ---------------------------------- - -* ``PYTHONPATH`` environment variable (fragile) - -* Installing packages (destination: site-packages folder) - -* ``.pth`` files in ``sys.path`` locations - - -Find your site-packages folder ------------------------------- - -* Windows: - ``(install root)\Lib\site-packages`` - - -* Mac/Linux: - ``(install root)/lib/pythonX.Y/site-packages`` - - -Installing packages -=================== - - -Installing: - -.. code-block:: bash - - python setup.py install - - pip install . - -Development installs: - -.. code-block:: bash - - python setup.py develop - - pip install -e . - - -+--------------------------------------+----------------------------------------+ -| Install | Development Install | -+======================================+========================================+ -| Copies package into site-packages | Adds a ``.pth`` file to site-packages, | -| | pointed at package source root | -+--------------------------------------+----------------------------------------+ -| Used when creating conda packages | Used when developing software locally | -+--------------------------------------+----------------------------------------+ -| Normal priority in sys.path | End of ``sys.path`` (only found if | -| | nothing else comes first) | -+======================================+========================================+ - -https://grahamwideman.wikispaces.com/Python-+site-package+dirs+and+.pth+files - - -What about setup.py? --------------------- - -.. code-block:: python - - #!/usr/bin/env - - pythonfrom setuptools import setups - - setup(name='Distutils', - version='1.0', - description='Python Distribution Utilities', - author='Greg Ward', - author_email='gward@python.net', - url='https://www.python.org/sigs/distutils-sig/', packages=['distutils', 'distutils.command'], - ) - -``https://docs.python.org/2/distutils/setupscript.html`` - -What Does ``setup.py`` Do? --------------------------- - -* Version & package metadata - -* List of packages to include - -* List of other files to include - -* Lists of dependencies - -* Lists of extensions to be compiled - - -Let’s Write a ``setup.py`` --------------------------- - -.. code-block:: python - - #!/usr/bin/env python - - from setuptools import setup - - setup(name='mypkg', - version='1.0', - # list folders, not files - packages=['mypkg', 'mypkg.subpkg'], - ) - -(remember that a "package" is a folder with a ``__init__.py__`` file) - - -setuptools ----------- - -* Separate library (ships with Python by default, though) - -* Adds entry point capability - -* Provides find_packages function (use with caution) - -* Creates eggs by default (people spend time fighting this later in the process) - - -Where does setup.py go? ------------------------ - -+--------------------------+-----------------------------------------------------+ -| Folder Structure | | -+==========================+=====================================================+ -| .. code-block:: python | | -| | * New outer folder | -| mypkg-src | * ``setup.py`` alongside package to be installed | -| setup.py | * ``mypkg`` is what will get installed | -| mypkg/ | * ``mypkg-src`` is what gets linked to by develop | -| __init__.py | | -| subpkg/ | | -| __init__.py | | -| a.py | | -+--------------------------+-----------------------------------------------------+ - - - -Try installing your package ---------------------------- - -.. code-block:: bash - - cd mypkg-src - - python setup.py install - - python -c “import mypkg.subpkg.a” - -Go look in your ``site-packages`` folder - - -Making Packages the Easy Way ----------------------------- - -.. image:: images/cookiecutter.png - - -`github.com/audreyr/cookiecutter `_ - -.. code-block:: bash - - conda install -c conda-forge cookiecutter - -or - -.. code-block:: bash - - pip install cookiecutter - - -Let’s make a project --------------------- - -cookiecutter: ``https://goo.gl/Jge1g8`` - - -That’s a shortened link to: - -``https://github.com/conda/cookiecutter-conda-python`` - -:: - - full_name [Full Name]: Mike Sarahan - email [Email Address]: msarahan@anaconda.com - github_username [github_username]: msarahan - repo_name [repository_name]: acon_demo - package_name [acon_demo]: - project_short_description [Short description]: acon demo - version [0.1.0]: - - -What did we get? ----------------- - -.. code-block:: bash - - ls -R acon_demo - - README.rst acon_demo conda.recipe setup.py tests - acon_demo/acon_demo: - __init__.py __main__.py cli.py - acon_demo/conda.recipe: - meta.yaml - acon_demo/tests: - __init__.py test_cli.py - - -Requirements in ``setup.py`` ----------------------------- - -.. code-block:: python - - #!/usr/bin/env python - from distutils.core import setup - - setup(name='mypkg', - version='1.0', - # list folders, not files - packages=['mypkg', 'mypkg.subpkg'], - install_requires=['click'], - ) - - -Requirements in ``requirements.txt`` ------------------------------------- - -**Common Mistake:** - -* ``requirements.txt`` often from pip freeze - -* Pinned way too tightly. OK for env creation, bad for packaging. -| -* Donald Stufft (PyPA): `Abstract vs. Concrete dependencies `_ - - - -Requirements in ``setup.cfg`` (ideal) -------------------------------------- - -:: - - [metadata] - name = my_package - version = attr: - src.VERSION - - [options] - packages = find: - install_requires = click - - -Parseable without execution, unlike setup.py - -`configuring setup using setup cfg files `_ - -Break time! ------------ - -Up next: producing redistributable artifacts - - -Redistributable artifacts -========================= - -* sdists - -* wheels - -* conda packages - -* eggs (deprecated) - - -When/how to use an sdist ------------------------- - -* Pure python (no compilation requirements) - -* Or, distributing source code that must be compiled prior to usage - -.. code-block:: bash - - python setup.py sdist - - -Wheels vs. Conda packages -------------------------- - -+-------------------------------------+-------------------------------------+ -| Wheels | Conda packages | -+=====================================+=====================================+ -| Employed by pip, blessed by PyPA | Foundation of Anaconda ecosystem | -+-------------------------------------+-------------------------------------+ -| Used by any python installation | Used by conda python installations | -+-------------------------------------+-------------------------------------+ -| Mostly specific to Python ecosystem | General purpose (any ecosystem) | -+-------------------------------------+-------------------------------------+ -| Good mechanism for specifying range | Primitive support for multiple | -| of python compatibility | python versions (noarch) | -+-------------------------------------+-------------------------------------+ -| Depends on static linking or other | Can bundle core system-level shared | -| system package managers to provide | libraries as packages, and resolve | -| core libraries | dependencies | -+-------------------------------------+-------------------------------------+ - - - -Introducing conda-build ------------------------ - -* Orchestrates environment creation, activation, and build/test processes - -* Can build conda packages and/or wheels - -* Separate project from conda, but very tightly integrated - -* Open-source, actively developed: - - https://github.com/conda/conda-build - - -Getting ``conda-build`` to work for you ---------------------------------------- - -Input: ``meta.yaml`` files - -.. code-block:: yaml - - package: - name: mypkg - version: 1.0 - - -Let’s Use ``conda-build`` -------------------------- - -.. code-block:: bash - - conda install conda-build - -* Windows only: - - :: - - conda install m2-patch posix - -* All platforms: - -.. code-block:: bash - - conda build mypkg-src - - -What happened? --------------- - -* Templates filled in, recipe interpreted - -* Build environment created (isolated) - -* Build script run - -* New files in build environment bundled into package - -* Test environment created (isolated) - -* Tests run on new package - -* cleanup - - -Obtaining recipes ------------------- - -* Existing recipes (best) - - - https://github.com/AnacondaRecipes - - - https://github.com/conda-forge - -* Skeletons from other repositories (PyPI, CRAN, CPAN, RPM) - -| - -* DIY - - -Anaconda Recipes ----------------- - -* Official recipes that Anaconda uses for building packages - -* Since Anaconda 5.0, forked from conda-forge recipes. - -* Intended to be compatible with conda-forge long-term - -* Presently, ahead of conda-forge on use of conda-build 3 features - - -Conda-forge ------------ - -.. image:: images/conda-forge.png - -* Numfocus-affiliated community organization made up of volunteers - -* One github repository per recipe - - - Fine granularity over permissions - -* Heavy use of automation for building, deploying, and updating recipes - -* Free builds on public CI services (TravisCI, CircleCI, Appveyor) - - -Skeletons ---------- - -* Read metadata from upstream repository - -* Translate that into a recipe -| -* **Will** save you some boilerplate work - -* **Might** work out of the box (should not assume automatic, though) - - -conda skeleton pypi -------------------- - -.. code-block:: bash - - conda skeleton pypi - - conda skeleton pypi click - - conda skeleton pypi --recursive pyinstrument - - -conda skeleton cran -------------------- - -.. code-block:: bash - - conda skeleton cran - - conda skeleton cran acs - - conda skeleton cran --recursive biwt - - - -When all else fails, write a recipe ------------------------------------ - -Only required section: - - -.. code-block:: yaml - - package: - name: abc - version: 1.2.3 - - -Source types ------------- - -* url - -* git - -* hg - -* svn - -* local path - - -`meta.yaml source section `_ - - -Source Patches --------------- - -* patch files live alongside meta.yaml - -* create patches with: - - ``diff`` - - ``git diff`` - - ``git format-patch`` - - -`meta.yaml source section `_ - - -Exercise: let’s make a patch ----------------------------- - -.. code-block:: yaml - - package: - name: test-patch - version: 1.2.3 - - source: - url: https://zlib.net/zlib-1.2.11.tar.gz - - build: - script: exit 1 - - -.. nextslide:: - -* Builds that fail leave their build folders in place - -* look in output for source tree in: - - ``*/conda-bld/test-patch_/work`` - -* ``cd`` there - -.. nextslide:: - -.. code-block:: bash - - git init - - git add * - - git commit -am “init” - - edit file of choice - - git commit -m “changing file because …” - - git format-patch HEAD~1 - - -.. nextslide:: - -* copy that patch back alongside meta.yaml - -* modify meta.yaml to include the patch - - -Multiple sources ----------------- - -.. code-block:: yaml - - source: - - url: https://package1.com/a.tar.bz2 - folder: stuff - - url: https://package1.com/b.tar.bz2 - folder: stuff - patches: - - something.patch - - git_url: https://github.com/conda/conda-build - folder: conda-build - -`meta.yaml source section `_ - - -Build options -------------- - -``number``: - version reference of recipe (as opposed to version of source code) - -``script``: - quick build steps, avoid separate build.sh/bld.bat files - -``skip``: - skip building recipe on some platforms - -``entry_points``: - python code locations to create executables for - -``run_exports``: - add dependencies to downstream consumers to ensure compatibility - -`meta.yaml build section `_ - - -Requirements ------------- - -.. image:: images/build_host_run.png - - -Requirements: build vs. host ----------------------------- - -* Historically, only build - -* Still fine to use only build - -* host introduced for cross compiling - -* host also useful for separating build tools from packaging environment - - -.. nextslide:: - -**If in doubt, put everything in host** - -* build is treated same as host for old-style recipes -(only build, no ``{{ compiler() }}``) - -* packages are bundled from host env, not build env - - -Post-build Tests ----------------- - -* Help ensure that you didn’t make a packaging mistake - -* Ideally checks that necessary shared libraries are included as dependencies - - - -Post-build tests: dependencies ------------------------------- - -Describe dependencies that are required for the tests -(but not for normal package usage) - -.. code-block:: yaml - - test: - requires: - - pytest - - - -Post-build tests: test files ----------------------------- - - -+----------------------+----------------------------------------------+ -| Windows | Linux / Mac + -+======================+==============================================+ -| ``run_test.pl``, ``run_test.py``, ``run_test.r``, ``run_test.lua`` | -+----------------------+----------------------------------------------+ -| ``run_test.bat`` | ``run_test.sh`` | -+----------------------+----------------------------------------------+ - - - -Post-build tests ----------------- - -* May have specific requirements - -* May specify files that must be bundled for tests (``source_files``) - -* ``imports:`` - language specific imports to try, to verify correct installation - -* ``commands:`` - sequential shell-based commands to run (not OS-specific) - -https://conda.io/docs/user-guide/tasks/build-packages/define-metadata.html#test-section - - -Import Tests ------------- - -.. code-block:: yaml - - test: - imports: - - dateutil - - dateutil.rrule - - dateutil.parser - - dateutil.tz - - -Test commands -------------- - -.. code-block:: yaml - - test: - commands: - - curl --version - - curl-config --features # [not win] - - curl-config --protocols # [not win] - - curl https://some.website.com - - -Outputs - more than one pkg per recipe --------------------------------------- - -.. code-block:: yaml - - package: - name: some-split - version: 1.0 - - outputs: - - name: subpkg - - name: subpkg2 - - -.. nextslide:: - -* Useful for consolidating related recipes that share (large) source - -* Reduce update burden - -* Reduce build time by keeping some parts of the build, while looping over other parts - -* Also output different types of packages from one recipe (wheels) - - -https://conda.io/docs/user-guide/tasks/build-packages/define-metadata.html#outputs-section - - -Outputs rules -------------- - -* list of dicts - -* each list must have ``name`` or ``type`` key - -* May use all entries from ``build``, ``requirements``, ``test``, ``about`` sections - -* May specify files to bundle either using globs or by running a script - - -Outputs Examples ----------------- - -https://github.com/AnacondaRecipes/curl-feedstock/blob/master/recipe/meta.yaml - - -https://github.com/AnacondaRecipes/aggregate/blob/master/ctng-compilers-activation-feedstock/recipe/meta.yaml - - -Exercise: Split a Package -------------------------- - -Curl is a library and an executable. Splitting them lets us clarify where Curl is only a build time dependency, and where it also needs to be a runtime dependency. - -**Starting point:** - -https://github.com/conda-forge/curl-feedstock/tree/master/recipe - - -.. nextslide:: - -**Solution:** - -https://github.com/AnacondaRecipes/curl-feedstock/tree/master/recipe - - - -About section -------------- - -.. image:: images/about_section.png - - - -Extra section: free-for-all ---------------------------- - -* Used for external tools or state management - -* No schema - -* Conda-forge’s maintainer list - -* Conda-build’s notion of whether a recipe is “final” - - -https://conda.io/docs/user-guide/tasks/build-packages/define-metadata.html#extra-section - - -Break time! ------------ - -Advanced recipe tricks coming next - - - -Conditional lines (selectors) ------------------------------ - -:: - - some_content # [some expression] - - -* content inside ``[...]`` is eval’ed - -* namespace includes OS info, python info, and a few others - - -https://conda.io/docs/user-guide/tasks/build-packages/define-metadata.html#preprocessing-selectors - - -Exercise: Limit a Recipe to Only Linux --------------------------------------- - -.. code-block:: yaml - - package: - name: example_skip_recipe - version: 1.0 - - build: - skip: True - -.. nextslide:: - -.. code-block:: yaml - - package: - name: example_skip_recipe - version: 1.0 - - build: - skip: True# [not linux] - - -Intro to Templating with Jinja2 --------------------------------- - -* Fill in information dynamically - - - git tag info - - - setup.py recipe data - - - centralized version numbering - - - string manipulation - -How does Templating Save You Time? ----------------------------------- - -.. code-block:: yaml - - {% set version = "3.0.2" %} - - package: - name: example - version: {{ version }} - source: - url: https://site/{{version}}.tgz - - -Jinja2 Templating in ``meta.yaml`` ----------------------------------- - -Set variables:: - - {% set somevar=”someval” %} - -Use variables:: - - {{ somevar }} - -Expressions in ``{{ }}`` are roughly python - - -Jinja2 conditionals -------------------- - -Selectors are one line only. When you want to toggle a block, use jinja2:: - - {%- if foo -%} - - toggled content - - on many lines - - {% endif %} - - -Exercise: use Jinja2 to reduce edits ------------------------------------- - -.. code-block:: yaml - - package: - name: abc - version: 1.2.3 - - source: - url: http://my.web/abc-1.2.3.tgz - - -.. nextslide:: - -.. code-block:: yaml - - {% set version=”1.2.3” %} - package: - name: abc - version: {{ version }} - - source: - url: http://w/abc-{{version}}.tgz - - -Variants: Jinja2 on steroids ----------------------------- - -Matrix specification in yaml files - -.. code-block:: yaml - - somevar: - - 1.0 - - 2.0 - - anothervar: - - 1.0 - - -All variant variables exposed in jinja2 ---------------------------------------- - -In meta.yaml, - -``{{ somevar }}`` - -And this loops over values - - -Exercise: try looping ---------------------- - -meta.yaml: - -.. code-block:: yaml - - package: - name: abc - version: 1.2.3 - - build: - skip: True # [skipvar] - -conda_build_config.yaml: - -.. code-block:: yaml - - skipvar: - - True - - False - - -.. nextslide:: - -meta.yaml: - -.. code-block:: yaml - - package: - name: abc - version: 1.2.3 - - requirements: - build: - - python {{ python }} - - run: - - python {{ python }} - -conda_build_config.yaml: - -.. code-block:: yaml - - python: - - 2.7 - - 3.6 - -.. nextslide:: - -meta.yaml: - -.. code-block:: yaml - - package: - name: abc - version: 1.2.3 - - requirements: - build: - - python - run: - - python - -.. nextslide:: - -conda_build_config.yaml: - -.. code-block:: yaml - - python: - - 2.7 - - 3.6 - - -Jinja2 functions ----------------- - -loading source data: - - ``load_setup_py_data`` - - ``load_file_regex`` - -Dynamic Pinning: - - ``pin_compatible`` - - ``pin_subpackage`` - -Compatibility Control: - - ``compiler`` - - ``cdt`` - - -Loading setup.py data ---------------------- - -.. code-block:: yaml - - {% set setup_data = load_setup_py_data() %} - - package: - name: abc - version: {{ setup_data[‘version’] }} - - -* Primarily a development recipe tool - release recipes specify version instead, and template source download link - -* Centralizing version info is very nice - see also ``versioneer``, ``setuptools_scm``, ``autover``, and many other auto-version tools - - -Loading arbitrary data ----------------------- - -.. code-block:: yaml - - {% set data = load_file_regex(load_file='meta.yaml', - regex_pattern='git_tag: ([\\d.]+)') %} - - package: - name: conda-build-test-get-regex-data - version: {{ data.group(1) }} - -* Useful when software provides version in some arbitrary file - -* Primarily a development recipe tool - release recipes specify version instead, and template source download link - - -Dynamic pinning ---------------- - -Use in meta.yaml, generally in requirements section: - -.. code-block:: yaml - - requirements: - host: - - numpy - run: - - {{ pin_compatible(‘numpy’) }} - -.. nextslide:: - -Use in meta.yaml, generally in requirements section: - -.. code-block:: yaml - - requirements: - host: - - numpy - run: - - {{ pin_compatible(‘numpy’) }} - - -* Pin run req based on what is present at build time - - -Dynamic pinning in practice ---------------------------- - -Used a lot with numpy: - -https://github.com/AnacondaRecipes/scikit-image-feedstock/blob/master/recipe/meta.yaml - - -Dynamic pinning within recipes ------------------------------- - -Refer to other outputs within the same recipe - - - When intradependencies exist - - - When shared libraries are consumed by other libraries - -https://github.com/AnacondaRecipes/aggregate/blob/master/clang/meta.yaml - - -Compilers ---------- - -Use in meta.yaml in requirements section: - -.. code-block:: yaml - - requirements: - build: - - {{ compiler(‘c’) }} - -* explicitly declare language needs - -* compiler packages can be actual compilers, or just activation scripts - -* Compiler packages utilize run_exports to add necessary runtime dependencies automatically - - -Why put compilers into Conda? ------------------------------ - -* Explicitly declaring language needs makes reproducing packages with recipe simpler -* Binary compatibility can be versioned and tracked better -* No longer care what the host OS used to build packages is -* Can still use system compilers - just need to give conda-build information on metadata about them. Opportunity for version check enforcement. - -``run_exports`` ---------------- - -“if you build and link against library abc, you need a runtime dependency on library abc” - -This is annoying to keep track of in recipes. - - -Upstream package “abc” (already built) - -.. code-block:: yaml - - - package: - name: abc - version: 1.0 - - build: - run_exports: - - abc 1.0.* - - -Downstream recipe - -.. code-block:: yaml - - requirements: - host: - - abc - - -Downstream package - -.. code-block:: yaml - - requirements: - host: - - abc 1.0 0 - run: - - abc 1.0.* - -.. nextslide:: - -.. image:: images/run_exports.png - - -.. nextslide:: - -* Add host or run dependencies for downstream packages that depend on upstream that specifies run_exports - -* Expresses idea that “if you build and link against library abc, you need a runtime dependency on library abc” - -* Simplifies version tracking - - -Requirements: run_exports -------------------------- - -.. image:: images/req_run_exports.png - - - - -Uploading packages: anaconda.org --------------------------------- - -* Sign-up: - - - ``https://anaconda.org/`` - -* Requirement: - - - ``conda install anaconda-client`` - -* CLI: anaconda upload path-to-package - -* conda-build auto-upload: - - - ``conda config --set anaconda_upload True`` - - - -Uploading packages: PyPI ------------------------- - - -* Sign-up: ``https://pypi.org/account/register/`` - -* Twine: ``pip install twine`` - -* Upload with twine to Test PyPI: - - - ``twine upload --repository-url https://test.pypi.org/legacy/ dist/* - -* Upload to PyPI: ``twine upload dist/*`` - - -Anaconda Survey ---------------- - -https://www.surveymonkey.com/r/conda - - - -Install - -Development install - -Copies package into site-packages - -Adds a .pth file to site-packages, pointed at package source root - -Used when creating conda packages - -Used when developing software locally - -Normal priority in sys.path - -End of sys.path (only found if nothing else comes first) - -https://grahamwideman.wikispaces.com/Python-+site-package+dirs+and+.pth+files - - - -What about setup.py? - -#!/usr/bin/env pythonfrom setuptools import setupsetup(name='Distutils', version='1.0', description='Python Distribution Utilities', author='Greg Ward', author_email='gward@python.net', url='https://www.python.org/sigs/distutils-sig/', packages=['distutils', 'distutils.command'], ) - - -https://docs.python.org/2/distutils/setupscript.html - -Lists of extensions to be compiled ----------------------------------- -What does setup.py do? - -Version & package metadata - -List of packages to include - -List of other files to include - -Lists of dependencies - - -#!/usr/bin/env pythonfrom setuptools import setupsetup(name='mypkg', version='1.0', # list folders, not files packages=['mypkg', 'mypkg.subpkg'], ) ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -Let’s write setup.py - - -creates eggs by default (people spend time fighting this later in the process) ------------------------------------------------------------------------------- -Setuptools - -Separate library (ships with Python by default, though) - -Adds entry point capability - -provides find_packages function (use with caution) - - -mypkg/ __init__.py subpkg/ __init__.py a.py -------------------------------------------------------------------- -Where does setup.py go? - -mypkg-src - -setup.py - - -New outer folder - -setup.py alongside package to be installed - -mypkg is what will get installed - -mypkg-src is what gets linked to by develop - -Go look in your site-packages folder ------------------------------------- -Try installing your package - -cd mypkg-src - -python setup.py install - -python -c “import mypkg.subpkg.a” - - - - - - -Making packages the easy way - -https://github.com/audreyr/cookiecutter - - - - - -conda install -c conda-forge cookiecutter - - -https://github.com/conda/cookiecutter-conda-python --------------------------------------------------- -Let’s make a project - -cookiecutter https://goo.gl/Jge1g8 - - - -That’s a shortened link to: - - -What did we get? ----------------- - -install_requires=['click'], ) ----------------------------------- -Adding requirements in setup.py - -#!/usr/bin/env pythonfrom distutils.core import setupsetup(name='mypkg', version='1.0', # list folders, not files packages=['mypkg', 'mypkg.subpkg'], - - -Donald Stufft (PyPA): Abstract vs. Concrete dependencies --------------------------------------------------------- -Requirements in requirements.txt - -common mistake - -requirements.txt often from pip freeze - -Pinned way too tightly. OK for env creation, bad for packaging. - - -https://caremad.io/posts/2013/07/setup-vs-requirement/ - - - -Requirements in setup.cfg (ideal) - -[metadata]name = my_packageversion = attr: src.VERSION[options]packages = find:install_requires = click - - -http://setuptools.readthedocs.io/en/latest/setuptools.html#configuring-setup-using-setup-cfg-files - -Parseable without execution, unlike setup.py - -Up next: producing redistributable artifacts --------------------------------------------- -Break time! - - -eggs (deprecated) ------------------ -Redistributable artifacts - -sdists - -wheels - -conda packages - - -python setup.py sdist ---------------------- -When/how to use an sdist - -Pure python (no build requirements) - - -Wheels vs. Conda packages -------------------------- - -Wheels - -Conda packages - -Employed by pip, blessed by PyPA - -Foundation of Anaconda ecosystem - -Used by any python installation - -Used by conda python installations - -Mostly specific to Python ecosystem - - General purpose (any ecosystem) - -Good mechanism for specifying range of python compatibility - - Primitive support for multiple python - - versions (noarch) - -Depends on static linking or other system package managers to provide core libraries - -Can bundle core system-level shared libraries as packages, and resolve dependencies - -Open-source, actively developedhttps://github.com/conda/conda-build --------------------------------------------------------------------- -Introducing conda-build - -Orchestrates environment creation, activation, and build/test processes - -Can build conda packages and/or wheels - -Separate project from conda, but very tightly integrated - - -version: 1.0 ------------- -Getting conda-build to work for you - -Input: meta.yaml files - -package: - - name: mypkg - - -conda build mypkg-src ---------------------- -Let’s use conda-build - -conda install conda-build - - -cleanup -------- -What happened? - -templates filled in, recipe interpreted - -build environment created (isolated) - -build script run - -new files in build environment bundled into package - -test environment created (isolated) - -tests run on new package - - -DIY ---- -Obtaining recipes - -Existing recipes (best) - -https://github.com/AnacondaRecipes - -https://github.com/conda-forge - -Skeletons from other repositories (PyPI, CRAN, CPAN, RPM) - - - - -Presently, ahead of conda-forge on use of conda-build 3 features ----------------------------------------------------------------- -AnacondaRecipes - -Official recipes that Anaconda uses for building packages - -Since Anaconda 5.0, forked from conda-forge recipes. - -Intended to be compatible with conda-forge long-term - - -Free builds on public CI services (TravisCI, CircleCI, Appveyor) ----------------------------------------------------------------- -Conda-forge - -Numfocus-affiliated community organization made up of volunteers - -One github repository per recipe - -Fine granularity over permissions - -Heavy use of automation for building, deploying, and updating recipes - - -Might work out of the box (should not assume automatic, though) ---------------------------------------------------------------- -Skeletons - -Read metadata from upstream repository - -Translate that into a recipe - - - -Will save you some boilerplate work - - -conda skeleton pypi --recursive pyinstrument --------------------------------------------- -conda skeleton pypi - -conda skeleton pypi - -conda skeleton pypi click - - - - -conda skeleton cran --recursive biwt ------------------------------------- -conda skeleton cran - -conda skeleton cran - -conda skeleton cran acs - - - - -version: 1.2.3 --------------- -When all else fails, write a recipe - -Only required section: - -package: - - name: abc - - -local path ----------- -Source types - -url - -git - -hg - -svn - - -https://conda.io/docs/user-guide/tasks/build-packages/define-metadata.html#source-section - -create patches with diff, git diff, or git format-patch -------------------------------------------------------- -Source patches - -patch files live alongside meta.yaml - - -https://conda.io/docs/user-guide/tasks/build-packages/define-metadata.html#source-section - -Exercise: let’s make a patch ----------------------------- -package: - - name: test-patch - - version: 1.2.3 - -source: - - url: https://zlib.net/zlib-1.2.11.tar.gz - -build: - - script: exit 1 - - -https://conda.io/docs/user-guide/tasks/build-packages/define-metadata.html#source-section - -Exercise: let’s make a patch ----------------------------- - -Builds that fail leave their build folders in place - -look in output for source tree in: ``*/conda-bld/test-patch_/work`` - -``cd there`` - - - -Exercise: let’s make a patch ----------------------------- - -.. code-block:: bash - - git init - - git add * - - git commit -am “init” - - edit file of choice - - git commit -m “changing file because …” - - git format-patch HEAD~1 - - -.. nextslide:: - -copy that patch back alongside ``meta.yaml`` - -modify meta.yaml to include the patch - - -Multiple sources ----------------- - -.. code-block:: yaml - -source: - - url: https://package1.com/a.tar.bz2 - folder: stuff - - url: https://package1.com/b.tar.bz2 - folder: stuff - patches: - - something.patch - - git_url: https://github.com/conda/conda-build - folder: conda-build - - -https://conda.io/docs/user-guide/tasks/build-packages/define-metadata.html#source-section - - -Build options -------------- - -number: - version reference of recipe (as opposed to version of source code) - -script: - quick build steps, avoid separate build.sh/bld.bat files - -skip: - skip building recipe on some platforms - -entry_points: - python code locations to create executables for - -run_exports: - add dependencies to downstream consumers to ensure compatibility - -https://conda.io/docs/user-guide/tasks/build-packages/define-metadata.html#build-section - -Requirements ------------- - -build - -host - -run - -host also useful for separating build tools from packaging environment ----------------------------------------------------------------------- - -Requirements: build vs. host - -Historically, only build - -Still fine to use only build - -host introduced for cross compiling - - -packages are bundled from host env, not build env -------------------------------------------------- - -Requirements: build vs. host - -If in doubt, put everything in host - -build is treated same as host for old-style recipes -(only build, no ``{{ compiler() }}``) - - -Post-build tests ----------------- - -Help ensure that you didn’t make a packaging mistake - -Ideally checks that necessary shared libraries are included as dependencies - - --------- -Post-build tests: dependencies ------------------------------- - -Describe dependencies that are required for the tests (but not for normal package usage) - -.. code-block:: yaml - - test: - - requires: - - - pytest - - -Post-build tests: test files ----------------------------- - -:: - - run_test.pl, run_test.py, run_test.r, run_test.lua - -Windows:: - - run_test.bat - - -Linux/Mac:: - - run_test.sh - - -Post-build tests ----------------- - -May have specific requirements - -May specify files that must be bundled for tests (source_files) - -imports: - language specific imports to try, to verify correct installation - -commands: - sequential shell-based commands to run (not OS-specific) - -https://conda.io/docs/user-guide/tasks/build-packages/define-metadata.html#test-section - -Import tests ------------- - -.. code-block:: yaml - - test: - imports: - - dateutil - - dateutil.rrule - - dateutil.parser - - dateutil.tz - -Test commands -------------- - -.. code-block:: yaml - - test: - commands: - - curl --version - - curl-config --features # [not win] - - curl-config --protocols # [not win] - - curl https://some.website.com - - -Outputs - more than one pkg per recipe --------------------------------------- - -package: - - name: some-split version: 1.0 - -outputs: - - - name: subpkg - - name: subpkg2 - -subpkg - -subpkg2 - - -.. nextslide:: - -Useful for consolidating related recipes that share (large) source - -Reduce update burden - -Reduce build time by keeping some parts of the build, while looping over other parts - -Also output different types of packages from one recipe (wheels) - - -https://conda.io/docs/user-guide/tasks/build-packages/define-metadata.html#outputs-section - - -Outputs rules -------------- - -list of dicts - -each list must have name or type key - -May use all entries from build, requirements, test, about sections - -May specify files to bundle either using globs or by running a script - - -https://conda.io/docs/user-guide/tasks/build-packages/define-metadata.html#outputs-section - -https://github.com/AnacondaRecipes/aggregate/blob/master/ctng-compilers-activation-feedstock/recipe/meta.yaml - -Outputs examples ----------------- - -https://github.com/AnacondaRecipes/curl-feedstock/blob/master/recipe/meta.yaml - -https://github.com/conda-forge/curl-feedstock/tree/master/recipe - -Exercise: split a package -------------------------- - -Curl is a library and an executable. Splitting them lets us clarify where Curl is only a build time dependency, and where it also needs to be a runtime dependency. - -Starting point: - - -https://conda.io/docs/user-guide/tasks/build-packages/define-metadata.html#outputs-section - -https://github.com/AnacondaRecipes/curl-feedstock/tree/master/recipe --------------------------------------------------------------------- -Exercise: split a package - -Solution: - - -https://conda.io/docs/user-guide/tasks/build-packages/define-metadata.html#outputs-section - -About section -------------- -https://conda.io/docs/user-guide/tasks/build-packages/define-metadata.html#about-section - - -Provide this stuff - -Conda-build’s notion of whether a recipe is “final” ---------------------------------------------------- -Extra section: free-for-all - -Used for external tools or state management - -No schema - -Conda-forge’s maintainer list - - -https://conda.io/docs/user-guide/tasks/build-packages/define-metadata.html#extra-section - -Advanced recipe tricks coming next ----------------------------------- -Break time! - - -namespace includes OS info, python info, and a few others ---------------------------------------------------------- -Conditional lines (selectors) - -some_content # [some expression] - - - -content inside [] is eval’ed - - -https://conda.io/docs/user-guide/tasks/build-packages/define-metadata.html#preprocessing-selectors - -Exercise: limit a recipe to only Linux --------------------------------------- - -https://conda.io/docs/user-guide/tasks/build-packages/define-metadata.html#preprocessing-selectors - - - -Intro to templating with Jinja2 - -Fill in information dynamically - -git tag info - -setup.py recipe data - -centralized version numbering - -string manipulation - - -Expressions in {{ }} are roughly python ---------------------------------------- -Jinja2 templating in meta.yaml - -Set variables: - -{% set somevar=”someval” %} - -Use variables: - -{{ somevar }} - - - - -Jinja2 conditionals - -Selectors are one line only. When you want to toggle a block, use jinja2: - -{%- if foo -%} - -toggled content - -on many lines - -{% endif %} - - -url: http://my.web/abc-1.2.3.tgz --------------------------------- -Exercise: use Jinja2 to reduce edits - -package: - - name: abc - - version: 1.2.3 - -source: - - -- 1.0 ------ -Variants: Jinja2 on steroids - -Matrix specification in yaml files - -somevar: - - - 1.0 - - - 2.0 - -anothervar: - - -And this loops over values --------------------------- -All variant variables exposed in jinja2 - -In meta.yaml, - - - -{{ somevar }} - - - - -skip: True # [skipvar] ----------------------- -Exercise: try looping - -meta.yaml: - -package: - - name: abc - - version: 1.2.3 - -build: - - -conda_build_config.yaml: - -skipvar: - - - True - -- False - -- python {{ python }} ---------------------- -Exercise: try looping - -meta.yaml: - -package: - - name: abc - - version: 1.2.3 - -requirements: - - build: - - - python {{ python }} - - run: - - -conda_build_config.yaml: - -python: - - - 2.7 - -- 3.6 - -- python --------- -Exercise: try looping - -meta.yaml: - -package: - - name: abc - - version: 1.2.3 - -requirements: - - build: - - - python - - run: - - -conda_build_config.yaml: - -python: - - - 2.7 - -- 3.6 - -cdt ---- -Jinja2 functions - -load_setup_py_data - -load_file_regex - -pin_compatible - -pin_subpackage - -compiler - - -Dynamic pinning - -Loading source data - -Compatibility control - -Loading setup.py data ---------------------- - -{% set setup_data = load_setup_py_data() %} - - - -package: - - name: abc - - version: {{ setup_data[‘version’] }} - - - - - -Primarily a development recipe tool - release recipes specify version instead, and template source download link - -Centralizing version info is very nice - see also versioneer, setuptools_scm, autover, and many other auto-version tools - -Primarily a development recipe tool - release recipes specify version instead, and template source download link ----------------------------------------------------------------------------------------------------------------- -Loading arbitrary data - -{% set data = load_file_regex(load_file='meta.yaml', regex_pattern='git_tag: ([\\d.]+)') %} - -package: - - name: conda-build-test-get-regex-data - - version: {{ data.group(1) }} - -Useful when software provides version in some arbitrary file - - -- {{ pin_compatible(‘numpy’) }} -------------------------------- -Dynamic pinning - -Use in meta.yaml, generally in requirements section: - -requirements: - - host: - - - numpy - - run: - - -- {{ pin_compatible(‘numpy’) }} -------------------------------- -Dynamic pinning - -Use in meta.yaml, generally in requirements section: - -requirements: - - host: - - - numpy - - run: - - -Pin run req based on what is present at build time - -https://github.com/AnacondaRecipes/scikit-image-feedstock/blob/master/recipe/meta.yaml --------------------------------------------------------------------------------------- -Dynamic pinning in practice - -Used a lot with numpy: - - - - -Dynamic pinning within recipes - -Refer to other outputs within the same recipe - -when intradependencies exist - -when shared libraries are consumed by other libraries - -https://github.com/AnacondaRecipes/aggregate/blob/master/clang/meta.yaml - - -Compiler packages utilize run_exports to add necessary runtime dependencies automatically ------------------------------------------------------------------------------------------ -Compilers - -Use in meta.yaml in requirements section: - -requirements: build: - {{ compiler(‘c’) }} - -explicitly declare language needs - -compiler packages can be actual compilers, or just activation scripts - - -run_exports ------------ - -package: - - name: abc - - version: 1.0 - - - -build: - - run_exports: - - - abc 1.0.* - -Upstream package “abc” (already built) - -Downstream recipe - -requirements: - - host: - - - abc - - - -requirements: - - host: - - - abc 1.0 0 - - run: - - - abc 1.0.* - - - -Downstream package - -Simplifies version tracking ---------------------------- -run_exports - -Add host or run dependencies for downstream packages that depend on upstream that specifies run_exports - -expresses idea that “if you build and link against library abc, you need a runtime dependency on library abc” - - -Requirements: run_exports -------------------------- - -build - -host - -run - -“Strong” run_exports - -“Weak” run_exports - -Uploading packages: anaconda.org --------------------------------- - -Uploading packages: PyPI ------------------------- - -https://www.surveymonkey.com/r/conda ------------------------------------- -Anaconda Survey - diff --git a/test_recipes/bitarray/meta.yaml b/test_recipes/bitarray/meta.yaml deleted file mode 100644 index e0970a5..0000000 --- a/test_recipes/bitarray/meta.yaml +++ /dev/null @@ -1,48 +0,0 @@ -{% set name = "bitarray" %} -{% set version = "0.8.1" %} -{% set sha256 = "7da501356e48a83c61f479393681c1bc4b94e5a34ace7e08cb29e7dd9290ab18" %} - -package: - name: {{ name|lower }} - version: {{ version }} - -source: - fn: {{ name }}-{{ version }}.tar.gz - url: https://pypi.io/packages/source/{{ name[0] }}/{{ name }}/{{ name }}-{{ version }}.tar.gz - sha256: {{ sha256 }} - -build: - number: 1 - script: python setup.py install --single-version-externally-managed --record record.txt - -requirements: - host: - - python - - setuptools - - build: - - {{ compiler('c') }} - - run: - - python - -test: - imports: - - bitarray - -about: - home: https://github.com/ilanschnell/bitarray - license: PSF - license_file: LICENSE - summary: 'efficient arrays of booleans -- C extension' - description: | - Bitarray provides an object type which efficiently represents an array of - booleans. Bitarrays are sequence types that behave very similarly - to usual lists. All functionality is implemented in C. - doc_url: https://pypi.python.org/pypi/bitarray/0.8.1 - doc_source_url: https://github.com/ilanschnell/bitarray/blob/master/README.rst - dev_url: https://github.com/ilanschnell/bitarray - -extra: - recipe-maintainers: - - nehaljwani diff --git a/test_recipes/bitarray/run_test.py b/test_recipes/bitarray/run_test.py deleted file mode 100644 index 6be48ce..0000000 --- a/test_recipes/bitarray/run_test.py +++ /dev/null @@ -1,3 +0,0 @@ -import bitarray - -assert bitarray.test().wasSuccessful() diff --git a/test_recipes/conda_build_config.yaml b/test_recipes/conda_build_config.yaml deleted file mode 100644 index 8cac22a..0000000 --- a/test_recipes/conda_build_config.yaml +++ /dev/null @@ -1,14 +0,0 @@ -c_compiler: - - vs2017 # [win] -cxx_compiler: - - vs2017 # [win] -python: - - 3.6 -vc: - -14 # [win] -zip_keys: - - # [win] - - vc # [win] - - c_compiler # [win] - - cxx_compiler # [win] - - python # [win] diff --git a/test_recipes/hello-cython/CMakeLists.txt b/test_recipes/hello-cython/CMakeLists.txt deleted file mode 100644 index f7219e6..0000000 --- a/test_recipes/hello-cython/CMakeLists.txt +++ /dev/null @@ -1,10 +0,0 @@ -cmake_minimum_required(VERSION 3.5.0) - -project(hello_cython) - -find_package(PythonInterp REQUIRED) -find_package(PythonLibs REQUIRED) -find_package(PythonExtensions REQUIRED) -find_package(Cython REQUIRED) - -add_subdirectory(hello) diff --git a/test_recipes/hello-cython/hello/CMakeLists.txt b/test_recipes/hello-cython/hello/CMakeLists.txt deleted file mode 100644 index 853fb89..0000000 --- a/test_recipes/hello-cython/hello/CMakeLists.txt +++ /dev/null @@ -1,6 +0,0 @@ - -add_cython_target(_hello CXX) -add_library(_hello MODULE ${_hello}) -python_extension_module(_hello) - -install(TARGETS _hello LIBRARY DESTINATION hello) diff --git a/test_recipes/hello-cython/hello/__init__.py b/test_recipes/hello-cython/hello/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/test_recipes/hello-cython/hello/__main__.py b/test_recipes/hello-cython/hello/__main__.py deleted file mode 100644 index 59019cf..0000000 --- a/test_recipes/hello-cython/hello/__main__.py +++ /dev/null @@ -1,4 +0,0 @@ - -if __name__ == "__main__": - from . import _hello as hello - hello.hello("World") diff --git a/test_recipes/hello-cython/hello/_hello.pyx b/test_recipes/hello-cython/hello/_hello.pyx deleted file mode 100644 index 1ae0086..0000000 --- a/test_recipes/hello-cython/hello/_hello.pyx +++ /dev/null @@ -1,9 +0,0 @@ - -cpdef void hello(str strArg): - "Prints back 'Hello ', for example example: hello.hello('you')" - print("Hello, {}! :)".format(strArg)) - -cpdef long size(): - "Returns elevation of Nevado Sajama." - return 21463L - diff --git a/test_recipes/hello-cython/setup.py b/test_recipes/hello-cython/setup.py deleted file mode 100644 index 1618a2d..0000000 --- a/test_recipes/hello-cython/setup.py +++ /dev/null @@ -1,11 +0,0 @@ -from skbuild import setup - -setup( - name="hello-cython", - version="1.2.3", - description="a minimal example package (cython version)", - author='The scikit-build team', - license="MIT", - packages=['hello_cython'], - package_dir={'hello_cython': 'hello'}, -)