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

Poetry 1.2 #1

Merged
merged 25 commits into from
Sep 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.9
python-version: "3.10"
- name: Install PyOxidizer
run: |
pip install pyoxidizer==0.22.0
Expand Down Expand Up @@ -113,7 +113,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.9
python-version: "3.10"
- name: Install PyOxidizer
run: |
pip install pyoxidizer==0.22.0
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.9
python-version: "3.10"
- name: Install PyOxidizer
run: |
pip install pyoxidizer==0.22.0
Expand Down Expand Up @@ -91,7 +91,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.9
python-version: "3.10"
- name: Install PyOxidizer
run: |
pip install pyoxidizer==0.22.0
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ on:
- "**"
paths:
- .github/workflows/test.yml
- Makefile
- vendor/**
pull_request:

Expand All @@ -16,7 +17,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.9]
python-version: ["3.10"]

steps:
- uses: actions/checkout@v2
Expand All @@ -32,7 +33,7 @@ jobs:
runs-on: macos-latest
strategy:
matrix:
python-version: [3.9]
python-version: ["3.10"]

steps:
- uses: actions/checkout@v2
Expand Down
52 changes: 29 additions & 23 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ BUILD_VERSION := latest

_path_build:
$(eval BUILDPATH := build/${ARCH}/release/${TARGET})
_path_bin:
$(eval BINPATH := ${BUILDPATH}${BIN_SUFFIX})
_path_lib: _path_build
$(eval LIBPATH := ${BUILDPATH}/lib)
_path_assets: _path_build
Expand All @@ -19,24 +17,37 @@ _path_assets: _path_build
clean_build: _path_build
@rm -rf ${BUILDPATH}

clean_src:
@rm -rf src/*

clean_dist:
@rm -rf dist

clean_vendor:
@rm -rf vendor

sources: clean_src
@git clone https://github.com/python/importlib_metadata.git src/importlib_metadata && cd src/importlib_metadata && git checkout v4.12.0
@git clone https://github.com/python-jsonschema/jsonschema.git src/jsonschema && cd src/jsonschema && git checkout v4.10.3
@git clone https://github.com/lark-parser/lark.git src/lark && cd src/lark && git checkout 1.1.2
@git clone https://github.com/python-poetry/poetry.git src/poetry && cd src/poetry && git checkout 1.2.0
@git clone https://github.com/python-poetry/poetry-core.git src/poetry-core && cd src/poetry-core && git checkout 1.1.0
@git clone https://github.com/pypa/virtualenv.git src/virtualenv && cd src/virtualenv && git checkout 20.16.3

patches:
@cd src/importlib_metadata && git diff --binary HEAD > ../../patches/importlib_metadata.patch
@cd src/jsonschema && git diff --binary HEAD > ../../patches/jsonschema.patch
@cd src/lark && git diff --binary HEAD > ../../patches/lark.patch
@cd src/poetry-core && git diff --binary HEAD > ../../patches/poetry-core.patch
@cd src/poetry && git diff --binary HEAD > ../../patches/poetry.patch
@cd src/requests && git diff --binary HEAD > ../../patches/requests.patch
@cd src/virtualenv && git diff --binary HEAD > ../../patches/virtualenv.patch

apply_patches:
@cd src/importlib_metadata && git apply --reject --ignore-whitespace ../../patches/importlib_metadata.patch
@cd src/jsonschema && git apply --reject --ignore-whitespace ../../patches/jsonschema.patch
@cd src/lark && git apply --reject --ignore-whitespace ../../patches/lark.patch
@cd src/poetry-core && git apply --reject --ignore-whitespace ../../patches/poetry-core.patch
@cd src/poetry && git apply --reject --ignore-whitespace ../../patches/poetry.patch
@cd src/requests && git apply --reject --ignore-whitespace ../../patches/requests.patch
@cd src/virtualenv && git apply --reject --ignore-whitespace ../../patches/virtualenv.patch

vendor: clean_vendor
Expand All @@ -50,25 +61,24 @@ tests:
.venv/bin/pip install .[testing] pyfakefs && \
.venv/bin/python -m unittest discover && \
rm -r .venv
@cd vendor/requests && \
python -m venv .venv && \
.venv/bin/pip install -e .[socks] && \
.venv/bin/pip install -r requirements-dev.txt && \
.venv/bin/pytest tests && \
rm -r .venv
@cd vendor/virtualenv && \
python -m venv .venv && \
.venv/bin/pip install .[testing] && \
.venv/bin/pytest && \
rm -r .venv
@cd vendor/poetry-core && \
python -m venv .venv && \
.venv/bin/pip install ../requests ../virtualenv . pep517 pytest pytest-mock && \
.venv/bin/pip install -r vendors/deps.txt && \
.venv/bin/pip install ../jsonschema ../lark ../virtualenv . && \
.venv/bin/pip install build pytest pytest-mock && \
.venv/bin/pytest && \
rm -r .venv
@cd vendor/poetry && \
python -m venv .venv && \
.venv/bin/pip install ../importlib_metadata ../requests ../virtualenv ../poetry-core . httpretty pytest pytest-mock==1.13.0 && \
.venv/bin/pip install ../importlib_metadata ../jsonschema ../lark ../virtualenv && \
.venv/bin/pip install -r ../poetry-core/vendors/deps.txt && \
.venv/bin/pip install ../poetry-core . && \
.venv/bin/pip install deepdiff flatdict httpretty pytest pytest-mock && \
.venv/bin/pytest && \
rm -r .venv

Expand All @@ -83,43 +93,39 @@ build_win: _build_win assets

_build_posix: _path_build _path_lib clean_build
pyoxidizer build --release --target-triple=${ARCH}
@mv ${BUILDPATH}/bin/lib ${BUILDPATH}
@cp -a vendor/poetry-core/poetry/core/_vendor/. ${LIBPATH}
@rm ${BUILDPATH}/COPYING.txt

_build_win: _path_build _path_lib clean_build
pyoxidizer build --release --target-triple=${ARCH} --var WIN_BUILD 1
@cp -a vendor/poetry-core/poetry/core/_vendor/. ${LIBPATH}

assets: _path_assets
@mkdir -p ${ASSETSPATH}
@mkdir -p ${ASSETSPATH}/core/version
@mkdir -p ${ASSETSPATH}/virtualenv/create
@mkdir -p ${ASSETSPATH}/virtualenv/discovery
@mkdir -p ${ASSETSPATH}/virtualenv/seed/wheels
@cp -R vendor/poetry-core/poetry/core/version/grammars ${ASSETSPATH}/core/version/grammars
@cp -R vendor/poetry-core/src/poetry/core/version/grammars ${ASSETSPATH}/core/version/grammars
@cp vendor/virtualenv/src/virtualenv/create/debug.py ${ASSETSPATH}/virtualenv/create/debug.py
@cp vendor/virtualenv/src/virtualenv/discovery/py_info.py ${ASSETSPATH}/virtualenv/discovery/py_info.py
@cp vendor/virtualenv/src/virtualenv/seed/wheels/embed/*.whl ${ASSETSPATH}/virtualenv/seed/wheels

sign: _path_build _path_lib
@codesign -s - ${BUILDPATH}/bin/poetry
@codesign -s - ${BUILDPATH}/poetry
@find ${LIBPATH} -name '*.so' -type f | xargs -I $$ codesign -s - $$

verify_build_linux: ARCH := ${ARCH_LINUX}
verify_build_linux: BIN_SUFFIX := /bin
verify_build_linux: _verify_build

verify_build_mac: ARCH := ${ARCH_MAC_INTEL}
verify_build_mac: BIN_SUFFIX := /bin
verify_build_mac: _verify_build

verify_build_win: ARCH := ${ARCH_WIN}
verify_build_win: _verify_build

_verify_build: _path_build _path_bin
${BINPATH}/poetry --version
${BINPATH}/poetry config virtualenvs.in-project true
@cd tests && ../${BINPATH}/poetry install
_verify_build: _path_build
${BUILDPATH}/poetry --version
${BUILDPATH}/poetry config virtualenvs.in-project true
@cd tests && ../${BUILDPATH}/poetry install -vvv
@rm -rf tests/.venv

pack_linux: ARCH := ${ARCH_LINUX}
Expand Down
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,16 @@

This project builds [Poetry](https://github.com/python-poetry/poetry) Python dependency management tool into a binary executable using [PyOxidizer](https://github.com/indygreg/PyOxidizer).

The aim is to have a Poetry instance which is fully independant of the local Python environment.
The aim is to have a Poetry instance fully independent of the local Python environment.

> **Note:** due to patches implemented over Poetry components, this build might introduce unwanted bugs over Poetry project, use at your own risk.

Due to its nature, `poetry-bin` has some key differences compared to the "vanilla version", specifically:

- `self` commands are dropped
- 1.2 plugins are not supported (yet?). The only included plugin is the `export` one
- the selection of the Python interpreter to use is slightly different, as it won't use `sys.executable` to make decisions

## Installation

You can install Poetry binary build using the install script:
Expand Down
58 changes: 29 additions & 29 deletions patches/importlib_metadata.patch
Original file line number Diff line number Diff line change
@@ -1,48 +1,48 @@
diff --git a/importlib_metadata/__init__.py b/importlib_metadata/__init__.py
index b01e7e3..0d8feb5 100644
index 8761307..9a5d8d2 100644
--- a/importlib_metadata/__init__.py
+++ b/importlib_metadata/__init__.py
@@ -228,10 +228,13 @@ class Distribution:
@@ -579,8 +579,12 @@ class Distribution:
if context and kwargs:
raise ValueError("cannot accept context and kwargs")
context = context or DistributionFinder.Context(**kwargs)
- return itertools.chain.from_iterable(
- resolver(context)
- for resolver in cls._discover_resolvers()
- resolver(context) for resolver in cls._discover_resolvers()
+ return filter(
+ lambda v: hasattr(v, "_path"),
+ itertools.chain.from_iterable(
+ resolver(context)
+ for resolver in cls._discover_resolvers()
)
+ )
+ )
)

@staticmethod
def at(path):
@@ -620,4 +623,4 @@ def requires(distribution_name):
return distribution(distribution_name).requires
diff --git a/pyproject.toml b/pyproject.toml
index 60de242..b240064 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -1,12 +1,10 @@
[build-system]
-requires = ["setuptools>=56", "setuptools_scm[toml]>=3.4.1"]
+requires = ["setuptools>=56"]
build-backend = "setuptools.build_meta"

[tool.black]
skip-string-normalization = true

-[tool.setuptools_scm]
-
[tool.pytest-enabler.black]
addopts = "--black"

-__version__ = version(__name__)
+__version__ = "1.7.0"
diff --git a/setup.cfg b/setup.cfg
index 5dd09a4..d989cd0 100644
index efd0a36..062f10b 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -16,7 +16,6 @@ classifiers =

[options]
python_requires = >=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*
-setup_requires = setuptools-scm
install_requires =
zipp>=0.5
pathlib2; python_version < '3'
diff --git a/setup.py b/setup.py
index d5d43d7..0c9823c 100644
--- a/setup.py
+++ b/setup.py
@@ -1,3 +1,3 @@
from setuptools import setup

-setup(use_scm_version=True)
+setup(use_scm_version=False)
@@ -1,5 +1,6 @@
[metadata]
name = importlib_metadata
+version = 4.12.0
author = Jason R. Coombs
author_email = jaraco@jaraco.com
description = Read metadata from Python packages
56 changes: 56 additions & 0 deletions patches/jsonschema.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
diff --git a/jsonschema/__version__.py b/jsonschema/__version__.py
new file mode 100644
index 0000000..d32a48d
--- /dev/null
+++ b/jsonschema/__version__.py
@@ -0,0 +1 @@
+__version__ = "4.10.3"
diff --git a/jsonschema/_utils.py b/jsonschema/_utils.py
index 7e11325..687b95a 100644
--- a/jsonschema/_utils.py
+++ b/jsonschema/_utils.py
@@ -5,11 +5,7 @@ import json
import re
import sys

-# The files() API was added in Python 3.9.
-if sys.version_info >= (3, 9): # pragma: no cover
- from importlib import resources
-else: # pragma: no cover
- import importlib_resources as resources # type: ignore
+from importlib import resources


class URIDict(MutableMapping):
@@ -56,10 +52,8 @@ def load_schema(name):
"""
Load a schema from ./schemas/``name``.json and return it.
"""
-
- path = resources.files(__package__).joinpath(f"schemas/{name}.json")
- data = path.read_text(encoding="utf-8")
- return json.loads(data)
+ from . import __name__
+ return json.loads(resources.read_text(f"{__name__}.schemas", f"{name}.json"))


def format_as_index(container, indices):
diff --git a/jsonschema/schemas/__init__.py b/jsonschema/schemas/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/pyproject.toml b/pyproject.toml
index 5041a10..46a3e40 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -1,9 +1,9 @@
[build-system]
-requires = ["hatchling", "hatch-vcs"]
+requires = ["hatchling"]
build-backend = "hatchling.build"

[tool.hatch.version]
-source = "vcs"
+path = "jsonschema/__version__.py"

[project]
name = "jsonschema"
Loading