Skip to content
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

add pypi package distribution with CI #755

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ tests
testdata.json
reports

# PyPI distributions
dist/

## R
*.Rhistory

Expand Down
27 changes: 27 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,33 @@ jobs:
fail_ci_if_error: true
verbose: true

pypi-publish:
name: Upload release to PyPI
runs-on: ubuntu-latest
needs: tests
if: ${{ success() && (contains(github.ref, 'refs/tags') || github.ref == 'refs/heads/master') }}
environment:
name: pypi
url: https://pypi.org/p/crim-weaver
permissions:
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
steps:
- uses: actions/checkout@v4
with:
fetch-depth: "0"
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Build Distribution Package
run: make dist-pypi
- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
verbose: true

deploy-docker:
needs: tests
if: ${{ success() && (contains(github.ref, 'refs/tags') || github.ref == 'refs/heads/master') }}
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ unit_tests/testdata.json
result[s].xml
testdata.json

# PyPI distributions
dist/

## R
*.Rhistory

Expand Down
4 changes: 4 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ Changes

Changes:
--------
- Update package distribution name to ``crim-weaver`` for release on PyPI.
The Python package is still imported as ``weaver``, but ``pserve`` and ``celery`` looking for the package egg
need to point at ``egg:crim-weaver``. For backward compatibility, provided Docker images create a system link
that make this change transparent, but users need to update the INI configuration if running *Weaver* locally.
- Add support of *OGC API - Processes - Part 3: Workflows and Chaining* with *Nested Process* ad-hoc workflow
definitions directly submitted for execution (fixes `#747 <https://github.com/crim-ca/weaver/issues/747>`_,
relates to `#412 <https://github.com/crim-ca/weaver/issues/412>`_).
Expand Down
18 changes: 13 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -292,22 +292,23 @@ install-npm-remarklint: install-npm ## install remark-lint dependency for 'chec
)

.PHONY: install-dev-npm
install-dev-npm: install-npm install-npm-remarklint install-npm-remarklint ## install all npm development dependencies
install-dev-npm: install-npm install-npm-remarklint install-npm-remarklint ## install all npm development dependencies

## -- Cleanup targets ----------------------------------------------------------------------------------------------- ##

.PHONY: clean
clean: clean-all ## alias for 'clean-all' target

.PHONY: clean-all
clean-all: clean-build clean-cache clean-docs-dirs clean-src clean-reports clean-test ## run all cleanup targets
clean-all: clean-build clean-cache clean-dist clean-docs-dirs clean-src clean-reports clean-test ## run all cleanup targets

.PHONY: clean-build
clean-build: ## remove the temporary build files
@echo "Removing build files..."
@-rm -fr "$(APP_ROOT)/build"
@-rm -fr "$(APP_ROOT)/eggs"
@-rm -fr "$(APP_ROOT)/develop-eggs"
@-rm -fr "$(APP_ROOT)/$(APP_NAME).egg-info"
@-rm -fr "$(APP_ROOT)/*.egg-info"
@-rm -fr "$(APP_ROOT)/parts"

.PHONY: clean-cache
Expand Down Expand Up @@ -353,10 +354,10 @@ clean-reports: ## remove report files generated by code checks
@-rm -fr "$(REPORTS_DIR)"

.PHONY: clean-dist
clean-dist: clean ## remove *all* files that are not controlled by 'git' except *.bak and makefile configuration
clean-dist: clean-build ## remove distribution files
@echo "Cleaning distribution..."
@git diff --quiet HEAD || echo "There are uncommitted changes! Not doing 'git clean'..."
@-git clean -dfx -e *.bak -e Makefile.config
@-rm -fr dist

