-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into test_scenario_csv
- Loading branch information
Showing
69 changed files
with
6,258 additions
and
2,847 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# Publish to conda | ||
|
||
There are two publishing systems for openfisca conda packages: | ||
- A fully automatic CI that publishes to an _openfisca_ channel. `openfisca-survey-manager` conda package is published to this channel. See below for more information. | ||
- A more complex CI calling Conda-Forge CI, that publishes to the _Conda-Forge_ channel. See https://www.youtube.com/watch?v=N2XwK9BkJpA for an introduction to Conda-Forge. We do not use it for this repository. | ||
|
||
## Automatic upload | ||
|
||
The CI automaticaly builds the conda package from the [PyPi package](https://pypi.org/project/OpenFisca-Survey-Manager/), and uploads it to [anaconda.org](https://anaconda.org/search?q=openfisca-survey-manager). You can check this out in the GitHub Actions configuration file `.github/workflow/workflow.yml` and its `publish-to-conda` step. | ||
|
||
## Manual actions made to make it work the first time | ||
|
||
- Create an account on https://anaconda.org. | ||
- Create a token on https://anaconda.org/openfisca/settings/access with _Allow write access to the API site_. | ||
- Put the token in a CI environment variable named `ANACONDA_TOKEN`. | ||
|
||
⚠️ Warning, the current token expires on 2025/01/14. Check existing tokens and their expiration dates on Anaconda.org website and its [_Access_ section](https://anaconda.org/openfisca/settings/access). | ||
|
||
## Manual actions before initializing the CI or to test the conda packaging | ||
|
||
Before initializing the CI the conda package was created locally. Now, the conda packaging is done by the CI. Nevertheless, if you want to test it, this section describes how a package is built and uploaded. | ||
|
||
To create a conda package for this repository you can check the packaging configuration in `.conda/meta.yaml` and do the following in the project root folder: | ||
|
||
1. Build package: | ||
- `conda install -c anaconda conda-build anaconda-client` | ||
(`conda-build` to build the package and [anaconda-client](https://github.com/Anaconda-Platform/anaconda-client) to push the package to anaconda.org) | ||
- `conda build .conda --channel openfisca` | ||
|
||
2. Upload the package to Anaconda.org, but DON'T do it if you don't want to publish your locally built package as an official OpenFisca-Survey-Manager library: | ||
- `anaconda login` | ||
- `anaconda upload openfisca-survey-manager-<VERSION>-py_0.tar.bz2` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
############################################################################### | ||
## File describing the package for Anaconda.org | ||
## It uses Jinja2 templating code to retreive information from setup.py | ||
############################################################################### | ||
|
||
{% set name = "OpenFisca-Survey-Manager" %} | ||
{% set data = load_setup_py_data() %} | ||
{% set version = data.get('version') %} | ||
|
||
package: | ||
name: {{ name|lower }} | ||
version: {{ version }} | ||
|
||
# openfisca-survey-manager package source | ||
source: | ||
path: .. | ||
|
||
build: | ||
noarch: python | ||
number: 0 | ||
script: "{{ PYTHON }} -m pip install . -vv" | ||
|
||
requirements: | ||
host: | ||
- python | ||
- pip | ||
run: | ||
{% for req in data.get('install_requires', []) %} | ||
{% if req.startswith('tables') %} | ||
# PyPI 'tables' library is named 'pytables' for conda | ||
- {{ req.replace('tables', 'pytables') }} | ||
{% else %} | ||
- {{ req | replace(" ","")}} | ||
{% endif %} | ||
{% endfor %} | ||
|
||
|
||
test: | ||
imports: | ||
- openfisca_survey_manager | ||
requires: | ||
- pip | ||
commands: | ||
- pip check | ||
|
||
outputs: | ||
- name: openfisca-survey-manager | ||
|
||
- name: openfisca-survey-manager-matching | ||
build: | ||
noarch: python | ||
commands: | ||
- echo {{ data.keys() }} | ||
requirements: | ||
host: | ||
- python | ||
run: | ||
{% if 'extra_requires' in data %} | ||
{% for req in data['extra_requires'].get('matching', []) %} | ||
- {{ req }} | ||
{% endfor %} | ||
{% endif %} | ||
- {{ pin_subpackage('openfisca-survey-manager', exact=True) }} | ||
|
||
- name: openfisca-survey-manager-dev | ||
build: | ||
noarch: python | ||
requirements: | ||
host: | ||
- python | ||
run: | ||
{% if 'extra_requires' in data %} | ||
{% for req in data['extra_requires'].get('dev', []) %} | ||
- {{ req }} | ||
{% endfor %} | ||
{% endif %} | ||
- {{ pin_subpackage('openfisca-survey-manager', exact=True) }} | ||
|
||
- name: openfisca-survey-manager-sas | ||
build: | ||
noarch: python | ||
requirements: | ||
host: | ||
- python | ||
run: | ||
{% if 'extra_requires' in data %} | ||
{% for req in data['extra_requires'].get('sas', []) %} | ||
- {{ req }} | ||
{% endfor %} | ||
{% endif %} | ||
- {{ pin_subpackage('openfisca-survey-manager', exact=True) }} | ||
|
||
about: | ||
home: https://fr.openfisca.org/ | ||
license_family: AGPL | ||
license: AGPL-3.0-only | ||
license_file: LICENSE.AGPL.txt | ||
summary: "Survey-Manager module, to work with OpenFisca and survey data." | ||
description: | | ||
OpenFisca is a versatile microsimulation free software. | ||
This repository contains the Survey-Manager module, to work with OpenFisca and survey data. | ||
doc_url: https://fr.openfisca.org/ | ||
dev_url: https://github.com/openfisca/openfisca-survey-manager/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
.circleci/has-functional-changes.sh → .github/has-functional-changes.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#! /usr/bin/env bash | ||
|
||
current_version=$(grep '^version =' pyproject.toml | cut -d '"' -f 2) # parsing with tomllib is complicated, see https://github.com/python-poetry/poetry/issues/273 | ||
git tag $current_version | ||
git push --tags # update the repository version |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
# Read package version in pyproject.toml and replace it in .conda/recipe.yaml | ||
|
||
import argparse | ||
import logging | ||
import re | ||
|
||
logging.basicConfig(level=logging.INFO, format='%(message)s') | ||
PACKAGE_VERSION = 'X.X.X' | ||
CORE_VERSION = '>=43,<44' | ||
NUMPY_VERSION = '>=1.24.3,<2' | ||
|
||
|
||
def get_versions(): | ||
''' | ||
Read package version and deps in pyproject.toml | ||
''' | ||
# openfisca_core_api = None | ||
openfisca_survey_manager = None | ||
# numpy = None | ||
with open('./pyproject.toml', 'r') as file: | ||
content = file.read() | ||
# Extract the version of openfisca_survey_manager | ||
version_match = re.search(r'^version\s*=\s*"([\d.]*)"', content, re.MULTILINE) | ||
if version_match: | ||
openfisca_survey_manager = version_match.group(1) | ||
else: | ||
raise Exception('Package version not found in pyproject.toml') | ||
# Extract dependencies | ||
# version = re.search(r'openfisca-core\s*(>=\s*[\d\.]*,\s*<\d*)"', content, re.MULTILINE) | ||
# if version: | ||
# openfisca_core_api = version.group(1) | ||
# version = re.search(r'numpy\s*(>=\s*[\d\.]*,\s*<\d*)"', content, re.MULTILINE) | ||
# if version: | ||
# numpy = version.group(1) | ||
# if not openfisca_core_api or not numpy: | ||
# raise Exception('Dependencies not found in pyproject.toml') | ||
return { | ||
'openfisca_survey_manager': openfisca_survey_manager, | ||
# 'openfisca_core_api': openfisca_core_api.replace(' ', ''), | ||
# 'numpy': numpy.replace(' ', ''), | ||
} | ||
|
||
|
||
if __name__ == '__main__': | ||
parser = argparse.ArgumentParser() | ||
parser.add_argument('-r', '--replace', type=bool, default=False, required=False, help='replace in file') | ||
parser.add_argument('-f', '--filename', type=str, default='.conda/recipe.yaml', help='Path to recipe.yaml, with filename') | ||
parser.add_argument('-o', '--only_package_version', type=bool, default=False, help='Only display current package version') | ||
args = parser.parse_args() | ||
info = get_versions() | ||
file = args.filename | ||
if args.only_package_version: | ||
print(f'{info["openfisca_survey_manager"]}') # noqa: T201 | ||
exit() | ||
logging.info('Versions :') | ||
print(info) # noqa: T201 |
Oops, something went wrong.