changeset 916141498322 in cookiecutter:default
details: https://hg.tryton.org/cookiecutter?cmd=changeset;node=916141498322
description:
        Add support for local_version on trydevpi.tryton.org

        From pip 20.3 the new solver check that the consistency between the 
version of
        the package and the metadata published.
        When installing from the CI a local version is appended by setup.py to 
generate
        a unique version to not reuse the cache.
        The local version generated from the CI environment is passed as 
parameter to
        trydevpi so it can generate the proper metadata.
        The build os local version is simplified to allow tox substitution to 
replicate
        it.

        issue9928
        review320501002
diffstat:

 {{ cookiecutter.module_name }}/setup.py |  8 +++++---
 {{ cookiecutter.module_name }}/tox.ini  |  2 +-
 2 files changed, 6 insertions(+), 4 deletions(-)

diffs (27 lines):

diff -r 41ffe478a57d -r 916141498322 {{ cookiecutter.module_name }}/setup.py
--- a/{{ cookiecutter.module_name }}/setup.py   Sat Dec 05 14:24:50 2020 +0000
+++ b/{{ cookiecutter.module_name }}/setup.py   Thu Dec 10 23:06:28 2020 +0100
@@ -54,9 +54,11 @@
         'hg+http://hg.tryton.org/modules/%s#egg=%s-%s' % (
             name[8:], name, version))
 local_version = []
-for build in ['CI_BUILD_NUMBER', 'CI_JOB_NUMBER', 'CI_JOB_ID']:
-    if os.environ.get(build):
-        local_version.append(os.environ[build])
+if os.environ.get('CI_JOB_ID'):
+    local_version.append(os.environ['CI_JOB_ID'])
+else:
+    for build in ['CI_BUILD_NUMBER', 'CI_JOB_NUMBER']:
+        local_version.append(os.environ.get(build, ''))
 if local_version:
     version += '+' + '.'.join(local_version)
 {% endif %}
diff -r 41ffe478a57d -r 916141498322 {{ cookiecutter.module_name }}/tox.ini
--- a/{{ cookiecutter.module_name }}/tox.ini    Sat Dec 05 14:24:50 2020 +0000
+++ b/{{ cookiecutter.module_name }}/tox.ini    Thu Dec 10 23:06:28 2020 +0100
@@ -12,4 +12,4 @@
     postgresql: TRYTOND_DATABASE_URI={env:POSTGRESQL_URI:postgresql://}
     sqlite: DB_NAME={env:SQLITE_NAME::memory:}
     postgresql: DB_NAME={env:POSTGRESQL_NAME:test}
-install_command = pip install --pre --find-links 
https://trydevpi.tryton.org/{% if cookiecutter.prefix %}?mirror=github{% endif 
%} {opts} {packages}
+install_command = pip install --pre --find-links 
https://trydevpi.tryton.org/?local_version={env:CI_JOB_ID:{env:CI_BUILD_NUMBER}.{env:CI_JOB_NUMBER}}{%
 if cookiecutter.prefix %}&mirror=github{% endif %} {opts} {packages}

Reply via email to