-
Notifications
You must be signed in to change notification settings - Fork 87
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #119 from goanpeca/fix/setup
PR: Simplify setup to make it more standard and create scripts in scripts/ folder
- Loading branch information
Showing
16 changed files
with
742 additions
and
563 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
# Release process | ||
|
||
## To release a new version of **anaconda-project** on PyPI: | ||
|
||
**1.)** Ensure you have the latest version from upstream and update your fork | ||
|
||
git pull upstream master | ||
git push origin master | ||
|
||
**2.)** Update [CHANGELOG.md](https://github.com/anaconda-platform/anaconda-project/blob/master/CHANGELOG.md), using loghub itself | ||
|
||
loghub anaconda-platform/anaconda-project -m <milestone> | ||
|
||
**3.)** Update [`anaconda_project/version.py`](https://github.com/anaconda-platform/anaconda-project/blob/master/anaconda_project/version.py) (set release version, remove 'dev0') | ||
|
||
**4.)** Commit changes | ||
|
||
git add . | ||
git commit -m "Set release version" | ||
|
||
**5.)** Create distributions | ||
|
||
python setup.py sdist bdist_wheel | ||
|
||
**6.)** Upload distributions | ||
|
||
twine upload dist/* -u <username> -p <password> | ||
|
||
**7.)** Add release tag | ||
|
||
git tag -a vX.X.X -m 'Tag release version vX.X.X' | ||
|
||
**8.)** Update `version.py` (add 'dev0' and increment minor or major as needed) | ||
|
||
**9.)** Commint changes | ||
|
||
git add . | ||
git commit -m "Restore dev version" | ||
|
||
**10.)** Push changes | ||
|
||
git push upstream master | ||
git push origin master | ||
git push --tags | ||
|
||
|
||
## To release a new version of **anaconda-project** on anaconda-platform: | ||
|
||
**1.)** After the previous steps on pypi (and tagging) run: | ||
|
||
bash scripts/build_and_upload.sh | ||
|
||
## To release a new version of **anaconda-project** on conda-forge: | ||
|
||
**1.)** Ensure you have the latest version from upstream and update your fork | ||
|
||
git pull upstream master | ||
git push origin master | ||
|
||
**2.)** Update [meta.yaml](https://github.com/anaconda-platform/anaaconda-project/blob/master/conda.recipe/meta.yaml) version and hash | ||
|
||
**3.)** Commit changes | ||
|
||
git add . | ||
git commit -m "Update conda recipe" | ||
|
||
**4.)** Update recipe on [conda-forge/anaconda-project-feedstock](https://github.com/conda-forge/anaconda-project-feedstock) | ||
|
||
**5.)** Push changes | ||
|
||
git push upstream master | ||
git push origin master |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# -*- coding: utf-8 -*- | ||
# ----------------------------------------------------------------------------- | ||
# Copyright (c) 2016, Anaconda, Inc. All rights reserved. | ||
# | ||
# Licensed under the terms of the BSD 3-Clause License. | ||
# The full license is in the file LICENSE.txt, distributed with this software. | ||
# ----------------------------------------------------------------------------- | ||
"""Version of anaconda-project library.""" | ||
|
||
VERSION_INFO = (0, 8, 0, 'dev0') | ||
__version__ = '.'.join(map(str, VERSION_INFO)) | ||
version = __version__ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,12 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
# be sure we are in the right place | ||
test -e setup.py || exit 1 | ||
test -d anaconda_project || exit 1 | ||
|
||
(test -d build/packages && /bin/rm -r build/packages) || true | ||
python setup.py test | ||
python setup.py conda_package | ||
python scripts/run_tests.py | ||
python scripts/create_conda_packages | ||
|
||
anaconda upload -u anaconda-platform --label dev build/packages/**/**/*.tar.bz2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,158 @@ | ||
# -*- coding: utf-8 -*- | ||
# ----------------------------------------------------------------------------- | ||
# Copyright (c) 2016, Anaconda, Inc. All rights reserved. | ||
# | ||
# Licensed under the terms of the BSD 3-Clause License. | ||
# The full license is in the file LICENSE.txt, distributed with this software. | ||
# ----------------------------------------------------------------------------- | ||
"""Script to automate the creation of conda packages for a release.""" | ||
|
||
from __future__ import print_function | ||
|
||
# Standard library imports | ||
import argparse | ||
import ast | ||
import os | ||
import subprocess | ||
import shutil | ||
import sys | ||
|
||
# Constants | ||
HERE = os.path.abspath(os.path.dirname(__file__)) | ||
ROOT = os.path.dirname(HERE) | ||
PYTHON_VERSIONS = ('2.7', '3.5', '3.6') | ||
|
||
|
||
def get_version(module='anaconda_project'): | ||
"""Get version.""" | ||
with open(os.path.join(ROOT, module, 'version.py'), 'r') as f: | ||
data = f.read() | ||
lines = data.split('\n') | ||
for line in lines: | ||
if line.startswith('VERSION_INFO'): | ||
version_tuple = ast.literal_eval(line.split('=')[-1].strip()) | ||
version = '.'.join(map(str, version_tuple)) | ||
break | ||
return version | ||
|
||
|
||
VERSION = get_version() | ||
|
||
|
||
class CondaPackageCreator: | ||
"Create Conda packages" | ||
|
||
def __init__(self, packages_dir=None): | ||
"Create Conda packages" | ||
self.packages_dir = packages_dir | ||
self.clean_up() | ||
|
||
if self.packages_dir is None: | ||
self.packages_dir = os.path.join(ROOT, 'build', 'packages') | ||
self._safe_makedirs(self.packages_dir) | ||
|
||
def clean_up(self): | ||
# Clean up leftover trash as best we can | ||
BUILD_TMP = os.path.join(ROOT, 'build', 'tmp') | ||
if os.path.isdir(BUILD_TMP): | ||
print("Cleaning up " + BUILD_TMP) | ||
try: | ||
shutil.rmtree(BUILD_TMP, ignore_errors=True) | ||
except Exception as e: | ||
print("Failed to remove %s: %s" % (BUILD_TMP, str(e))) | ||
else: | ||
print("Done removing " + BUILD_TMP) | ||
|
||
def run(self): | ||
try: | ||
self._real_run() | ||
except Exception as e: | ||
import traceback | ||
traceback.print_exc() | ||
print("setup.py: Failed to build packages: " + str(e), file=sys.stderr) | ||
sys.exit(1) | ||
|
||
def _real_run(self): | ||
recipe_dir = os.path.join(ROOT, 'conda.recipe') | ||
python_versions = PYTHON_VERSIONS | ||
all_final_package_paths = [] | ||
for python_version in python_versions: | ||
out = subprocess.check_output(['conda-build', '--output', '--python', python_version, recipe_dir]) | ||
package_path = out.decode('utf-8').strip() | ||
print("expected conda package path: " + package_path) | ||
if '--' in package_path: | ||
# conda build bug? | ||
print("package_path looks broken, contains -- in it. fixing...") | ||
package_path = package_path.replace("--", "-%s-" % VERSION) | ||
print("new conda package path: " + package_path) | ||
build_arch = os.path.basename(os.path.dirname(package_path)) | ||
python_scoped_package_dir = os.path.join(self.packages_dir, "py%s" % python_version) | ||
final_package_path = os.path.join(python_scoped_package_dir, build_arch, os.path.basename(package_path)) | ||
all_final_package_paths.append(final_package_path) | ||
if os.path.isfile(final_package_path): | ||
print("Package for python %s platform %s already exists: %s" % | ||
(python_version, build_arch, final_package_path)) | ||
else: | ||
if os.path.isfile(package_path): | ||
print("Already built for python %s at %s" % (python_version, package_path)) | ||
else: | ||
print("Calling conda build for %s %s" % (python_version, build_arch)) | ||
code = subprocess.call(['conda', 'build', '--no-binstar-upload', '--python', python_version, | ||
recipe_dir]) | ||
if code != 0: | ||
raise Exception("Failed to build for python version " + python_version) | ||
if not os.path.isfile(package_path): | ||
try: | ||
print("files that DO exist: " + repr(os.listdir(os.path.basename(package_path)))) | ||
except Exception as e: | ||
print(" (failed to list files that do exist, %s)" % str(e)) | ||
raise Exception("conda said it would build %s but it didn't" % package_path) | ||
|
||
self._safe_makedirs(os.path.dirname(final_package_path)) | ||
print("Copying %s to %s" % (package_path, final_package_path)) | ||
shutil.copyfile(package_path, final_package_path) | ||
print("Created %s" % final_package_path) | ||
|
||
for arch in ('osx-64', 'linux-32', 'win-32', 'win-64'): | ||
if arch == build_arch: | ||
continue | ||
converted_output_dir = os.path.join(python_scoped_package_dir) | ||
converted_package_path = os.path.join(converted_output_dir, arch, os.path.basename(package_path)) | ||
if os.path.isfile(converted_package_path): | ||
print("Already converted to %s from %s for python %s" % (arch, build_arch, python_version)) | ||
else: | ||
print("Creating %s by conversion %s=>%s" % (converted_package_path, build_arch, arch)) | ||
self._safe_makedirs(converted_output_dir) | ||
# this automatically creates the "arch" directory to put the package in | ||
code = subprocess.call(['conda', 'convert', '--platform', arch, final_package_path, '--output-dir', | ||
converted_output_dir]) | ||
if code != 0: | ||
raise Exception("Failed to convert from %s to %s to create %s" % | ||
(build_arch, arch, converted_package_path)) | ||
all_final_package_paths.append(converted_package_path) | ||
|
||
print("Packages in " + self.packages_dir) | ||
|
||
def _safe_makedirs(self, path): | ||
try: | ||
os.makedirs(path) | ||
except OSError: | ||
pass | ||
|
||
|
||
def main(): | ||
parser = argparse.ArgumentParser(description='Script to create conda packages for all platforms and ' | ||
'python version 2.7, 3.5 and 3.6') | ||
parser.add_argument(action="store", | ||
dest="packages_dir", | ||
default=None, | ||
help="location directory for built packages", | ||
nargs='?') | ||
|
||
options = parser.parse_args() | ||
cpc = CondaPackageCreator(packages_dir=options.packages_dir) | ||
cpc.run() | ||
|
||
|
||
if __name__ == '__main__': | ||
main() |
Oops, something went wrong.