mirror of
https://github.com/wassname/catalyst.git
synced 2026-09-12 12:12:04 +08:00
DEV: add conda_build_matrix.py to help upload packages
This commit is contained in:
@@ -169,6 +169,28 @@ Once we are happy, push the updated docs to the GitHub ``gh-pages`` branch.
|
|||||||
|
|
||||||
`zipline.io <http://www.zipline.io/index.html>`__ will update in a few moments.
|
`zipline.io <http://www.zipline.io/index.html>`__ will update in a few moments.
|
||||||
|
|
||||||
|
Uploading conda packages
|
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
To build the conda packages for zipline run:
|
||||||
|
|
||||||
|
.. code-block:: bash
|
||||||
|
|
||||||
|
$ python etc/conda_build_matrix.py
|
||||||
|
|
||||||
|
If all of the builds succeed, then this will not print anything and exit with
|
||||||
|
``EXIT_SUCCESS``. If there are build issues, we must address them and decide
|
||||||
|
what to do.
|
||||||
|
|
||||||
|
Once all of the builds in the matrix pass, we can upload them to anaconda with:
|
||||||
|
|
||||||
|
.. code-block:: bash
|
||||||
|
|
||||||
|
$ python etc/conda_build_matrix.py --upload
|
||||||
|
|
||||||
|
If you would like to test this command by uploading to a different user, this
|
||||||
|
may be specified with the ``--user`` flag.
|
||||||
|
|
||||||
Next Commit
|
Next Commit
|
||||||
~~~~~~~~~~~
|
~~~~~~~~~~~
|
||||||
|
|
||||||
|
|||||||
@@ -1,15 +1,95 @@
|
|||||||
from itertools import product
|
from itertools import product
|
||||||
import os
|
import os
|
||||||
|
import subprocess
|
||||||
|
|
||||||
|
import click
|
||||||
|
|
||||||
py_versions = ('2.7', '3.4')
|
py_versions = ('2.7', '3.4')
|
||||||
numpy_versions = ('1.9', '1.10')
|
npy_versions = ('1.9', '1.10')
|
||||||
|
zipline_path = os.path.join(
|
||||||
|
os.path.dirname(__file__),
|
||||||
|
'..',
|
||||||
|
'conda',
|
||||||
|
'zipline',
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def mkargs(py_version, npy_version, output=False):
|
||||||
for pair in product(py_versions, numpy_versions):
|
return {
|
||||||
os.system('conda build conda/zipline -c quantopian '
|
'args': [
|
||||||
'--python=%s --numpy=%s' % pair)
|
'conda',
|
||||||
|
'build',
|
||||||
|
zipline_path,
|
||||||
|
'-c', 'quantopian',
|
||||||
|
'--python=%s' % py_version,
|
||||||
|
'--numpy=%s' % npy_version,
|
||||||
|
] + (['--output'] if output else []),
|
||||||
|
'stdout': subprocess.PIPE,
|
||||||
|
'stderr': subprocess.PIPE,
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@click.command()
|
||||||
|
@click.option(
|
||||||
|
'--upload',
|
||||||
|
is_flag=True,
|
||||||
|
default=False,
|
||||||
|
help='Upload packages after building',
|
||||||
|
)
|
||||||
|
@click.option(
|
||||||
|
'--upload-only',
|
||||||
|
is_flag=True,
|
||||||
|
default=False,
|
||||||
|
help='Upload the last built packages without rebuilding.',
|
||||||
|
)
|
||||||
|
@click.option(
|
||||||
|
'--user',
|
||||||
|
default='quantopian',
|
||||||
|
help='The anaconda account to upload to.',
|
||||||
|
)
|
||||||
|
def main(upload, upload_only, user):
|
||||||
|
if upload_only:
|
||||||
|
# if you are only uploading you shouldn't need to specify both flags
|
||||||
|
upload = True
|
||||||
|
procs = (
|
||||||
|
(
|
||||||
|
py_version,
|
||||||
|
npy_version,
|
||||||
|
(subprocess.Popen(**mkargs(py_version, npy_version))
|
||||||
|
if not upload_only else
|
||||||
|
None),
|
||||||
|
)
|
||||||
|
for py_version, npy_version in product(py_versions, npy_versions)
|
||||||
|
)
|
||||||
|
status = 0
|
||||||
|
files = []
|
||||||
|
for py_version, npy_version, proc in procs:
|
||||||
|
if not upload_only:
|
||||||
|
out, err = proc.communicate()
|
||||||
|
if proc.returncode:
|
||||||
|
status = 1
|
||||||
|
print('build failure: python=%s numpy=%s\n%s' % (
|
||||||
|
py_version,
|
||||||
|
npy_version,
|
||||||
|
err.decode('utf-8'),
|
||||||
|
))
|
||||||
|
elif upload:
|
||||||
|
files.append(subprocess.Popen(
|
||||||
|
**mkargs(py_version, npy_version, output=True)
|
||||||
|
).communicate()[0].decode('utf-8').strip())
|
||||||
|
|
||||||
|
if not status and upload:
|
||||||
|
for f in files:
|
||||||
|
p = subprocess.Popen(
|
||||||
|
['anaconda', 'upload', '-u', user, f],
|
||||||
|
stdout=subprocess.DEVNULL,
|
||||||
|
stderr=subprocess.DEVNULL,
|
||||||
|
)
|
||||||
|
out, err = p.communicate()
|
||||||
|
if p.returncode:
|
||||||
|
print('failed to upload: %s\n%s' % (f, err.decode('utf-8')))
|
||||||
|
return status
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
main()
|
exit(main())
|
||||||
|
|||||||
Reference in New Issue
Block a user