-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.html
887 lines (789 loc) · 38.1 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<title>Software Development for Engineering Research - Packaging</title>
<meta name="description" content="
Lecture on packaging and distribution for ME 599: Software Development for Engineering Research">
<meta name="author" content="Kyle Niemeyer">
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
<link rel="stylesheet" href="dist/reset.css">
<link rel="stylesheet" href="dist/reveal.css">
<link rel="stylesheet" href="dist/theme/simple.css" id="theme">
<!-- For syntax highlighting -->
<link rel="stylesheet" href="plugin/highlight/monokai.css">
<!-- If the query includes 'print-pdf', include the PDF print sheet -->
<script>
if( window.location.search.match( /print-pdf/gi ) ) {
var link = document.createElement( 'link' );
link.rel = 'stylesheet';
link.type = 'text/css';
link.href = 'css/print/pdf.css';
document.getElementsByTagName( 'head' )[0].appendChild( link );
}
</script>
<!--[if lt IE 9]>
<script src="lib/js/html5shiv.js"></script>
<![endif]-->
</head>
<body>
<div class="reveal">
<!-- Any section element inside of this container is displayed as a slide -->
<div class="slides">
<section>
<h2>Distributing Packages / Deploying</h2>
<h3>Software Development for Engineering Research</h3>
<br/>
<h3>Kyle Niemeyer. 26 January 2022</h3>
<h3>ME 599, Corvallis, OR</h3>
</section>
<section>
<section data-markdown>
<textarea data-template>
## Next, a bit about `main()` and `__main__`
- `__name__ == __main__`, when the file is executed from the command line
- `__name__ == ` module name, when imported
- use `main()` as name of entry point function to overall package (this is convention)
- Define most logic in functions outside `main()` and call those
</textarea>
</section>
<section>
<div style="font-size:22px">
<pre><code data-trim class="python">
from time import sleep
print("This is my file to demonstrate best practices.")
def process_data(data):
print("Beginning data processing...")
modified_data = data + " that has been modified"
sleep(3)
print("Data processing finished.")
return modified_data
def read_data_from_web():
print("Reading data from the Web")
data = "Data from the web"
return data
def write_data_to_database(data):
print("Writing data to a database")
print(data)
def main():
data = read_data_from_web()
modified_data = process_data(data)
write_data_to_database(modified_data)
if __name__ == "__main__":
main()
</code></pre>
</div>
</section>
<section data-markdown>
<textarea data-template>
## More reading:
https://realpython.com/python-main-function
</textarea>
</section>
</section>
<section>
<section data-markdown>
<textarea data-template>
## Today: How to package and distribute your software
</textarea>
</section>
<section>
<p class="fragment">
We've talked about version-controlling, licensing,
structuring, testing, and object-orienting your software.
</p>
<p class="fragment">
What about actually deploying it so that others can install and use it?
</p>
<p class="fragment">
Note: this can be hard, especially when considering all the various systems
you may want/need to support.
</p>
</section>
<section>
<h2>First step: package the software.</h2>
<br>
<p class="fragment">
This means creating a file distributable to a wider audience,
that can install your package on their system.
</p>
<p class="fragment">
Depends somewhat on the package manager they use (e.g., pip/pipenv, conda)
</p>
</section>
<section>
<h2>Package management options</h2>
<br>
<ul>
<li class="fragment">
Source-based: link to code. Good for dynamic languages, less for compiled.
</li>
<li class="fragment">
Binary: popular for both dynamic and compiled. Create packages for various architectures/systems.
</li>
<li class="fragment">
Virtualization: package both software and environment.
</li>
</ul>
</section>
<section>
<h2>Comment on Python package management</h2>
<br>
<p class="fragment">
Unfortanately, managing packages in Python is an ever-evolving environment.
</p>
<p class="fragment">
pip and conda are currently the most-used, but now there is pipenv
</p>
<p class="fragment">
Do the best you can! Fortunately the basics should be compatible with future systems.
</p>
</section>
</section>
<section>
<section>
<h2> Python: <code>pip</code> and PyPI </h2>
<br>
<ul>
<li class="fragment">
<code>pip</code> can be used to install Python packages from source or from <a href="https://pypi.org">PyPI</a>
</li>
<li class="fragment">
<a href="https://realpython.com/pipenv-guide/"><code>pipenv</code></a> is a newer
replacement for pip that allows environments and handles dependenies better
</li>
<li class="fragment">
We will tell <code>pip</code> how to install your package by creating a <code>setup.py</code> (or <code>pyproject.toml</code>)
file for the <code>setuptools</code> package to use.
</li>
<li class="fragment">
<code>setup.py</code> / <code>pyproject.toml</code> goes at the same level as your package's source code directory.
</li>
</ul>
</section>
<section>
<div style="font-size:35px">
<pre><code data-trim class="text">
setup.py
/compphys
|- __init__.py
|- _version.py
|- constants.py
|- physics.py
/more
|- __init__.py
|- morephysics.py
|- evenmorephysics.py
/assets
|- data.txt
|- orphan.py
/tests
|- test_physics.py
|- test_morephysics.py
...
</code></pre>
</div>
</section>
<section>
<p>
<code>setup.py</code> imports and calls <code>setup()</code> function, which can both install
a package locally and make/upload to PyPI
</p>
<br>
<ul>
<li class="fragment">
<code>pip</code> can be used to install Python packages from source or from <a href="https://pypi.org">PyPI</a>
</li>
<li class="fragment">
We will tell <code>pip</code> how to install your package by creating a <code>setup.py</code>
file for the <code>setuptools</code> package to use.
</li>
<li class="fragment">
<code>setup.py</code> goes at the same level as your package's source code directory.
</li>
</ul>
</section>
<section>
<div style="font-size:25px">
<pre><code data-trim class="python stretch">
try:
from setuptools import setup, find_packages
except ImportError:
from distutils.core import setup
setup(
name='compphys',
version='0.1.0',
description='Effective Computation in Physics',
author='Anthony Scopatz and Kathryn D. Huff',
author_email='[email protected]',
url='http://physics.codes',
classifiers=[
'License :: OSI Approved :: BSD License',
'Intended Audience :: Developers',
'Intended Audience :: Science/Research',
'Natural Language :: English',
'Programming Language :: Python :: 3',
],
license='BSD-3-Clause',
python_requires='>=3',
zip_safe=False,
packages=['compphys', 'compphys.more', 'compphys.tests'],
# or find automatically:
package=find_packages(),
package_dir={
'compphys': 'compphys',
'compphys.more': 'compphys/more',
'compphys.tests': 'compphys/tests',
},
include_package_data=True,
# or you can specify explicitly:
package_data={
'compphys': ['assets/*.txt']
},
)
</code></pre>
</div>
</section>
<section>
<p class="fragment">
Better: have <code>setup.py</code> copy in README, version information from
<code>_version.py</code> file in your package, and include dependency information.
</p>
<p class="fragment">
Add a <code>setup.cfg</code> file with some additional configuration options
</p>
<p class="fragment">
Add a <a href="https://keepachangelog.com/"<code>CHANGELOG</code> file</a> to describe how your
code changes with each version.
</p>
<p class="fragment">
Add a <code>MANIFEST.in</code> file to tell PyPI to bring other files.
</p>
</section>
<section>
<div style="font-size:14px">
<pre><code data-trim class="python stretch">
from codecs import open
from os import path
import sys
here = path.abspath(path.dirname(__file__))
with open(path.join(here, 'compphys', '_version.py')) as version_file:
exec(version_file.read())
with open(path.join(here, 'README.md')) as readme_file:
readme = readme_file.read()
with open(path.join(here, 'CHANGELOG.md')) as changelog_file:
changelog = changelog_file.read()
desc = readme + '\n\n' + changelog
try:
import pypandoc
long_description = pypandoc.convert_text(desc, 'rst', format='md')
with open(path.join(here, 'README.rst'), 'w') as rst_readme:
rst_readme.write(long_description)
except (ImportError, OSError, IOError):
long_description = desc
install_requires = [
'numpy',
]
tests_require = [
'pytest',
'pytest-cov',
]
needs_pytest = {'pytest', 'test', 'ptr'}.intersection(sys.argv)
setup_requires = ['pytest-runner'] if needs_pytest else []
setup(
name='compphys',
version=__version__,
description='Effective Computation in Physics',
long_description=long_description,
author='Anthony Scopatz and Kathryn D. Huff',
author_email='[email protected]',
url='http://physics.codes',
classifiers=[
'License :: OSI Approved :: BSD License',
'Intended Audience :: Developers',
'Intended Audience :: Science/Research',
'Natural Language :: English',
'Programming Language :: Python :: 3',
],
license='BSD-3-Clause',
install_requires=install_requires,
tests_require=tests_require,
python_requires='>=3',
setup_requires=setup_requires,
zip_safe=False,
packages=['compphys', 'compphys.more', 'compphys.tests'],
package_dir={
'compphys': 'compphys',
'compphys.more': 'compphys/more',
'compphys.tests': 'compphys/tests',
},
include_package_data=True,
)
</code></pre>
</div>
</section>
<section>
<h3>Contents of <code>setup.cfg</code>:</h3>
<br>
<pre><code data-trim class="text">
[metadata]
license_file = LICENSE
[aliases]
test=pytest
[tool:pytest]
addopts = -vv --cov=./
filterwarnings =
ignore::ResourceWarning
</code></pre>
</section>
<section>
<h3>Contents of <code>MANIFEST.in:</code>:</h3>
<br>
<pre><code data-trim class="markdown">
include LICENSE
include AUTHORS.md
include CHANGELOG.md
include CONTRIBUTING.md
include compphys/tests/*.txt
</code></pre>
</section>
<section>
<ol>
<li class="fragment">
Install the package from source: <code>python setup.py install</code>
</li>
<li class="fragment">
Create a source-only ZIP file: <code>python setup.py sdist</code>
</li>
<li class="fragment">
Create an <a href="https://pypi.org/account/register/">account on PyPI</a>
</li>
<li class="fragment">
Upload: <code>twine upload dist/*</code>
</li>
<li class="fragment">
Subsequent versions: increase the version number (tip: use Semantic Versioning)
</li>
<ol>
</section>
<section>
<h2>New: pyproject.toml</h2>
<br>
<ul>
<li class="fragment">
There is a newer standard for specifying project information: <code>pyproject.toml</code>
</li>
<li class="fragment">
This is intended to replace <code>setup.py</code> and related files for <code>pip</code>
</li>
<li class="fragment">
This is still evolving, and you might choose to adopt this approach, but it is currently not required (I think)
</li>
</ul>
</section>
<section>
<h3>Contents of basic <code>pyproject.toml</code>:</h3>
<br>
<pre><code data-trim class="text">
[build-system]
requires = [
"setuptools>=42", "wheel"
]
build-backend = "setuptools.build_meta"
</code></pre>
</section>
<section data-markdown>
<textarea data-template>
Read more at <https://packaging.python.org/en/latest/tutorials/packaging-projects/>
</textarea>
</section>
</section>
<section>
<section>
<p>
<a href="https://semver.org">Semantic Versioning</a>: Given a version number MAJOR.MINOR.PATCH, increment the:
</p>
<ul class="fragment">
<li>MAJOR version when you make incompatible API changes,</li>
<li>MINOR version when you add functionality in a backwards-compatible manner, and</li>
<li>PATCH version when you make backwards-compatible bug fixes.</li>
</ul>
<p class="fragment">
To start: set initial development release at 0.1.0 and increment minor version for subsequent releases.
</p>
</section>
<section>
<h3>Contents of <code>_version.py</code>:</h3>
<br>
<pre><code data-trim class="python">
__version_info__ = (0, 4, 2, 'a1')
__version__ = '.'.join(map(str, __version_info__[:3]))
if len(__version_info__) == 4:
__version__ += __version_info__[-1]
</code></pre>
</section>
<section>
<h3>Contents of <code>CHANGELOG.md</code>:</h3>
<br>
<div style="font-size:20px">
<pre><code data-trim class="markdown">
# Changelog
All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
## [Unreleased]
## [0.1.0] - 2015-10-06
### Added
- Answer "Should you ever rewrite a change log?".
### Changed
- Improve argument against commit logs.
- Start following [SemVer](http://semver.org) properly.
## [0.0.8] - 2015-02-17
### Changed
- Update year to match in every README example.
- Reluctantly stop making fun of Brits only, since most of the world
writes dates in a strange way.
### Fixed
- Fix typos in recent README changes.
- Update outdated unreleased diff link.
## [0.0.7] - 2015-02-16
### Added
- Link, and make it obvious that date format is ISO 8601.
### Changed
- Clarified the section on "Is there a standard change log format?".
### Fixed
- Fix Markdown links to tag comparison URL with footnote-style links.
## [0.0.6] - 2014-12-12
### Added
- README section on "yanked" releases.
## [0.0.5] - 2014-08-09
### Added
- Markdown links to version tags on release headings.
- Unreleased section to gather unreleased changes and encourage note
keeping prior to releases.
## [0.0.4] - 2014-08-09
### Added
- Better explanation of the difference between the file ("CHANGELOG")
and its function "the change log".
### Changed
- Refer to a "change log" instead of a "CHANGELOG" throughout the site
to differentiate between the file and the purpose of the file — the
logging of changes.
### Removed
- Remove empty sections from CHANGELOG, they occupy too much space and
create too much noise in the file. People will have to assume that the
missing sections were intentionally left out because they contained no
notable changes.
## [0.0.3] - 2014-08-09
### Added
- "Why should I care?" section mentioning The Changelog podcast.
## [0.0.2] - 2014-07-10
### Added
- Explanation of the recommended reverse chronological release ordering.
## 0.0.1 - 2014-05-31
### Added
- This CHANGELOG file to hopefully serve as an evolving example of a
standardized open source project CHANGELOG.
- CNAME file to enable GitHub Pages custom domain
- README now contains answers to common questions about CHANGELOGs
- Good examples and basic guidelines, including proper date formatting.
- Counter-examples: "What makes unicorns cry?"
[Unreleased]: https://github.com/olivierlacan/keep-a-changelog/compare/v1.0.0...HEAD
[0.1.0]: https://github.com/olivierlacan/keep-a-changelog/compare/v0.0.8...v0.1.0
[0.0.8]: https://github.com/olivierlacan/keep-a-changelog/compare/v0.0.7...v0.0.8
[0.0.7]: https://github.com/olivierlacan/keep-a-changelog/compare/v0.0.6...v0.0.7
[0.0.6]: https://github.com/olivierlacan/keep-a-changelog/compare/v0.0.5...v0.0.6
[0.0.5]: https://github.com/olivierlacan/keep-a-changelog/compare/v0.0.4...v0.0.5
[0.0.4]: https://github.com/olivierlacan/keep-a-changelog/compare/v0.0.3...v0.0.4
[0.0.3]: https://github.com/olivierlacan/keep-a-changelog/compare/v0.0.2...v0.0.3
[0.0.2]: https://github.com/olivierlacan/keep-a-changelog/compare/v0.0.1...v0.0.2
</code></pre>
</div>
</section>
</section>
<section>
<section>
<h3> <code>conda</code> </h3>
<br>
<ul>
<li class="fragment">
<code>pip</code> is great for pure Python source codes, but many research codes use multiple languages
including compiled code.
</li>
<li class="fragment">
<a href="https://conda.io/docs/">Conda:</a> cross-platform binary manager designed for deploying research software.
</li>
<li class="fragment">
Handles multilanguage and non-Python code, runs on all operating systems, and runs in user's home
space—it does not try to install on the system.
</li>
</ul>
</section>
<section>
<h3> <code>conda</code> </h3>
<br>
<ul>
<li class="fragment">
Fastest way to install: <a href="https://conda.io/miniconda.html">Miniconda distribution</a>
</li>
<li class="fragment">
By default, searches <a href="https://anaconda.org">Anaconda Cloud</a>, but you can add additional
channels to search for packages (even your own!)
</li>
<li class="fragment">
Recommendation: add conda-forge channel via <code>conda config --add channels conda-forge</code>
</li>
</ul>
</section>
<section>
<h3> Build a conda package (on your system) </h3>
<br>
<ol>
<li class="fragment">
Create an <a href="https://docs.anaconda.com/anaconda-cloud/user-guide/tasks/work-with-accounts.html#cloud-accounts-create">Anaconda cloud</a>
account, install the client, and login:
<pre><code data-trim>
conda install anaconda-client
anaconda login
</code></pre>
</li>
<li class="fragment"> Install <code>conda-build</code>:
<pre><code data-trim>
conda install conda-build
conda config --set anaconda_upload no
</code></pre>
</li>
<li class="fragment">
Create a new directory <code>conda.recipe</code> and in it create the file <code>meta.yaml</code>:
</li>
</ol>
</section>
<section>
<div style="font-size:20px">
<pre><code data-trim class="yaml stretch">
{% set data = load_setup_py_data() %}
package:
name: compphys
version: {{ data['version'] }}
source:
path: ..
build:
number: 0
script: python setup.py install --single-version-externally-managed --record=record.txt
requirements:
build:
- python >= 3
- setuptools
run:
- python
- numpy
test:
imports:
- compphys
requires:
- pytest
- pytest-cov
commands:
- pytest -vv --pyargs compphys
about:
home: data['url']
license: BSD 3-Clause
license_file: LICENSE
license_family: BSD
summary: data['description']
description: data['long_description']
dev_url: data['url']
</code></pre>
</div>
</section>
<section>
<ol start="4">
<li class="fragment">
Build the package: <code>conda build conda.recipe</code>
</li>
<li class="fragment">
Upload your package to Anaconda cloud:
<pre><code data-trim>
anaconda upload $HOME/miniconda/conda-bld/*/compphys*.tar.bz2
</code></pre>
</li>
<li class="fragment">
Go see your package at <a href="https://anaconda.org/[username]/compphys"><code>https://anaconda.org/[username]/compphys</code></a>!
</li>
<li class="fragment">
Others can install your package using <code>conda install -c [username] compphys</code>
</li>
</ol>
</section>
</section>
<section>
<p>
Now you have three ways of making your software installable by people:
</p>
<ul>
<li class="fragment">
Create <code>setup.py</code> to allow others to download your repo and install manually (at minimum, do this).
</li>
<li class="fragment">
Upload your package to PyPI, making it easily installable using <code>pip</code>.
</li>
<li class="fragment">
Create and upload a <code>conda</code> package, easily installable via your personal channel.
</li>
</ul>
</section>
<section>
<section>
<h3>Advanced deploying</h3>
<p class="fragment">
Although at this point it may be sufficient to manually build and deploy packages for pip and conda,
you can also use GitHub Actions or Travis CI to do this for you.
</p>
<img class="fragment" src="https://media.giphy.com/media/ChzfTLSi47FYc/giphy.gif" height="300" alt="Matrix Whoa gif">
</section>
<section>
<p class="fragment">
Main idea: when you tag a release using Git (e.g., <code>git tag -a v0.1.1 -m 'v0.1.1'</code>),
GitHub Actions will run your tests, and if successful build and deploy to PyPI and/or Anaconda.
</p>
<img class="fragment" src="https://media.giphy.com/media/CruIeCnUaWqJy/giphy.gif" height="300" alt="Anna Kendrick I know gif">
</section>
<section>
<div style="font-size:24px">
<pre><code data-trim class="yaml stretch">
name: Python package
on:
push:
# Build on tags that look like releases
tags:
- v*
# Build when main is pushed to
branches:
- main
pull_request:
# Build when a pull request targets main
branches:
- main
jobs:
build:
runs-on: ${{ matrix.os }}
continue-on-error: ${{ matrix.experimental }}
strategy:
matrix:
python-version: [3.7, 3.8]
os: [ubuntu-latest, macos-latest, windows-latest]
experimental: [false]
fail-fast: false
steps:
- name: Check out the repository
uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip setuptools wheel
python -m pip install tox tox-gh-actions tox-venv
- name: Test with tox
run: tox -v
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v1
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: ./coverage.xml
</code></pre>
</div>
</section>
<section>
<div style="font-size:24px">
<pre><code data-trim class="yaml stretch">
conda-build-and-upload:
runs-on: ubuntu-latest
defaults:
run:
shell: bash -l {0}
steps:
- uses: actions/checkout@v2
- uses: conda-incubator/setup-miniconda@77b16ed746da28724c61e1f1ad23395a4b695ef5
with:
auto-update-conda: true
conda-build-version: 3.21
auto-activate-base: true
activate-environment: ""
show-channel-urls: true
miniforge-version: latest
- name: Install conda-build dependencies
run: conda install -q anaconda-client conda-verify ripgrep
- name: Run conda build
run: conda build conda.recipe
- name: Upload package to anaconda.org
run: |
anaconda -t ${{ secrets.ANACONDA_TOKEN }} upload $CONDA/conda-bld/*/package*.tar.bz2
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags')
pypi-build-and-upload:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: 3.8
- name: Install build dependencies
run: python -m pip install --upgrade pip setuptools wheel pep517
- name: Build the source and binary distributions
run: python -m pep517.build --source --binary --out-dir dist/ .
- name: Publish a Python distribution to PyPI
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags')
uses: pypa/[email protected]
with:
user: __token__
password: ${{ secrets.PYPI_PASSWORD }}
</code></pre>
</div>
</section>
<section>
<p>Required steps: generate those secure strings for passwords/upload tokens</p>
<br>
<div style="font-size:35px">
<ul>
<li class="fragment">
<strong>Anaconda:</strong> go to your <a href="https://anaconda.org/">Anaconda.org</a> account settings,
and in Access generate an API token. Then, in your <a href="https://travis-ci.org/">Travis CI</a>
account, go to the repo in question, and create an environment variable with the name <code>ANACONDA_TOKEN</code>.
Add the value of the API token you just created. Copy the secure string into <code>meta.yaml</code>.
</li>
<li class="fragment">
<strong><a href="https://docs.travis-ci.com/user/deployment/pypi/">PyPI:</a></strong>
install <a href="https://github.com/travis-ci/travis.rb#installation">Travis CI command line utility</a>, then
use command <code>travis encrypt --add deploy.password</code> to generate the <code>secure</code> string
for <code>meta.yaml</code>.
</li>
</ul>
</div>
</section>
</section>
<section>
<p> Next: add <code>setup.py</code> or <code>pyproject.toml</code>
at minimum to your projects, and consider making available via
PyPI and/or Anaconda!
</section>
</div>
</div>
<script src="dist/reveal.js"></script>
<script src="plugin/notes/notes.js"></script>
<script src="plugin/markdown/markdown.js"></script>
<script src="plugin/highlight/highlight.js"></script>
<script>
// More info about initialization & config:
// - https://revealjs.com/initialization/
// - https://revealjs.com/config/
Reveal.initialize({
hash: true,
// Learn about plugins: https://revealjs.com/plugins/
plugins: [ RevealMarkdown, RevealHighlight, RevealNotes ]
});
</script>
</body>
</html>