Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change build system (backport #1247) #1262

Merged
merged 5 commits into from
Jun 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/gnocchi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ jobs:
strategy:
matrix:
env:
- build
- pep8
steps:
- uses: actions/checkout@v2
Expand Down
2 changes: 2 additions & 0 deletions .mergify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ queue_rules:
conditions:
- check-success=doc (docs)
- check-success=doc (docs-gnocchi-web)
- check-success=check (build)
- check-success=check (pep8)
- check-success=test (py36, mysql-file)
- check-success=test (py36, mysql-swift)
Expand Down Expand Up @@ -36,6 +37,7 @@ pull_request_rules:
- '#approved-reviews-by>=1'
- check-success=doc (docs)
- check-success=doc (docs-gnocchi-web)
- check-success=check (build)
- check-success=check (pep8)
- check-success=test (py36, mysql-file)
- check-success=test (py36, mysql-swift)
Expand Down
2 changes: 0 additions & 2 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
include ChangeLog
include AUTHORS
exclude .gitignore
exclude .github
137 changes: 0 additions & 137 deletions gnocchi/setuptools.py

This file was deleted.

5 changes: 5 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[build-system]
requires = ["setuptools", "setuptools_scm", "wheel"]
build-backend = "setuptools.build_meta"

[tool.setuptools_scm]
70 changes: 62 additions & 8 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,71 @@
# limitations under the License.

import setuptools
import sys

from setuptools.command import develop
from setuptools.command import easy_install
from setuptools.command import install_scripts


# NOTE(sileht): We use a template to set the right
# python version in the sheban
SCRIPT_TMPL = """
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
# implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import sys
from gnocchi.cli import api

if __name__ == '__main__':
sys.exit(api.api())
else:
application = api.wsgi()
"""


# Can't use six in this file it's too early in the bootstrap process
PY3 = sys.version_info >= (3,)


class local_install_scripts(install_scripts.install_scripts):
def run(self):
install_scripts.install_scripts.run(self)
# NOTE(sileht): Build wheel embed custom script as data, and put sheban
# in script of the building machine. To workaround that build_scripts
# on bdist_whell return '#!python' and then during whl install it's
# replaced by the correct interpreter. We do the same here.
bs_cmd = self.get_finalized_command('build_scripts')
executable = getattr(bs_cmd, 'executable', easy_install.sys_executable)
script = easy_install.get_script_header("", executable) + SCRIPT_TMPL
if PY3:
script = script.encode('ascii')
self.write_script("gnocchi-api", script, 'b')


class local_develop(develop.develop):
def install_wrapper_scripts(self, dist):
develop.develop.install_wrapper_scripts(self, dist)
if self.exclude_scripts:
return
script = easy_install.get_script_header("") + SCRIPT_TMPL
if PY3:
script = script.encode('ascii')
self.write_script("gnocchi-api", script, 'b')

import gnocchi.setuptools

cmdclass = {
'egg_info': gnocchi.setuptools.local_egg_info,
'develop': gnocchi.setuptools.local_develop,
'install_scripts': gnocchi.setuptools.local_install_scripts,
'develop': local_develop,
'install_scripts': local_install_scripts,
}

try:
Expand All @@ -32,10 +90,6 @@


setuptools.setup(
setup_requires=['setuptools>=30.3.0',
'setuptools_scm!=1.16.0,!=1.16.1,!=1.16.2'],
# Remove any local stuff to mimic pbr
use_scm_version={'local_scheme': lambda v: ""},
cmdclass=cmdclass,
py_modules=[],
)
5 changes: 5 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,11 @@ deps =
xattr!=0.9.4
commands = {toxinidir}/run-upgrade-tests.sh mysql-ceph

[testenv:build]
basepython = python3
deps = build
commands = python3 -m build

[testenv:pep8]
basepython = python3
deps = hacking>=0.12
Expand Down