Skip to content

Commit

Permalink
[sdk/python] Allow editable installs without build step (#357)
Browse files Browse the repository at this point in the history
This change makes it possible to install the Python SDK with `pip install -e sdk/python/lib` without having to first build the project and then install from the build directory with `pip install -e sdk/python/env/src`.

This helps speed up local development, but also makes it possible to install in this way from tests that require the version of the package to be a simple version like `1.0.0` and not `1.12.0a1721429785` like with the built package.
  • Loading branch information
justinvp committed Jul 22, 2024
1 parent 09ce176 commit 31e46ca
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 7 deletions.
3 changes: 2 additions & 1 deletion sdk/python/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
.mypy_cache/
*.pyc
/env/
/*.egg-info
*.egg-info/
.venv/
build/
4 changes: 2 additions & 2 deletions sdk/python/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ ensure::

build::
rm -rf $(PYENVSRC) && cp -R ./lib/. $(PYENVSRC)/
sed -i.bak "s/\$${VERSION}/$(PYPI_VERSION)/g" $(PYENVSRC)/setup.py && rm $(PYENVSRC)/setup.py.bak
sed -i.bak "s/\$${VERSION}/$(VERSION:v%=%)/g" $(PYENVSRCLIB)/version.py && rm $(PYENVSRCLIB)/version.py.bak
sed -i.bak 's/^VERSION = .*/VERSION = "$(PYPI_VERSION)"/g' $(PYENVSRC)/setup.py && rm $(PYENVSRC)/setup.py.bak
sed -i.bak 's/^VERSION = .*/VERSION = "$(VERSION)"/g' $(PYENVSRCLIB)/version.py && rm $(PYENVSRCLIB)/version.py.bak

cp ../../README.md $(PYENVSRC)
cd $(PYENVSRC) && pipenv run python setup.py build bdist_wheel --universal
Expand Down
2 changes: 1 addition & 1 deletion sdk/python/lib/pulumi_policy/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@
# See the License for the specific language governing permissions and
# limitations under the License.

VERSION = "${VERSION}"
VERSION = "1.0.0"
11 changes: 8 additions & 3 deletions sdk/python/lib/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,17 @@

from setuptools import setup, find_packages

VERSION = "1.0.0"

def readme():
with open('README.md', encoding='utf-8') as f:
return f.read()
try:
with open('README.md', encoding='utf-8') as f:
return f.read()
except FileNotFoundError:
return "Pulumi's Policy Python SDK - Development Version"

setup(name='pulumi_policy',
version='${VERSION}',
version=VERSION,
description='Pulumi\'s Policy Python SDK',
long_description=readme(),
long_description_content_type='text/markdown',
Expand Down

0 comments on commit 31e46ca

Please sign in to comment.