From a42d5196d1bfb40153d83822a6d9724ceb04ceb1 Mon Sep 17 00:00:00 2001 From: Lan Yao Date: Thu, 2 Mar 2023 14:37:34 -0800 Subject: [PATCH 1/2] add entry_point and setuptools-git --- pip/BUILD | 1 + pip/requirements.txt | 1 + pip/rules.bzl | 4 ++++ pip/templates/setup.py | 3 ++- 4 files changed, 8 insertions(+), 1 deletion(-) diff --git a/pip/BUILD b/pip/BUILD index 9600afb3..f7452896 100644 --- a/pip/BUILD +++ b/pip/BUILD @@ -36,6 +36,7 @@ py_binary( srcs = ["assemble.py"], deps = [ vaticle_bazel_distribution_requirement("setuptools"), + vaticle_bazel_distribution_requirement("setuptools-git"), vaticle_bazel_distribution_requirement("wheel") ], visibility = ["//visibility:public"] diff --git a/pip/requirements.txt b/pip/requirements.txt index a1a27281..29bc27af 100644 --- a/pip/requirements.txt +++ b/pip/requirements.txt @@ -35,3 +35,4 @@ urllib3==1.26.14 webencodings==0.5.1 wheel==0.38.4 zipp==3.11.0 +setuptools-git==1.2 diff --git a/pip/rules.bzl b/pip/rules.bzl index 6c91c742..582f416a 100644 --- a/pip/rules.bzl +++ b/pip/rules.bzl @@ -121,6 +121,7 @@ def _assemble_pip_impl(ctx): "{license}": ctx.attr.license, "{long_description_file}": ctx.file.long_description_file.path, "{python_requires}": ctx.attr.python_requires, + "{entry_points}": str(ctx.attr.entry_points), }, ) @@ -285,6 +286,9 @@ assemble_pip = rule( default = ">0", doc = "If your project only runs on certain Python versions, setting the python_requires argument to the appropriate PEP 440 version specifier string will prevent pip from installing the project on other Python versions.", ), + "entry_points": attr.string_list_dict( + doc = "entry_points for setuptools." + ), "_setup_py_template": attr.label( allow_single_file = True, default = "//pip/templates:setup.py", diff --git a/pip/templates/setup.py b/pip/templates/setup.py index bf816c83..84ff8ec4 100644 --- a/pip/templates/setup.py +++ b/pip/templates/setup.py @@ -39,5 +39,6 @@ install_requires=INSTALL_REQUIRES_PLACEHOLDER, zip_safe=False, python_requires="{python_requires}", - setup_requires=["wheel"] + entry_points={entry_points}, + setup_requires=["setuptools-git", "wheel"] ) From 9a1ecf366f84708a841e81c1dd9e906a5fb85855 Mon Sep 17 00:00:00 2001 From: Lan Yao Date: Thu, 2 Mar 2023 23:00:53 -0800 Subject: [PATCH 2/2] remove generate init file for package --- pip/assemble.py | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/pip/assemble.py b/pip/assemble.py index e133f1d7..8436190b 100644 --- a/pip/assemble.py +++ b/pip/assemble.py @@ -28,14 +28,6 @@ from setuptools.sandbox import run_setup -def create_init_files(directory): - from os import walk - from os.path import join - for dirName, subdirList, fileList in walk(directory): - if "__init__.py" not in fileList: - open(join(dirName, "__init__.py"), "w").close() - - parser = argparse.ArgumentParser() parser.add_argument('--output_sdist', help="Output archive") parser.add_argument('--output_wheel', help="Output archive") @@ -110,9 +102,6 @@ def create_init_files(directory): # change directory into new package root os.chdir(pkg_dir) -# ensure every folder is a Python package -create_init_files(pkg_dir) - # pack sources run_setup(setup_py, ['sdist', 'bdist_wheel'])