Skip to content
Snippets Groups Projects
Commit 425e4b3b authored by Nathan Hertz's avatar Nathan Hertz
Browse files

Added comments on everything relevant; refactored setup_to_meta.py; modified...

Added comments on everything relevant; refactored setup_to_meta.py; modified how parse_setup is called from setup_to_meta
parent 32415143
No related branches found
No related tags found
No related merge requests found
# Main section
# Accessible from the command line using 'buildout key=value'
# e.g. buildout parts=build_packages will specify build_packages
# as a part that should be installed
[buildout]
develop = src/setup_to_meta
parts = gen_metadata
develop = src/setup_to_meta src/build_packages
[gen_metadata]
recipe = setup_to_meta
path = apps/cli/executables/alma_product_fetch
# [conda]
# recipe = condarecipe
# path = /opt/miniconda3/condabin/conda
# env = data
# Section for building internal tools using conda
# Depends on gen_metadata
# Depends on `name` in [buildout] to specify which package to install
# Specify name via command line using
# `buildout parts=build_packages name={name}`
[build_packages]
=> gen_metadata
recipe = build_packages
name = ${buildout:name}
# [alma-product-fetch]
# recipe = bdistrecipe
# path = apps/cli/executables/alma_product_fetch
# [datafetcher]
# recipe = bdistrecipe
# path = apps/cli/executables/datafetcher
\ No newline at end of file
# Section for generating meta.yaml files
[gen_metadata]
recipe = setup_to_meta
\ No newline at end of file
{% set name = "datafetcher" %}
{% set version = "4.0.0a1.dev1" %}
package:
name: "{{ name|lower }}"
version: "{{ version }}"
build:
entry_points:
- datafetcher = datafetcher.commands:main
script: {{ PYTHON }} setup.py install
source:
path: ../../../apps/cli/executables/datafetcher
requirements:
build:
- python==3.8
- pika>=1.1,<2
- pycapo>=0.3.0,<1.0
- beautifulsoup4>=4.9.1,<5.0
- lxml>=4.3.2,<5.0
- psycopg2>=2.8.5,<3.0
- pyopenssl>=19.1.0,<20.0
- requests>=2.23,<3.0
run:
- python==3.8
- pika>=1.1,<2
- pycapo>=0.3.0,<1.0
- beautifulsoup4>=4.9.1,<5.0
- lxml>=4.3.2,<5.0
- psycopg2>=2.8.5,<3.0
- pyopenssl>=19.1.0,<20.0
- requests>=2.23,<3.0
test:
source_files:
- test/
requires:
- pytest>=5.4,<6.0
commands:
- pytest -vv --log-level=DEBUG --showlocals test/datafetcher_test.py
about:
license: "GPL"
license_family: "GPL"
summary: "NRAO Archive Data Fetcher Script"
\ No newline at end of file
{% set name = "events" %}
{% set version = "4.0.0a1.dev1" %}
package:
name: "{{ name|lower }}"
version: "{{ version }}"
source:
path: shared/messaging/events
build:
number: 0
script:
- python setup.py install
requirements:
run:
- python=3.8
- pika
- pycapo
about:
license: "GPL"
license_family: "GPL"
summary: "NRAO Archive Data Fetcher Script"
import setuptools
def get_data(field, data):
"""
Get data from field if it exists.
:return: None if not found. Datum of field if found.
"""
datum = None
try:
datum = data[field]
except KeyError as e:
pass
return datum
data = {}
def my_setup(*args, **kwargs):
"""
A replacement for setuptools.setup().
"""
fields = [
'name',
'version',
'description',
'license',
'install_requires',
'tests_require',
'entry_points'
]
for field in fields:
data[field] = get_data(field, kwargs)
def main():
# Author of these shenanigans: Daniel Lyons (but you already knew that)
# Monkey-patch over the setuptools setup() function to do our function instead
setuptools.setup = my_setup
# Load the setup.py file
import setup
# Instead of exiting, we now have populated our global variable, without doing any parsing
for field, datum in data.items():
print('{}: {}'.format(field, datum))
if __name__ == "__main__":
main()
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment