Skip to content

Instantly share code, notes, and snippets.

@ethankhall
Created August 11, 2016 15:57
Show Gist options
  • Save ethankhall/bc9cd66c5a30954daa39dd5452d55123 to your computer and use it in GitHub Desktop.
Save ethankhall/bc9cd66c5a30954daa39dd5452d55123 to your computer and use it in GitHub Desktop.
PyGradle
apply plugin: 'python-sdist'
dependencies {
python 'pypi:Werkzeug:0.7',
python 'pypi:Jinja2:2.4',
python 'pypi:itsdangerous:0.21',
python 'pypi:click:2.0'
}
from setuptools.dist import Distribution
import os
class GradleDistribution(Distribution, object):
"""The Python to Gradle bridge."""
#: The name of the requirements file generated by pygradle.
PINNED_TXT = 'pinned.txt'
def __init__(self, attrs):
attrs['name'] = os.getenv(self.PYGRADLE_PRODUCT_NAME)
attrs['version'] = os.getenv(self.PYGRADLE_PRODUCT_VERSION)
attrs['install_requires'] = list(self.load_requirements())
def load_requirements(self):
...
$ tree
├── build.gradle
├── gradlew
├── foo
│ ├── build.gradle
│ ├── setup.cfg
│ ├── setup.py
│ ├── src
│ │ └── foo
│ │ └── __init__.py
│ ├── requirements.txt
│ └── test
│ └── test_foo.py
├── <subproject>
│ └── ...
└── settings.gradle
$ ./gradlew build
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment