-
Notifications
You must be signed in to change notification settings - Fork 270
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
tweaks for CI and CD #9
Merged
+84
−46
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
.* | ||
!.gitignore | ||
*.pyc | ||
__pycache__/ | ||
build/ | ||
!.travis.yml | ||
dist/ | ||
*.egg-info/ |
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,44 @@ | ||
language: python | ||
|
||
python: "3.4" | ||
|
||
# build sdist | ||
script: make build | ||
|
||
# install twine for uploading to PyPI | ||
before_deploy: pip install twine | ||
|
||
deploy: | ||
|
||
# create github release | ||
- provider: releases | ||
|
||
# GitHub access token | ||
api_key: | ||
secure: "Hv2ICkPkC7hiRw8GS9adkEcfoYGeVPbGHRNPQdGxLTeP1Mz9x/2ylUprrb2Ohq+pHGRa1W55nSJAZWHto4L/seWS17vN1JB1o71KYeD8h4Ywm/iJzYJFu4v8cmuT9qMPC89GtSGUkEZml+Vd6lb6d/eBr7HWoAMF7LCobzVvpJftgSBqkN1Z0aaunGNRtPVaqf0D4iQMSU1e0X9HFyIsxjS68sNqVcU/eSqbkHQ32COliOdEZXDqNmoJjIq4NYVH7DCS4kSpfxSd3BkJPn1UH4891MntflMllH7khmSA0lqSuunp+olfzhzchYb0/e0LavqYyFU/cRemyt8RBuE0GD3J3TMudVav/5HLKt6/exZwqfv7bHyorDXkkKGJqYNPUCOD2K4RS4ExpUU5c5en5inJZdgKYVI9gZS15oXmKV3H/8JkJPgx0xRP1Rx8niQKezKdFb0dZxArbMBUuAnolgyoq2EgnsNYhboRWXoJP36FCWFn8U8UNUfmgOkkMcP59mZ6svznxWPIyCMhfGgShY03GTvPp94P6c6OZJpjyjmWyPsvGZJrvnRlJ8VxBaUBcfuQl9rtBorwJ3VI1VWguyBaSINM6OWPtEJ0J2oVM/8Dvjuw2qPNkCdUhflc7wV/AUYB9/6rfpjY+GwTEKtZBBw4epbZX/B0L+vdRONZJ0Q=" | ||
|
||
# enable wildcards in filenames | ||
file_glob: true | ||
|
||
# upload sdist | ||
file: dist/* | ||
|
||
# avoid stashing sdist | ||
skip_cleanup: true | ||
|
||
# create releases on tags only | ||
on: | ||
tags: true | ||
|
||
# deploy to PyPI | ||
- provider: script | ||
|
||
# upload sdist to PyPI | ||
script: twine upload -u $PYPI_USERNAME -p $PYPI_PASSWORD dist/* | ||
|
||
# avoid stashing sdist | ||
skip_cleanup: true | ||
|
||
# deploy on tags only | ||
on: | ||
tags: true |
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,42 +1,22 @@ | ||
BUILD_DIR = build | ||
DESCRIPTION = CS50 Library for Python | ||
MAINTAINER = CS50 <[email protected]> | ||
NAME = python-cs50 | ||
OLD_NAME = lib50-python | ||
VERSION = 1.3.0 | ||
|
||
.PHONY: bash | ||
bash: | ||
docker run -i --rm -t -v "$(PWD)":/root cs50/cli | ||
|
||
.PHONY: build | ||
build: clean | ||
mkdir -p "$(BUILD_DIR)"/usr/lib/python2.7/dist-packages/cs50 | ||
cp src/* "$(BUILD_DIR)"/usr/lib/python2.7/dist-packages/cs50 | ||
mkdir -p "$(BUILD_DIR)"/usr/lib/python3/dist-packages/cs50 | ||
cp src/* "$(BUILD_DIR)"/usr/lib/python3/dist-packages/cs50 | ||
python setup.py sdist | ||
|
||
.PHONY: clean | ||
clean: | ||
rm -rf "$(BUILD_DIR)" | ||
rm -rf *.egg-info dist | ||
|
||
.PHONY: install | ||
install: build | ||
pip install dist/*.tar.gz | ||
|
||
.PHONY: push | ||
push: | ||
git push origin "v$$(python setup.py --version)" | ||
|
||
.PHONY: release | ||
release: tag push | ||
|
||
.PHONY: deb | ||
deb: build | ||
fpm \ | ||
-C "$(BUILD_DIR)" \ | ||
-m "$(MAINTAINER)" \ | ||
-n "$(NAME)" \ | ||
-p "$(BUILD_DIR)" \ | ||
-s dir \ | ||
-t deb \ | ||
-v "$(VERSION)" \ | ||
--after-install after-install.sh \ | ||
--conflicts "$(NAME) (<< $(VERSION)), $(OLD_NAME)" \ | ||
--deb-no-default-config-files \ | ||
--depends python \ | ||
--depends python3 \ | ||
--description "$(DESCRIPTION)" \ | ||
--replaces "$(NAME) (<= $(VERSION)), $(OLD_NAME)" \ | ||
--provides "$(NAME)" \ | ||
--provides "$(OLD_NAME)" \ | ||
usr | ||
.PHONY: tag | ||
tag: | ||
git tag "v$$(python setup.py --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.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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,19 @@ | ||
from setuptools import setup | ||
|
||
setup( | ||
author="CS50", | ||
author_email="[email protected]", | ||
classifiers=[ | ||
"Intended Audience :: Developers", | ||
"Programming Language :: Python", | ||
"Programming Language :: Python :: 3", | ||
"Topic :: Software Development :: Libraries :: Python Modules" | ||
], | ||
description="CS50 library for Python", | ||
install_requires=["SQLAlchemy"], | ||
keywords="cs50", | ||
name="cs50", | ||
packages=["cs50"], | ||
url="https://github.com/cs50/python-cs50", | ||
version="1.3.0" | ||
) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any way to factor out version?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought we don't need anymore, since we're distributing via PyPI only, aren't we?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dmalan ended up reading the version specified in
setup.py
this way, without need to factor it out. Generally, I don't think we need to factor it out so long as we don't build multiple distributions (e.g., deb, rpm, sdist, etc).Factoring it out (e.g., to a file) and parsing that from
setup.py
(or any number of other scripts/config files) is fairly easy, but just feels unnecessary to me, tbh, specially that we decided to distribute Python packages via PyPI only? Thoughts?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting. Is calling the var
__version__
conventional? This would seem to mean thatsetup.py
needs to be installed along with, e.g.,cs50.py
itself. Is that indeed the norm with PyPi packages, doessetup.py
end up getting installed somewhere?Separately, what's to be the relationship between the version number in
setup.py
and our GitHub repo's branches? Should we automatically (forcibly) create a GitHub tag and release calledv#.#.#
anytime there's a push, extracting the release's version number fromsetup.py
too?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, see https://www.python.org/dev/peps/pep-0396/#specification
The
setup.py
script end up being part of the source distribution (sdist) that we build and deploy to PyPI, sincepip
uses it to build this package for and install it on the target system. I don't think it typically gets installed (it's not in our case either), but what does get installed is some metadata about the package, based on what we provided insetup.py
, and that's what's used to extract the version number at runtime in this case.If you're referring to the problem per cs50/submit50#44, recall PyPI doesn't allow the same filename (including version) to be uploaded more than once. So we can't re-upload the same version of a package, to overwrite it, for example. (And frankly, this doesn't seem ideal, since two users might have the same package version installed, but effectively, they're different packages.)
But it might be the case that we, for example, have multiple PRs pending, and we want some or all of them to be part of the next release. If we just go ahead and merge these PRs into master, one after the other, only the first one will be deployed to PyPI, and all the others will fail, because they use the same version number. So we can't do that, using the current setup, without merging these PRs into one, and then merging that big PR into master, which seems unnecessary.
For that reason, we should automatically deploy, but manually trigger deployment somehow. A couple of solutions to this might be:
Deploy on tags instead of commits to master. This should allow us to merge as many PRs as we want before the next release is published. And once we're comfortable releasing, we just tag and push that tag, which should trigger a build and deploy to PyPI.
Deploy on commits to a production branch (or the equivalent). This also should allow us to merge as many PRs as we want into master, without any problems. And once a release is ready, we merge master into production, which should trigger a build and deploy to PyPI.