diff --git a/.circleci/config.yml b/.circleci/config.yml index aa8ca73c4931c..1d21f4ebf76d8 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -134,7 +134,7 @@ jobs: circleci-agent step halt else source .venv/bin/activate - python -m localstack.testing.testselection.scripts.generate_test_selection_from_pr /tmp/workspace/repo $CI_PULL_REQUEST target/testselection/test-selection.txt + PYTHONPATH=localstack-core python -m localstack.testing.testselection.scripts.generate_test_selection_from_pr /tmp/workspace/repo $CI_PULL_REQUEST target/testselection/test-selection.txt cat target/testselection/test-selection.txt fi @@ -402,7 +402,7 @@ jobs: if [ -z $TESTSELECTION_PYTEST_ARGS ] ; then TEST_FILES=$(circleci tests glob "tests/aws/**/test_*.py" "tests/integration/**/test_*.py" | circleci tests split --verbose --split-by=timings | tr '\n' ' ') else - TEST_FILES=$(circleci tests glob "tests/aws/**/test_*.py" "tests/integration/**/test_*.py" | python -m localstack.testing.testselection.scripts.filter_by_test_selection target/testselection/test-selection.txt | circleci tests split --verbose --split-by=timings | tr '\n' ' ') + TEST_FILES=$(circleci tests glob "tests/aws/**/test_*.py" "tests/integration/**/test_*.py" | PYTHONPATH=localstack-core python -m localstack.testing.testselection.scripts.filter_by_test_selection target/testselection/test-selection.txt | circleci tests split --verbose --split-by=timings | tr '\n' ' ') fi echo $TEST_FILES PYTEST_ARGS="${TINYBIRD_PYTEST_ARGS}${TESTSELECTION_PYTEST_ARGS}-o junit_family=legacy --junitxml=target/reports/test-report-<< parameters.platform >>-${CIRCLE_NODE_INDEX}.xml" \ @@ -465,8 +465,9 @@ jobs: - run: name: Run localstack command: | - DEBUG=1 DISABLE_EVENTS="1" IMAGE_NAME="localstack/localstack:latest" bin/localstack start -d - bin/localstack wait -t 120 || (bin/localstack logs && false) + source .venv/bin/activate + DEBUG=1 DISABLE_EVENTS="1" IMAGE_NAME="localstack/localstack:latest" localstack start -d + localstack wait -t 120 || (python -m localstack.cli.main logs && false) - run: name: Run capture-not-implemented command: | @@ -538,6 +539,7 @@ jobs: METRIC_REPORT_DIR_PATH=parity_metrics \ IMPLEMENTATION_COVERAGE_FILE=scripts/implementation_coverage_full.csv \ SOURCE_TYPE=community \ + PYTHONPATH=localstack-core \ python -m scripts.tinybird.upload_raw_test_metrics_and_coverage else echo "Skipping parity reporting to tinybird (no credentials, running on fork)..." diff --git a/.dockerignore b/.dockerignore index 1ad806c4cbb23..db8b1c5a344a7 100644 --- a/.dockerignore +++ b/.dockerignore @@ -2,6 +2,7 @@ .venv* .filesystem +**/.filesystem # ignore files generated in CI build tests/aws/**/node_modules diff --git a/.github/workflows/tests-pro-integration.yml b/.github/workflows/tests-pro-integration.yml index a62c54286bef5..f0be2cccd67e0 100644 --- a/.github/workflows/tests-pro-integration.yml +++ b/.github/workflows/tests-pro-integration.yml @@ -291,14 +291,14 @@ jobs: # Entrypoints need to be generated _after_ the community edition has been linked into the venv run: | VENV_DIR="../localstack-ext/.venv" make entrypoints - cat localstack_core.egg-info/entry_points.txt + ../localstack-ext/.venv/bin/python -m plux show - name: Create Pro Entrypoints working-directory: localstack-ext # Entrypoints need to be generated _after_ the community edition has been linked into the venv run: | make entrypoints - cat localstack_ext.egg-info/entry_points.txt + .venv/bin/python -m plux show - name: Test Pro Startup env: @@ -334,7 +334,7 @@ jobs: working-directory: localstack-ext run: | # Remove the host tmp folder (might contain remnant files with different permissions) - sudo rm -rf ../localstack/.filesystem/var/lib/localstack/tmp + sudo rm -rf ../localstack/localstack-core/.filesystem/var/lib/localstack/tmp make test - name: Archive Test Results diff --git a/Dockerfile b/Dockerfile index 13b85840a7dda..5d98609326965 100644 --- a/Dockerfile +++ b/Dockerfile @@ -99,6 +99,7 @@ ENV PATH "${PATH}:${JAVA_HOME}/bin" # set workdir RUN mkdir -p /opt/code/localstack +RUN mkdir /opt/code/localstack/localstack-core WORKDIR /opt/code/localstack/ # create localstack user and filesystem hierarchy, perform some permission fixes @@ -176,7 +177,7 @@ ADD Makefile pyproject.toml VERSION ./ ADD bin/localstack bin/localstack.bat bin/localstack-supervisor bin/ # add the code as late as possible -ADD localstack/ localstack/ +ADD localstack-core/ /opt/code/localstack/localstack-core # Generate the plugin entrypoints RUN make entrypoints diff --git a/Dockerfile.s3 b/Dockerfile.s3 index 359796d93f38a..23f5a3b9715b4 100644 --- a/Dockerfile.s3 +++ b/Dockerfile.s3 @@ -4,6 +4,7 @@ ARG TARGETARCH # set workdir RUN mkdir -p /opt/code/localstack +RUN mkdir /opt/code/localstack/localstack-core WORKDIR /opt/code/localstack/ # Install runtime OS package dependencies @@ -81,7 +82,7 @@ ADD Makefile pyproject.toml VERSION requirements-base-runtime.txt ./ ADD bin/localstack bin/localstack.bat bin/localstack-supervisor bin/ # add the code as late as possible -ADD localstack/ localstack/ +ADD localstack-core/ /opt/code/localstack/localstack-core # Generate the plugin entrypoints RUN make entrypoints diff --git a/Makefile b/Makefile index 4e1df728147db..f60144f942a48 100644 --- a/Makefile +++ b/Makefile @@ -73,14 +73,14 @@ install: install-dev entrypoints ## Install full dependencies into venv entrypoints: ## Run plux to build entry points $(VENV_RUN); python -m plux entrypoints @# make sure that the entrypoints were correctly created and are non-empty - @test -s localstack_core.egg-info/entry_points.txt || (echo "Entrypoints were not correctly created! Aborting!" && exit 1) + @test -s localstack-core/localstack_core.egg-info/entry_points.txt || (echo "Entrypoints were not correctly created! Aborting!" && exit 1) dist: entrypoints ## Build source and built (wheel) distributions of the current version $(VENV_RUN); pip install --upgrade twine; python -m build publish: clean-dist dist ## Publish the library to the central PyPi repository # make sure the dist archive contains a non-empty entry_points.txt file before uploading - tar --wildcards --to-stdout -xf dist/localstack?core*.tar.gz "localstack?core*/localstack_core.egg-info/entry_points.txt" | grep . > /dev/null 2>&1 || (echo "Refusing upload, localstack-core dist does not contain entrypoints." && exit 1) + tar --wildcards --to-stdout -xf dist/localstack?core*.tar.gz "localstack?core*/localstack-core/localstack_core.egg-info/entry_points.txt" | grep . > /dev/null 2>&1 || (echo "Refusing upload, localstack-core dist does not contain entrypoints." && exit 1) $(VENV_RUN); twine upload dist/* coveralls: ## Publish coveralls metrics @@ -258,11 +258,11 @@ clean: ## Clean up (npm dependencies, downloaded infrastructure rm -rf .filesystem rm -rf build/ rm -rf dist/ - rm -rf *.egg-info + rm -rf localstack-core/*.egg-info rm -rf $(VENV_DIR) clean-dist: ## Clean up python distribution directories rm -rf dist/ build/ - rm -rf *.egg-info + rm -rf localstack-core/*.egg-info .PHONY: usage freeze install-basic install-runtime install-test install-dev install entrypoints dist publish coveralls start docker-save-image docker-build docker-build-multiarch docker-push-master docker-create-push-manifests docker-run-tests docker-run docker-mount-run docker-cp-coverage test test-coverage test-docker test-docker-mount test-docker-mount-code lint lint-modified format format-modified init-precommit clean clean-dist upgrade-pinned-dependencies diff --git a/pyproject.toml b/pyproject.toml index 78a89a50e437f..7d51e9464e768 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -144,12 +144,14 @@ script-files = [ "bin/localstack.bat", "bin/localstack-supervisor", ] +package-dir = { "" = "localstack-core"} [tool.setuptools.dynamic] readme = { file = ["README.md"], content-type = "text/markdown"} version = { file = "VERSION" } [tool.setuptools.packages.find] +where = ["localstack-core/"] include = ["localstack*"] exclude = ["tests*"] @@ -170,6 +172,7 @@ exclude = ["tests*"] # Always generate Python 3.8-compatible code. target-version = "py38" line-length = 100 +src = ["localstack-core", "tests"] exclude = [ ".venv*", "venv*", @@ -177,9 +180,11 @@ exclude = [ "build", "target", "*.egg-info", + "localstack-core/*.egg-info", ".filesystem", + "localstack-core/.filesystem", ".git", - "localstack/services/stepfunctions/asl/antlr/runtime" + "localstack-core/localstack/services/stepfunctions/asl/antlr/runtime" ] [tool.ruff.lint] @@ -206,12 +211,12 @@ select = ["B", "C", "E", "F", "I", "W", "T", "B9"] [tool.coverage.run] relative_files = true source = [ - "localstack/" + "localstack-core/" ] omit = [ - "localstack/aws/api/*", - "localstack/extensions/api/*", - "localstack/services/stepfunctions/asl/antlr/runtime/*" + "localstack-core/localstack/aws/api/*", + "localstack-core/localstack/extensions/api/*", + "localstack-core/localstack/services/stepfunctions/asl/antlr/runtime/*" ] dynamic_context = "test_function" diff --git a/setup.py b/setup.py index 0ac4c46692eb9..c0dd26fed2838 100644 --- a/setup.py +++ b/setup.py @@ -12,7 +12,7 @@ def get_version(): # Set the version in the localstack/version.py file def set_version_constant(version: str): with open( - os.path.join(os.path.dirname(__file__), "localstack", "version.py"), "w" + os.path.join(os.path.dirname(__file__), "localstack-core", "localstack", "version.py"), "w" ) as version_file: version_file.write(f'__version__ = "{version}"\n')