## -- Testing targets ----------------------------------------------------------------------------------------------- ##
## -- [variants '<target>-only' without '-only' suffix are also available with pre-install setup]
Expand Down Expand Up @@ -744,6 +745,13 @@ bump: ## bump version using VERSION specified as user input [make VERSION=<x.y.
@[ "${VERSION}" ] || ( echo ">> 'VERSION' is not set"; exit 1 )
@-bash -c '$(CONDA_CMD) bump2version $(BUMP_XARGS) --new-version "${VERSION}" patch;'

.PHONY: dist-pypi
dist-pypi: clean-dist
@echo "Build distributions for PyPI ..."
@-python setup.py sdist
@-python setup.py bdist_wheel
@ls -l dist

## -- Docker targets ------------------------------------------------------------------------------------------------ ##

.PHONY: docker-info
Expand Down
6 changes: 5 additions & 1 deletion config/weaver.ini.example
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@
###

[app:main]
use = egg:weaver
# WARNING:
# For backward compatibility, a system link can be created to map this distribution as "weaver -> crim_weaver".
# See 'docker/Dockerfile-base' for system link mapping example.
# Otherwise, replace the following with 'egg:weaver' according to the installed package distribution.
use = egg:crim-weaver

pyramid.reload_templates = false
pyramid.debug_authorization = false
Expand Down
8 changes: 8 additions & 0 deletions docker/Dockerfile-base
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,12 @@ COPY ./ ${APP_DIR}
# equivalent of `make install` without conda env and pre-installed packages
RUN pip install --no-dependencies -e ${APP_DIR}

# backward-compatibility mapping for 'importlib.metadata' dist/package name resolution
# this allows existing 'weaver.ini' to point at 'weaver' rather than 'crim-weaver' for pserve and celery INI
RUN ln -s $( \
python -c 'import importlib.metadata; DIST=importlib.metadata.Distribution.from_name("crim-weaver")._path; \
print(DIST); \
print(str(DIST).replace("crim_", ""))' \
)

CMD ["bash"]
15 changes: 12 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,10 @@ def _parse_requirements(file_path, requirements, links):
LOGGER.info("link requirements: %s", LINKS)

setup(
name=__meta__.__name__,
name=__meta__.__package__,
version=__meta__.__version__,
provides=[__meta__.__name__], # ensure that the package distribution alias maps to the importable package name
py_modules=[__meta__.__name__],
description=__meta__.__description__,
long_description=LONG_DESCRIPTION,
long_description_content_type="text/x-rst",
Expand Down Expand Up @@ -115,9 +117,16 @@ def _parse_requirements(file_path, requirements, links):
download_url=__meta__.__docker_repository__,
license=__meta__.__license_type__,
keywords=" ".join(__meta__.__keywords__),
packages=find_packages(),
packages=find_packages(exclude=["tests*"]),
package_dir={
__meta__.__name__: "weaver",
__meta__.__package__: "weaver",
},
package_data={
"": ["*.mako"],
"weaver": ["*"],
},
include_package_data=True,
package_data={"": ["*.mako"]},
zip_safe=False,
test_suite="tests",
python_requires=">=3.7, <4",
Expand Down
2 changes: 1 addition & 1 deletion tests/functional/test_celery.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def test_celery_registry_resolution():
cfg_ini.write(
inspect.cleandoc(f"""
[app:main]
use = egg:weaver
use = egg:crim-weaver
[celery]
broker_url = {celery_mongo_broker}
result_backend = {celery_mongo_broker}
Expand Down
3 changes: 2 additions & 1 deletion weaver/__meta__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
__name__ = "weaver"
__title__ = "Weaver"
__version__ = "5.9.0"
__package__ = "crim-weaver"
__description__ = "Workflow Execution Management Service (EMS); Application, Deployment and Execution Service (ADES)."
__source_repository__ = "https://github.com/crim-ca/weaver"
__docker_repository__ = "https://hub.docker.com/r/pavics/weaver"
Expand All @@ -15,7 +16,7 @@
]
__author__ = ", ".join(__authors__)
__emails__ = [
""
"[email protected]"
]
__keywords__ = [
"buildout",
Expand Down
Loading