├── tests ├── __init__.py ├── utils │ ├── __init__.py │ ├── fixtures │ │ ├── setups │ │ │ ├── with-setup-cfg │ │ │ │ ├── setup.py │ │ │ │ └── setup.cfg │ │ │ ├── with-setup-cfg-attr │ │ │ │ ├── setup.py │ │ │ │ └── setup.cfg │ │ │ ├── extras_require_with_vars │ │ │ │ └── setup.py │ │ │ ├── setuptools_setup │ │ │ │ └── setup.py │ │ │ ├── ansible │ │ │ │ └── requirements.txt │ │ │ └── pendulum │ │ │ │ └── setup.py │ │ └── pyproject.toml │ ├── test_pip.py │ └── test_env_site.py ├── config │ ├── __init__.py │ └── test_config.py ├── console │ ├── __init__.py │ └── commands │ │ ├── __init__.py │ │ ├── env │ │ ├── __init__.py │ │ ├── helpers.py │ │ ├── test_list.py │ │ ├── test_remove.py │ │ ├── conftest.py │ │ └── test_info.py │ │ ├── debug │ │ ├── __init__.py │ │ └── test_resolve.py │ │ ├── plugin │ │ ├── __init__.py │ │ └── conftest.py │ │ ├── self │ │ ├── __init__.py │ │ └── fixtures │ │ │ ├── poetry-1.0.5-darwin.sha256sum │ │ │ └── poetry-1.0.5-darwin.tar.gz │ │ ├── source │ │ ├── __init__.py │ │ ├── test_remove.py │ │ └── conftest.py │ │ ├── test_about.py │ │ ├── test_run.py │ │ ├── test_install.py │ │ ├── test_check.py │ │ └── test_cache.py ├── mixology │ ├── __init__.py │ ├── solutions │ │ ├── __init__.py │ │ ├── providers │ │ │ ├── __init__.py │ │ │ └── test_python_requirement_solution_provider.py │ │ └── solutions │ │ │ ├── __init__.py │ │ │ └── test_python_requirement_solution.py │ ├── version_solver │ │ ├── __init__.py │ │ ├── test_python_constraint.py │ │ └── conftest.py │ └── helpers.py ├── packages │ └── __init__.py ├── publishing │ └── __init__.py ├── puzzle │ ├── __init__.py │ └── conftest.py ├── installation │ ├── __init__.py │ └── fixtures │ │ ├── no-dependencies.test │ │ ├── remove.test │ │ ├── update-with-lock.test │ │ ├── with-dependencies.test │ │ ├── with-prereleases.test │ │ ├── with-category-change.test │ │ ├── with-conditional-dependency.test │ │ ├── install-no-dev.test │ │ ├── with-wheel-dependency-no-requires-dist.test │ │ ├── with-python-versions.test │ │ ├── with-optional-dependencies.test │ │ ├── with-duplicate-dependencies-update.test │ │ ├── with-dependencies-extras.test │ │ ├── with-url-dependency.test │ │ ├── extras.test │ │ ├── with-directory-dependency-poetry.test │ │ ├── extras-with-dependencies.test │ │ ├── with-platform-dependencies.test │ │ ├── with-sub-dependencies.test │ │ ├── with-file-dependency.test │ │ ├── with-dependencies-nested-extras.test │ │ ├── with-directory-dependency-setuptools.test │ │ ├── update-with-locked-extras.test │ │ ├── with-multiple-updates.test │ │ └── with-duplicate-dependencies.test ├── repositories │ ├── __init__.py │ └── fixtures │ │ ├── installed │ │ ├── lib │ │ │ └── python3.7 │ │ │ │ └── site-packages │ │ │ │ ├── standard.pth │ │ │ │ ├── editable.pth │ │ │ │ ├── editable-with-import.pth │ │ │ │ ├── directory_pep_610-1.2.3.dist-info │ │ │ │ ├── direct_url.json │ │ │ │ └── METADATA │ │ │ │ ├── url_pep_610-1.2.3.dist-info │ │ │ │ ├── direct_url.json │ │ │ │ └── METADATA │ │ │ │ ├── file_pep_610-1.2.3.dist-info │ │ │ │ ├── METADATA │ │ │ │ └── direct_url.json │ │ │ │ ├── foo-0.1.0-py3.8.egg │ │ │ │ ├── git_pep_610-1.2.3.dist-info │ │ │ │ ├── METADATA │ │ │ │ └── direct_url.json │ │ │ │ ├── editable_directory_pep_610-1.2.3.dist-info │ │ │ │ ├── direct_url.json │ │ │ │ └── METADATA │ │ │ │ ├── editable-2.3.4.dist-info │ │ │ │ └── METADATA │ │ │ │ ├── standard-1.2.3.dist-info │ │ │ │ └── METADATA │ │ │ │ └── editable-with-import-2.3.4.dist-info │ │ │ │ └── METADATA │ │ ├── lib64 │ │ │ └── python3.7 │ │ │ │ └── site-packages │ │ │ │ ├── bender.pth │ │ │ │ ├── bender-2.0.5.dist-info │ │ │ │ └── METADATA │ │ │ │ └── lib64-2.3.4.dist-info │ │ │ │ └── METADATA │ │ └── src │ │ │ ├── pendulum │ │ │ └── pendulum.egg-info │ │ │ │ └── requires.txt │ │ │ └── bender │ │ │ └── bender.egg-info │ │ │ └── PKG-INFO │ │ ├── pypi.org │ │ └── dists │ │ │ ├── isort-4.3.4.tar.gz │ │ │ ├── pastel-0.1.0.tar.gz │ │ │ ├── futures-3.2.0.tar.gz │ │ │ ├── ipython-5.7.0.tar.gz │ │ │ ├── jupyter-1.0.0.tar.gz │ │ │ ├── tomlkit-0.5.2.tar.gz │ │ │ ├── tomlkit-0.5.3.tar.gz │ │ │ ├── SQLAlchemy-1.2.12.tar.gz │ │ │ ├── Twisted-18.9.0.tar.bz2 │ │ │ ├── isort-4.3.4-py2-none-any.whl │ │ │ ├── isort-4.3.4-py3-none-any.whl │ │ │ ├── black-19.10b0-py36-none-any.whl │ │ │ ├── futures-3.2.0-py2-none-any.whl │ │ │ ├── ipython-5.7.0-py2-none-any.whl │ │ │ ├── ipython-5.7.0-py3-none-any.whl │ │ │ ├── ipython-7.5.0-py3-none-any.whl │ │ │ ├── clikit-0.2.4-py2.py3-none-any.whl │ │ │ ├── jupyter-1.0.0-py2.py3-none-any.whl │ │ │ └── python-language-server-0.21.2.tar.gz │ │ └── legacy │ │ ├── jupyter.html │ │ ├── missing-version.html │ │ ├── pastel.html │ │ ├── black.html │ │ ├── tomlkit.html │ │ ├── python-language-server.html │ │ ├── relative.html │ │ ├── absolute.html │ │ ├── futures.html │ │ ├── pytest.html │ │ ├── isort.html │ │ ├── pyyaml.html │ │ ├── ipython.html │ │ └── clikit.html ├── fixtures │ ├── with-include │ │ ├── notes.txt │ │ ├── my_module.py │ │ ├── extra_dir │ │ │ ├── README.md │ │ │ ├── __init__.py │ │ │ ├── sub_pkg │ │ │ │ ├── __init__.py │ │ │ │ └── vcs_excluded.txt │ │ │ └── vcs_excluded.txt │ │ ├── tests │ │ │ └── __init__.py │ │ ├── for_wheel_only │ │ │ └── __init__.py │ │ ├── src │ │ │ └── src_package │ │ │ │ └── __init__.py │ │ ├── README.rst │ │ ├── package_with_include │ │ │ └── __init__.py │ │ ├── LICENSE │ │ └── pyproject.toml │ ├── extended_project │ │ ├── build.py │ │ ├── extended_project │ │ │ └── __init__.py │ │ ├── README.rst │ │ └── pyproject.toml │ ├── extended_project_without_setup │ │ ├── build.py │ │ ├── extended_project │ │ │ └── __init__.py │ │ ├── README.rst │ │ └── pyproject.toml │ ├── project_with_setup │ │ ├── my_package │ │ │ └── __init__.py │ │ ├── project_with_setup.egg-info │ │ │ ├── dependency_links.txt │ │ │ ├── top_level.txt │ │ │ ├── requires.txt │ │ │ ├── SOURCES.txt │ │ │ └── PKG-INFO │ │ └── setup.py │ ├── simple_project │ │ ├── simple_project │ │ │ └── __init__.py │ │ ├── README.rst │ │ ├── dist │ │ │ ├── simple-project-1.2.3.tar.gz │ │ │ └── simple_project-1.2.3-py2.py3-none-any.whl │ │ └── pyproject.toml │ ├── excluded_subpackage │ │ ├── example │ │ │ ├── test │ │ │ │ ├── __init__.py │ │ │ │ └── excluded.py │ │ │ └── __init__.py │ │ ├── README.rst │ │ └── pyproject.toml │ ├── git │ │ └── github.com │ │ │ └── demo │ │ │ ├── prerelease │ │ │ ├── prerelease │ │ │ │ └── __init__.py │ │ │ └── pyproject.toml │ │ │ ├── pyproject-demo │ │ │ ├── demo │ │ │ │ └── __init__.py │ │ │ └── pyproject.toml │ │ │ ├── demo │ │ │ ├── demo.egg-info │ │ │ │ ├── dependency_links.txt │ │ │ │ ├── top_level.txt │ │ │ │ ├── requires.txt │ │ │ │ ├── SOURCES.txt │ │ │ │ └── PKG-INFO │ │ │ ├── demo │ │ │ │ └── __init__.py │ │ │ └── setup.py │ │ │ ├── poetry-plugin │ │ │ ├── poetry_plugin │ │ │ │ └── __init__.py │ │ │ └── pyproject.toml │ │ │ ├── no-dependencies │ │ │ ├── demo.egg-info │ │ │ │ ├── dependency_links.txt │ │ │ │ ├── top_level.txt │ │ │ │ ├── SOURCES.txt │ │ │ │ └── PKG-INFO │ │ │ ├── demo │ │ │ │ └── __init__.py │ │ │ └── setup.py │ │ │ ├── no-version │ │ │ ├── demo │ │ │ │ └── __init__.py │ │ │ └── setup.py │ │ │ ├── non-canonical-name │ │ │ ├── Demo.egg-info │ │ │ │ ├── dependency_links.txt │ │ │ │ ├── top_level.txt │ │ │ │ ├── requires.txt │ │ │ │ ├── SOURCES.txt │ │ │ │ └── PKG-INFO │ │ │ ├── demo │ │ │ │ └── __init__.py │ │ │ └── setup.py │ │ │ └── namespace-package-one │ │ │ ├── namespace_package │ │ │ ├── one │ │ │ │ └── __init__.py │ │ │ └── __init__.py │ │ │ └── setup.py │ ├── project_with_extras │ │ ├── project_with_extras │ │ │ └── __init__.py │ │ └── pyproject.toml │ ├── sample_project │ │ ├── README.rst │ │ └── pyproject.toml │ ├── with_local_config │ │ ├── README.rst │ │ ├── poetry.toml │ │ └── pyproject.toml │ ├── project_with_multi_constraints_dependency │ │ ├── project │ │ │ └── __init__.py │ │ └── pyproject.toml │ ├── with_default_source │ │ ├── README.rst │ │ └── pyproject.toml │ ├── with_two_default_sources │ │ └── README.rst │ ├── directory │ │ ├── project_with_transitive_file_dependencies │ │ │ ├── project_with_transitive_file_dependencies │ │ │ │ └── __init__.py │ │ │ ├── inner-directory-project │ │ │ │ └── pyproject.toml │ │ │ └── pyproject.toml │ │ └── project_with_transitive_directory_dependencies │ │ │ ├── project_with_transitive_directory_dependencies │ │ │ └── __init__.py │ │ │ ├── pyproject.toml │ │ │ └── setup.py │ ├── inspection │ │ ├── demo_only_requires_txt.egg-info │ │ │ ├── requires.txt │ │ │ └── PKG-INFO │ │ ├── demo_with_obsolete_egg_info │ │ │ ├── demo-0.1.0.egg-info │ │ │ │ ├── requires.txt │ │ │ │ └── PKG-INFO │ │ │ └── pyproject.toml │ │ ├── demo_no_setup_pkg_info_no_deps │ │ │ ├── PKG-INFO │ │ │ └── pyproject.toml │ │ └── demo │ │ │ └── pyproject.toml │ ├── distributions │ │ ├── demo-0.1.0.tar.gz │ │ └── demo-0.1.0-py2.py3-none-any.whl │ ├── wheel_with_no_requires_dist │ │ └── demo-0.1.0-py2.py3-none-any.whl │ ├── invalid_pyproject │ │ └── pyproject.toml │ ├── project_with_nested_local │ │ ├── quix │ │ │ └── pyproject.toml │ │ ├── foo │ │ │ └── pyproject.toml │ │ ├── bar │ │ │ └── pyproject.toml │ │ └── pyproject.toml │ ├── outdated_lock │ │ └── pyproject.toml │ ├── up_to_date_lock │ │ └── pyproject.toml │ ├── old_lock │ │ ├── pyproject.toml │ │ └── poetry.lock │ ├── with_non_default_source │ │ └── pyproject.toml │ ├── with_non_default_secondary_source │ │ └── pyproject.toml │ ├── with_non_default_multiple_sources │ │ └── pyproject.toml │ ├── with_non_default_multiple_secondary_sources │ │ └── pyproject.toml │ ├── project_with_git_dev_dependency │ │ └── pyproject.toml │ ├── project_with_local_dependencies │ │ └── pyproject.toml │ └── complete.toml ├── masonry │ └── builders │ │ └── fixtures │ │ ├── pep_561_stub_only │ │ ├── pkg-stubs │ │ │ ├── __init__.pyi │ │ │ ├── subpkg │ │ │ │ └── __init__.pyi │ │ │ └── module.pyi │ │ └── pyproject.toml │ │ ├── excluded_subpackage │ │ ├── example │ │ │ ├── test │ │ │ │ ├── __init__.py │ │ │ │ └── excluded.py │ │ │ └── __init__.py │ │ ├── README.rst │ │ └── pyproject.toml │ │ ├── pep_561_stub_only_partial │ │ ├── pkg-stubs │ │ │ ├── __init__.pyi │ │ │ ├── py.typed │ │ │ ├── subpkg │ │ │ │ └── __init__.pyi │ │ │ └── module.pyi │ │ └── pyproject.toml │ │ └── pep_561_stub_only_src │ │ ├── src │ │ └── pkg-stubs │ │ │ ├── __init__.pyi │ │ │ ├── subpkg │ │ │ └── __init__.pyi │ │ │ └── module.pyi │ │ └── pyproject.toml └── compat.py ├── poetry ├── config │ ├── __init__.py │ ├── config_source.py │ ├── source.py │ └── dict_config_source.py ├── console │ ├── __init__.py │ ├── events │ │ ├── __init__.py │ │ └── console_events.py │ ├── io │ │ ├── __init__.py │ │ └── inputs │ │ │ └── __init__.py │ ├── commands │ │ ├── __init__.py │ │ ├── cache │ │ │ ├── __init__.py │ │ │ └── list.py │ │ ├── debug │ │ │ ├── __init__.py │ │ │ └── info.py │ │ ├── env │ │ │ ├── __init__.py │ │ │ ├── remove.py │ │ │ ├── use.py │ │ │ └── list.py │ │ ├── plugin │ │ │ └── __init__.py │ │ ├── self │ │ │ └── __init__.py │ │ ├── source │ │ │ ├── __init__.py │ │ │ ├── update.py │ │ │ └── remove.py │ │ ├── env_command.py │ │ ├── about.py │ │ ├── search.py │ │ ├── command.py │ │ ├── installer_command.py │ │ ├── check.py │ │ ├── build.py │ │ ├── shell.py │ │ ├── lock.py │ │ └── update.py │ ├── logging │ │ ├── __init__.py │ │ ├── formatters │ │ │ ├── formatter.py │ │ │ ├── __init__.py │ │ │ └── builder_formatter.py │ │ ├── io_handler.py │ │ └── io_formatter.py │ ├── exceptions.py │ └── command_loader.py ├── layouts │ ├── standard.py │ ├── src.py │ └── __init__.py ├── masonry │ ├── __init__.py │ ├── builders │ │ └── __init__.py │ └── api.py ├── utils │ ├── __init__.py │ ├── patterns.py │ └── _compat.py ├── version │ └── __init__.py ├── inspection │ └── __init__.py ├── mixology │ ├── solutions │ │ ├── __init__.py │ │ ├── solutions │ │ │ └── __init__.py │ │ └── providers │ │ │ ├── __init__.py │ │ │ └── python_requirement_solution_provider.py │ ├── set_relation.py │ ├── __init__.py │ └── result.py ├── _vendor │ └── .gitignore ├── __version__.py ├── puzzle │ ├── __init__.py │ └── exceptions.py ├── installation │ ├── __init__.py │ ├── operations │ │ ├── __init__.py │ │ ├── install.py │ │ ├── uninstall.py │ │ ├── operation.py │ │ └── update.py │ ├── base_installer.py │ └── noop_installer.py ├── publishing │ └── __init__.py ├── repositories │ ├── __init__.py │ ├── exceptions.py │ ├── remote_repository.py │ └── base_repository.py ├── __init__.py ├── __main__.py ├── exceptions.py ├── plugins │ ├── base_plugin.py │ ├── __init__.py │ ├── application_plugin.py │ └── plugin.py ├── packages │ ├── __init__.py │ ├── project_package.py │ ├── package_collection.py │ └── dependency_package.py ├── locations.py └── json │ └── __init__.py ├── assets └── install.gif ├── mypy.ini ├── tox.ini ├── .github ├── ISSUE_TEMPLATE │ ├── config.yml │ ├── ---documentation.md │ ├── ---feature-request.md │ ├── ---everything-else.md │ └── ---bug-report.md ├── workflows │ ├── code-quality.yaml │ ├── skip.yml │ └── release.yml ├── PULL_REQUEST_TEMPLATE.md └── stale.yml ├── .flake8 ├── .gitignore ├── make-nix-release.sh ├── .pre-commit-config.yaml ├── .cirrus.yml └── LICENSE /tests/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/utils/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /poetry/config/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /poetry/console/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /poetry/layouts/standard.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /poetry/masonry/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /poetry/utils/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /poetry/version/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/config/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/console/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/mixology/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/packages/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/publishing/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/puzzle/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /poetry/console/events/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /poetry/console/io/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /poetry/inspection/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/installation/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/repositories/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /poetry/console/commands/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /poetry/console/io/inputs/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /poetry/console/logging/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /poetry/mixology/solutions/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/console/commands/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/console/commands/env/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/fixtures/with-include/notes.txt: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/mixology/solutions/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /poetry/console/commands/cache/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /poetry/console/commands/debug/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /poetry/console/commands/env/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /poetry/console/commands/plugin/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /poetry/console/commands/self/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /poetry/console/commands/source/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /poetry/console/commands/source/update.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /poetry/console/events/console_events.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/console/commands/debug/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/console/commands/plugin/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/console/commands/self/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/console/commands/source/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/fixtures/extended_project/build.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/fixtures/with-include/my_module.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /poetry/_vendor/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /tests/fixtures/with-include/extra_dir/README.md: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/fixtures/with-include/tests/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/mixology/solutions/providers/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/mixology/solutions/solutions/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /poetry/__version__.py: -------------------------------------------------------------------------------- 1 | __version__ = "1.2.0a2" 2 | -------------------------------------------------------------------------------- /tests/fixtures/with-include/extra_dir/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /poetry/puzzle/__init__.py: -------------------------------------------------------------------------------- 1 | from .solver import Solver 2 | -------------------------------------------------------------------------------- /tests/fixtures/extended_project_without_setup/build.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/fixtures/project_with_setup/my_package/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/fixtures/simple_project/simple_project/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/fixtures/with-include/extra_dir/sub_pkg/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/fixtures/with-include/extra_dir/vcs_excluded.txt: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/fixtures/with-include/for_wheel_only/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/fixtures/with-include/src/src_package/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/fixtures/excluded_subpackage/example/test/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/fixtures/extended_project/extended_project/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/fixtures/with-include/extra_dir/sub_pkg/vcs_excluded.txt: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /poetry/installation/__init__.py: -------------------------------------------------------------------------------- 1 | from .installer import Installer 2 | -------------------------------------------------------------------------------- /poetry/publishing/__init__.py: -------------------------------------------------------------------------------- 1 | from .publisher import Publisher 2 | -------------------------------------------------------------------------------- /tests/fixtures/git/github.com/demo/prerelease/prerelease/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/fixtures/git/github.com/demo/pyproject-demo/demo/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/fixtures/project_with_extras/project_with_extras/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/fixtures/with-include/README.rst: -------------------------------------------------------------------------------- 1 | My Package 2 | ========== 3 | -------------------------------------------------------------------------------- /tests/fixtures/extended_project/README.rst: -------------------------------------------------------------------------------- 1 | My Package 2 | ========== 3 | -------------------------------------------------------------------------------- /tests/fixtures/sample_project/README.rst: -------------------------------------------------------------------------------- 1 | My Package 2 | ========== 3 | -------------------------------------------------------------------------------- /tests/fixtures/simple_project/README.rst: -------------------------------------------------------------------------------- 1 | My Package 2 | ========== 3 | -------------------------------------------------------------------------------- /tests/fixtures/with_local_config/README.rst: -------------------------------------------------------------------------------- 1 | My Package 2 | ========== 3 | -------------------------------------------------------------------------------- /tests/masonry/builders/fixtures/pep_561_stub_only/pkg-stubs/__init__.pyi: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /poetry/masonry/builders/__init__.py: -------------------------------------------------------------------------------- 1 | from .editable import EditableBuilder 2 | -------------------------------------------------------------------------------- /tests/fixtures/excluded_subpackage/README.rst: -------------------------------------------------------------------------------- 1 | My Package 2 | ========== 3 | -------------------------------------------------------------------------------- /tests/fixtures/extended_project_without_setup/extended_project/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/fixtures/git/github.com/demo/demo/demo.egg-info/dependency_links.txt: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/fixtures/git/github.com/demo/demo/demo.egg-info/top_level.txt: -------------------------------------------------------------------------------- 1 | demo 2 | -------------------------------------------------------------------------------- /tests/fixtures/git/github.com/demo/poetry-plugin/poetry_plugin/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/fixtures/project_with_multi_constraints_dependency/project/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/fixtures/with_default_source/README.rst: -------------------------------------------------------------------------------- 1 | My Package 2 | ========== 3 | -------------------------------------------------------------------------------- /tests/masonry/builders/fixtures/excluded_subpackage/example/test/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/fixtures/excluded_subpackage/example/__init__.py: -------------------------------------------------------------------------------- 1 | __version__ = "0.1.0" 2 | -------------------------------------------------------------------------------- /tests/fixtures/git/github.com/demo/demo/demo/__init__.py: -------------------------------------------------------------------------------- 1 | __version__ = "1.2.3" 2 | -------------------------------------------------------------------------------- /tests/fixtures/project_with_setup/project_with_setup.egg-info/dependency_links.txt: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/fixtures/with_two_default_sources/README.rst: -------------------------------------------------------------------------------- 1 | My Package 2 | ========== 3 | -------------------------------------------------------------------------------- /tests/masonry/builders/fixtures/pep_561_stub_only/pkg-stubs/subpkg/__init__.pyi: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/masonry/builders/fixtures/pep_561_stub_only_partial/pkg-stubs/__init__.pyi: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/masonry/builders/fixtures/pep_561_stub_only_src/src/pkg-stubs/__init__.pyi: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/fixtures/extended_project_without_setup/README.rst: -------------------------------------------------------------------------------- 1 | My Package 2 | ========== 3 | -------------------------------------------------------------------------------- /tests/fixtures/git/github.com/demo/no-dependencies/demo.egg-info/dependency_links.txt: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/fixtures/git/github.com/demo/no-dependencies/demo.egg-info/top_level.txt: -------------------------------------------------------------------------------- 1 | demo 2 | -------------------------------------------------------------------------------- /tests/fixtures/git/github.com/demo/no-version/demo/__init__.py: -------------------------------------------------------------------------------- 1 | __version__ = "1.2.3" 2 | -------------------------------------------------------------------------------- /tests/fixtures/git/github.com/demo/non-canonical-name/Demo.egg-info/dependency_links.txt: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/fixtures/with-include/package_with_include/__init__.py: -------------------------------------------------------------------------------- 1 | __version__ = "1.2.3" 2 | -------------------------------------------------------------------------------- /tests/masonry/builders/fixtures/pep_561_stub_only_partial/pkg-stubs/py.typed: -------------------------------------------------------------------------------- 1 | partial 2 | -------------------------------------------------------------------------------- /tests/masonry/builders/fixtures/pep_561_stub_only_partial/pkg-stubs/subpkg/__init__.pyi: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/masonry/builders/fixtures/pep_561_stub_only_src/src/pkg-stubs/subpkg/__init__.pyi: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/repositories/fixtures/installed/lib/python3.7/site-packages/standard.pth: -------------------------------------------------------------------------------- 1 | standard -------------------------------------------------------------------------------- /tests/fixtures/git/github.com/demo/no-dependencies/demo/__init__.py: -------------------------------------------------------------------------------- 1 | __version__ = "1.2.3" 2 | -------------------------------------------------------------------------------- /tests/fixtures/git/github.com/demo/non-canonical-name/Demo.egg-info/top_level.txt: -------------------------------------------------------------------------------- 1 | demo 2 | -------------------------------------------------------------------------------- /tests/fixtures/project_with_setup/project_with_setup.egg-info/top_level.txt: -------------------------------------------------------------------------------- 1 | my_package 2 | -------------------------------------------------------------------------------- /tests/masonry/builders/fixtures/excluded_subpackage/README.rst: -------------------------------------------------------------------------------- 1 | My Package 2 | ========== 3 | -------------------------------------------------------------------------------- /assets/install.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/serverwentdown/poetry/master/assets/install.gif -------------------------------------------------------------------------------- /poetry/repositories/__init__.py: -------------------------------------------------------------------------------- 1 | from .pool import Pool 2 | from .repository import Repository 3 | -------------------------------------------------------------------------------- /tests/fixtures/git/github.com/demo/non-canonical-name/demo/__init__.py: -------------------------------------------------------------------------------- 1 | __version__ = "1.2.3" 2 | -------------------------------------------------------------------------------- /tests/masonry/builders/fixtures/excluded_subpackage/example/__init__.py: -------------------------------------------------------------------------------- 1 | __version__ = "0.1.0" 2 | -------------------------------------------------------------------------------- /tests/repositories/fixtures/installed/lib64/python3.7/site-packages/bender.pth: -------------------------------------------------------------------------------- 1 | ../../../src/bender -------------------------------------------------------------------------------- /tests/repositories/fixtures/installed/lib/python3.7/site-packages/editable.pth: -------------------------------------------------------------------------------- 1 | /path/to/editable 2 | -------------------------------------------------------------------------------- /tests/utils/fixtures/setups/with-setup-cfg/setup.py: -------------------------------------------------------------------------------- 1 | from setuptools import setup 2 | 3 | setup() 4 | -------------------------------------------------------------------------------- /tests/compat.py: -------------------------------------------------------------------------------- 1 | try: 2 | import zipp 3 | except ImportError: 4 | import zipfile as zipp # noqa 5 | -------------------------------------------------------------------------------- /tests/fixtures/git/github.com/demo/namespace-package-one/namespace_package/one/__init__.py: -------------------------------------------------------------------------------- 1 | name = "one" 2 | -------------------------------------------------------------------------------- /tests/fixtures/with_local_config/poetry.toml: -------------------------------------------------------------------------------- 1 | [virtualenvs] 2 | in-project = false 3 | create = false 4 | -------------------------------------------------------------------------------- /tests/repositories/fixtures/installed/lib/python3.7/site-packages/editable-with-import.pth: -------------------------------------------------------------------------------- 1 | import os 2 | -------------------------------------------------------------------------------- /tests/utils/fixtures/setups/with-setup-cfg-attr/setup.py: -------------------------------------------------------------------------------- 1 | from setuptools import setup 2 | 3 | setup() 4 | -------------------------------------------------------------------------------- /poetry/__init__.py: -------------------------------------------------------------------------------- 1 | from pkgutil import extend_path 2 | 3 | 4 | __path__ = extend_path(__path__, __name__) 5 | -------------------------------------------------------------------------------- /poetry/mixology/solutions/solutions/__init__.py: -------------------------------------------------------------------------------- 1 | from .python_requirement_solution import PythonRequirementSolution 2 | -------------------------------------------------------------------------------- /tests/fixtures/directory/project_with_transitive_file_dependencies/project_with_transitive_file_dependencies/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/fixtures/project_with_setup/project_with_setup.egg-info/requires.txt: -------------------------------------------------------------------------------- 1 | pendulum>=1.4.4 2 | cachy[msgpack]>=0.2.0 3 | -------------------------------------------------------------------------------- /tests/fixtures/directory/project_with_transitive_directory_dependencies/project_with_transitive_directory_dependencies/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/mixology/version_solver/__init__.py: -------------------------------------------------------------------------------- 1 | import pytest 2 | 3 | 4 | pytest.register_assert_rewrite("tests.mixology.helpers") 5 | -------------------------------------------------------------------------------- /poetry/mixology/solutions/providers/__init__.py: -------------------------------------------------------------------------------- 1 | from .python_requirement_solution_provider import PythonRequirementSolutionProvider 2 | -------------------------------------------------------------------------------- /tests/console/commands/self/fixtures/poetry-1.0.5-darwin.sha256sum: -------------------------------------------------------------------------------- 1 | be3d3b916cb47038899d6ff37e875fd08ba3fed22bcdbf5a92f3f48fd2f15da8 2 | -------------------------------------------------------------------------------- /tests/fixtures/git/github.com/demo/demo/demo.egg-info/requires.txt: -------------------------------------------------------------------------------- 1 | pendulum>=1.4.4 2 | 3 | [bar] 4 | tomlkit 5 | 6 | [foo] 7 | cleo 8 | -------------------------------------------------------------------------------- /tests/fixtures/git/github.com/demo/namespace-package-one/namespace_package/__init__.py: -------------------------------------------------------------------------------- 1 | __import__("pkg_resources").declare_namespace(__name__) 2 | -------------------------------------------------------------------------------- /tests/fixtures/inspection/demo_only_requires_txt.egg-info/requires.txt: -------------------------------------------------------------------------------- 1 | cleo; extra == "foo" 2 | pendulum (>=1.4.4) 3 | tomlkit; extra == "bar" 4 | -------------------------------------------------------------------------------- /poetry/__main__.py: -------------------------------------------------------------------------------- 1 | import sys 2 | 3 | 4 | if __name__ == "__main__": 5 | from .console.application import main 6 | 7 | sys.exit(main()) 8 | -------------------------------------------------------------------------------- /poetry/exceptions.py: -------------------------------------------------------------------------------- 1 | class PoetryException(Exception): 2 | 3 | pass 4 | 5 | 6 | class InvalidProjectFile(PoetryException): 7 | 8 | pass 9 | -------------------------------------------------------------------------------- /tests/fixtures/distributions/demo-0.1.0.tar.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/serverwentdown/poetry/master/tests/fixtures/distributions/demo-0.1.0.tar.gz -------------------------------------------------------------------------------- /tests/fixtures/git/github.com/demo/non-canonical-name/Demo.egg-info/requires.txt: -------------------------------------------------------------------------------- 1 | pendulum>=1.4.4 2 | 3 | [bar] 4 | tomlkit 5 | 6 | [foo] 7 | cleo 8 | -------------------------------------------------------------------------------- /poetry/plugins/base_plugin.py: -------------------------------------------------------------------------------- 1 | class BasePlugin: 2 | """ 3 | Base class for all plugin types 4 | """ 5 | 6 | PLUGIN_API_VERSION = "1.0.0" 7 | -------------------------------------------------------------------------------- /poetry/repositories/exceptions.py: -------------------------------------------------------------------------------- 1 | class RepositoryError(Exception): 2 | 3 | pass 4 | 5 | 6 | class PackageNotFound(Exception): 7 | 8 | pass 9 | -------------------------------------------------------------------------------- /tests/fixtures/excluded_subpackage/example/test/excluded.py: -------------------------------------------------------------------------------- 1 | from .. import __version__ 2 | 3 | 4 | def test_version(): 5 | assert __version__ == "0.1.0" 6 | -------------------------------------------------------------------------------- /tests/fixtures/inspection/demo_with_obsolete_egg_info/demo-0.1.0.egg-info/requires.txt: -------------------------------------------------------------------------------- 1 | cleo; extra == "foo" 2 | pendulum (>=1.0.0) 3 | tomlkit; extra == "bar" 4 | -------------------------------------------------------------------------------- /poetry/packages/__init__.py: -------------------------------------------------------------------------------- 1 | from .dependency_package import DependencyPackage 2 | from .locker import Locker 3 | from .package_collection import PackageCollection 4 | -------------------------------------------------------------------------------- /poetry/plugins/__init__.py: -------------------------------------------------------------------------------- 1 | from .application_plugin import ApplicationPlugin 2 | from .plugin import Plugin 3 | 4 | 5 | __all__ = ["ApplicationPlugin", "Plugin"] 6 | -------------------------------------------------------------------------------- /poetry/console/exceptions.py: -------------------------------------------------------------------------------- 1 | from cleo.exceptions import CleoSimpleException 2 | 3 | 4 | class PoetrySimpleConsoleException(CleoSimpleException): 5 | 6 | pass 7 | -------------------------------------------------------------------------------- /tests/masonry/builders/fixtures/pep_561_stub_only/pkg-stubs/module.pyi: -------------------------------------------------------------------------------- 1 | """Example module""" 2 | from typing import Tuple 3 | 4 | 5 | version_info = Tuple[int, int, int] 6 | -------------------------------------------------------------------------------- /tests/fixtures/distributions/demo-0.1.0-py2.py3-none-any.whl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/serverwentdown/poetry/master/tests/fixtures/distributions/demo-0.1.0-py2.py3-none-any.whl -------------------------------------------------------------------------------- /tests/fixtures/simple_project/dist/simple-project-1.2.3.tar.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/serverwentdown/poetry/master/tests/fixtures/simple_project/dist/simple-project-1.2.3.tar.gz -------------------------------------------------------------------------------- /tests/masonry/builders/fixtures/excluded_subpackage/example/test/excluded.py: -------------------------------------------------------------------------------- 1 | from .. import __version__ 2 | 3 | 4 | def test_version(): 5 | assert __version__ == "0.1.0" 6 | -------------------------------------------------------------------------------- /tests/masonry/builders/fixtures/pep_561_stub_only_partial/pkg-stubs/module.pyi: -------------------------------------------------------------------------------- 1 | """Example module""" 2 | from typing import Tuple 3 | 4 | 5 | version_info = Tuple[int, int, int] 6 | -------------------------------------------------------------------------------- /tests/masonry/builders/fixtures/pep_561_stub_only_src/src/pkg-stubs/module.pyi: -------------------------------------------------------------------------------- 1 | """Example module""" 2 | from typing import Tuple 3 | 4 | 5 | version_info = Tuple[int, int, int] 6 | -------------------------------------------------------------------------------- /tests/repositories/fixtures/pypi.org/dists/isort-4.3.4.tar.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/serverwentdown/poetry/master/tests/repositories/fixtures/pypi.org/dists/isort-4.3.4.tar.gz -------------------------------------------------------------------------------- /tests/repositories/fixtures/pypi.org/dists/pastel-0.1.0.tar.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/serverwentdown/poetry/master/tests/repositories/fixtures/pypi.org/dists/pastel-0.1.0.tar.gz -------------------------------------------------------------------------------- /tests/console/commands/self/fixtures/poetry-1.0.5-darwin.tar.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/serverwentdown/poetry/master/tests/console/commands/self/fixtures/poetry-1.0.5-darwin.tar.gz -------------------------------------------------------------------------------- /tests/repositories/fixtures/installed/src/pendulum/pendulum.egg-info/requires.txt: -------------------------------------------------------------------------------- 1 | python-dateutil<3.0,>=2.6 2 | pytzdata>=2018.3 3 | 4 | [:python_version < "3.5"] 5 | typing<4.0,>=3.6 6 | -------------------------------------------------------------------------------- /tests/repositories/fixtures/pypi.org/dists/futures-3.2.0.tar.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/serverwentdown/poetry/master/tests/repositories/fixtures/pypi.org/dists/futures-3.2.0.tar.gz -------------------------------------------------------------------------------- /tests/repositories/fixtures/pypi.org/dists/ipython-5.7.0.tar.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/serverwentdown/poetry/master/tests/repositories/fixtures/pypi.org/dists/ipython-5.7.0.tar.gz -------------------------------------------------------------------------------- /tests/repositories/fixtures/pypi.org/dists/jupyter-1.0.0.tar.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/serverwentdown/poetry/master/tests/repositories/fixtures/pypi.org/dists/jupyter-1.0.0.tar.gz -------------------------------------------------------------------------------- /tests/repositories/fixtures/pypi.org/dists/tomlkit-0.5.2.tar.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/serverwentdown/poetry/master/tests/repositories/fixtures/pypi.org/dists/tomlkit-0.5.2.tar.gz -------------------------------------------------------------------------------- /tests/repositories/fixtures/pypi.org/dists/tomlkit-0.5.3.tar.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/serverwentdown/poetry/master/tests/repositories/fixtures/pypi.org/dists/tomlkit-0.5.3.tar.gz -------------------------------------------------------------------------------- /tests/installation/fixtures/no-dependencies.test: -------------------------------------------------------------------------------- 1 | package = [] 2 | 3 | [metadata] 4 | python-versions = "*" 5 | lock-version = "1.1" 6 | content-hash = "123456789" 7 | 8 | [metadata.files] 9 | -------------------------------------------------------------------------------- /tests/repositories/fixtures/pypi.org/dists/SQLAlchemy-1.2.12.tar.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/serverwentdown/poetry/master/tests/repositories/fixtures/pypi.org/dists/SQLAlchemy-1.2.12.tar.gz -------------------------------------------------------------------------------- /tests/repositories/fixtures/pypi.org/dists/Twisted-18.9.0.tar.bz2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/serverwentdown/poetry/master/tests/repositories/fixtures/pypi.org/dists/Twisted-18.9.0.tar.bz2 -------------------------------------------------------------------------------- /tests/repositories/fixtures/pypi.org/dists/isort-4.3.4-py2-none-any.whl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/serverwentdown/poetry/master/tests/repositories/fixtures/pypi.org/dists/isort-4.3.4-py2-none-any.whl -------------------------------------------------------------------------------- /tests/repositories/fixtures/pypi.org/dists/isort-4.3.4-py3-none-any.whl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/serverwentdown/poetry/master/tests/repositories/fixtures/pypi.org/dists/isort-4.3.4-py3-none-any.whl -------------------------------------------------------------------------------- /poetry/console/logging/formatters/formatter.py: -------------------------------------------------------------------------------- 1 | import logging 2 | 3 | 4 | class Formatter(object): 5 | def format(self, record: logging.LogRecord) -> str: 6 | raise NotImplementedError() 7 | -------------------------------------------------------------------------------- /tests/fixtures/wheel_with_no_requires_dist/demo-0.1.0-py2.py3-none-any.whl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/serverwentdown/poetry/master/tests/fixtures/wheel_with_no_requires_dist/demo-0.1.0-py2.py3-none-any.whl -------------------------------------------------------------------------------- /tests/repositories/fixtures/pypi.org/dists/black-19.10b0-py36-none-any.whl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/serverwentdown/poetry/master/tests/repositories/fixtures/pypi.org/dists/black-19.10b0-py36-none-any.whl -------------------------------------------------------------------------------- /tests/repositories/fixtures/pypi.org/dists/futures-3.2.0-py2-none-any.whl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/serverwentdown/poetry/master/tests/repositories/fixtures/pypi.org/dists/futures-3.2.0-py2-none-any.whl -------------------------------------------------------------------------------- /tests/repositories/fixtures/pypi.org/dists/ipython-5.7.0-py2-none-any.whl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/serverwentdown/poetry/master/tests/repositories/fixtures/pypi.org/dists/ipython-5.7.0-py2-none-any.whl -------------------------------------------------------------------------------- /tests/repositories/fixtures/pypi.org/dists/ipython-5.7.0-py3-none-any.whl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/serverwentdown/poetry/master/tests/repositories/fixtures/pypi.org/dists/ipython-5.7.0-py3-none-any.whl -------------------------------------------------------------------------------- /tests/repositories/fixtures/pypi.org/dists/ipython-7.5.0-py3-none-any.whl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/serverwentdown/poetry/master/tests/repositories/fixtures/pypi.org/dists/ipython-7.5.0-py3-none-any.whl -------------------------------------------------------------------------------- /tests/fixtures/simple_project/dist/simple_project-1.2.3-py2.py3-none-any.whl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/serverwentdown/poetry/master/tests/fixtures/simple_project/dist/simple_project-1.2.3-py2.py3-none-any.whl -------------------------------------------------------------------------------- /tests/repositories/fixtures/installed/lib/python3.7/site-packages/directory_pep_610-1.2.3.dist-info/direct_url.json: -------------------------------------------------------------------------------- 1 | { 2 | "url": "file:///path/to/distributions/directory-pep-610", 3 | "dir_info": {} 4 | } 5 | -------------------------------------------------------------------------------- /tests/repositories/fixtures/pypi.org/dists/clikit-0.2.4-py2.py3-none-any.whl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/serverwentdown/poetry/master/tests/repositories/fixtures/pypi.org/dists/clikit-0.2.4-py2.py3-none-any.whl -------------------------------------------------------------------------------- /tests/repositories/fixtures/pypi.org/dists/jupyter-1.0.0-py2.py3-none-any.whl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/serverwentdown/poetry/master/tests/repositories/fixtures/pypi.org/dists/jupyter-1.0.0-py2.py3-none-any.whl -------------------------------------------------------------------------------- /tests/repositories/fixtures/pypi.org/dists/python-language-server-0.21.2.tar.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/serverwentdown/poetry/master/tests/repositories/fixtures/pypi.org/dists/python-language-server-0.21.2.tar.gz -------------------------------------------------------------------------------- /poetry/layouts/src.py: -------------------------------------------------------------------------------- 1 | from pathlib import Path 2 | 3 | from .layout import Layout 4 | 5 | 6 | class SrcLayout(Layout): 7 | @property 8 | def basedir(self) -> "Path": 9 | return Path("src") 10 | -------------------------------------------------------------------------------- /tests/repositories/fixtures/installed/lib/python3.7/site-packages/url_pep_610-1.2.3.dist-info/direct_url.json: -------------------------------------------------------------------------------- 1 | { 2 | "url": "https://python-poetry.org/distributions/url-pep-610-1.2.3.tar.gz", 3 | "archive_info": {} 4 | } 5 | -------------------------------------------------------------------------------- /mypy.ini: -------------------------------------------------------------------------------- 1 | [mypy] 2 | check_untyped_defs = True 3 | ignore_errors = False 4 | ignore_missing_imports = True 5 | strict_optional = True 6 | warn_unused_ignores = True 7 | warn_redundant_casts = True 8 | warn_unused_configs = True 9 | -------------------------------------------------------------------------------- /tests/repositories/fixtures/installed/lib/python3.7/site-packages/file_pep_610-1.2.3.dist-info/METADATA: -------------------------------------------------------------------------------- 1 | Metadata-Version: 2.1 2 | Name: file-pep-610 3 | Version: 1.2.3 4 | Summary: Foo 5 | License: MIT 6 | Requires-Python: >=3.6 7 | -------------------------------------------------------------------------------- /tests/repositories/fixtures/installed/lib/python3.7/site-packages/foo-0.1.0-py3.8.egg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/serverwentdown/poetry/master/tests/repositories/fixtures/installed/lib/python3.7/site-packages/foo-0.1.0-py3.8.egg -------------------------------------------------------------------------------- /tests/repositories/fixtures/installed/lib/python3.7/site-packages/git_pep_610-1.2.3.dist-info/METADATA: -------------------------------------------------------------------------------- 1 | Metadata-Version: 2.1 2 | Name: git-pep-610 3 | Version: 1.2.3 4 | Summary: Foo 5 | License: MIT 6 | Requires-Python: >=3.6 7 | -------------------------------------------------------------------------------- /tests/repositories/fixtures/installed/lib/python3.7/site-packages/url_pep_610-1.2.3.dist-info/METADATA: -------------------------------------------------------------------------------- 1 | Metadata-Version: 2.1 2 | Name: url-pep-610 3 | Version: 1.2.3 4 | Summary: Foo 5 | License: MIT 6 | Requires-Python: >=3.6 7 | -------------------------------------------------------------------------------- /tests/fixtures/git/github.com/demo/no-dependencies/demo.egg-info/SOURCES.txt: -------------------------------------------------------------------------------- 1 | setup.py 2 | demo/__init__.py 3 | demo.egg-info/PKG-INFO 4 | demo.egg-info/SOURCES.txt 5 | demo.egg-info/dependency_links.txt 6 | demo.egg-info/top_level.txt 7 | -------------------------------------------------------------------------------- /poetry/installation/operations/__init__.py: -------------------------------------------------------------------------------- 1 | from typing import Union 2 | 3 | from .install import Install 4 | from .uninstall import Uninstall 5 | from .update import Update 6 | 7 | 8 | OperationTypes = Union[Install, Uninstall, Update] 9 | -------------------------------------------------------------------------------- /tests/repositories/fixtures/installed/lib/python3.7/site-packages/directory_pep_610-1.2.3.dist-info/METADATA: -------------------------------------------------------------------------------- 1 | Metadata-Version: 2.1 2 | Name: directory-pep-610 3 | Version: 1.2.3 4 | Summary: Foo 5 | License: MIT 6 | Requires-Python: >=3.6 7 | -------------------------------------------------------------------------------- /tests/repositories/fixtures/installed/lib/python3.7/site-packages/editable_directory_pep_610-1.2.3.dist-info/direct_url.json: -------------------------------------------------------------------------------- 1 | { 2 | "url": "file:///path/to/distributions/directory-pep-610", 3 | "dir_info": { 4 | "editable": true 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /poetry/mixology/set_relation.py: -------------------------------------------------------------------------------- 1 | class SetRelation: 2 | """ 3 | An enum of possible relationships between two sets. 4 | """ 5 | 6 | SUBSET = "subset" 7 | 8 | DISJOINT = "disjoint" 9 | 10 | OVERLAPPING = "overlapping" 11 | -------------------------------------------------------------------------------- /tests/fixtures/git/github.com/demo/demo/demo.egg-info/SOURCES.txt: -------------------------------------------------------------------------------- 1 | setup.py 2 | demo/__init__.py 3 | demo.egg-info/PKG-INFO 4 | demo.egg-info/SOURCES.txt 5 | demo.egg-info/dependency_links.txt 6 | demo.egg-info/requires.txt 7 | demo.egg-info/top_level.txt 8 | -------------------------------------------------------------------------------- /tests/repositories/fixtures/installed/lib/python3.7/site-packages/editable_directory_pep_610-1.2.3.dist-info/METADATA: -------------------------------------------------------------------------------- 1 | Metadata-Version: 2.1 2 | Name: editable-directory-pep-610 3 | Version: 1.2.3 4 | Summary: Foo 5 | License: MIT 6 | Requires-Python: >=3.6 7 | -------------------------------------------------------------------------------- /tox.ini: -------------------------------------------------------------------------------- 1 | [tox] 2 | minversion = 3.3.0 3 | isolated_build = True 4 | envlist = py36, py37, py38, py39, doc 5 | 6 | [testenv] 7 | whitelist_externals = poetry 8 | commands = 9 | poetry install -vv --no-root 10 | poetry run pytest {posargs} tests/ 11 | -------------------------------------------------------------------------------- /tests/fixtures/git/github.com/demo/non-canonical-name/Demo.egg-info/SOURCES.txt: -------------------------------------------------------------------------------- 1 | setup.py 2 | Demo.egg-info/PKG-INFO 3 | Demo.egg-info/SOURCES.txt 4 | Demo.egg-info/dependency_links.txt 5 | Demo.egg-info/requires.txt 6 | Demo.egg-info/top_level.txt 7 | demo/__init__.py 8 | -------------------------------------------------------------------------------- /poetry/utils/patterns.py: -------------------------------------------------------------------------------- 1 | import re 2 | 3 | 4 | wheel_file_re = re.compile( 5 | r"""^(?P(?P.+?)(-(?P\d.+?))?) 6 | ((-(?P\d.*?))?-(?P.+?)-(?P.+?)-(?P.+?) 7 | \.whl|\.dist-info)$""", 8 | re.VERBOSE, 9 | ) 10 | -------------------------------------------------------------------------------- /poetry/config/config_source.py: -------------------------------------------------------------------------------- 1 | from typing import Any 2 | 3 | 4 | class ConfigSource: 5 | def add_property(self, key: str, value: Any) -> None: 6 | raise NotImplementedError() 7 | 8 | def remove_property(self, key: str) -> None: 9 | raise NotImplementedError() 10 | -------------------------------------------------------------------------------- /tests/fixtures/project_with_setup/project_with_setup.egg-info/SOURCES.txt: -------------------------------------------------------------------------------- 1 | setup.py 2 | my_package/__init__.py 3 | my_package.egg-info/PKG-INFO 4 | my_package.egg-info/SOURCES.txt 5 | my_package.egg-info/dependency_links.txt 6 | my_package.egg-info/requires.txt 7 | my_package.egg-info/top_level.txt 8 | -------------------------------------------------------------------------------- /tests/repositories/fixtures/installed/lib/python3.7/site-packages/git_pep_610-1.2.3.dist-info/direct_url.json: -------------------------------------------------------------------------------- 1 | { 2 | "url": "https://github.com/demo/git-pep-610.git", 3 | "vcs_info": { 4 | "vcs": "git", 5 | "requested_revision": "my-branch", 6 | "commit_id": "123456" 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /tests/fixtures/invalid_pyproject/pyproject.toml: -------------------------------------------------------------------------------- 1 | [tool.poetry] 2 | name = "invalid" 3 | version = "1.0.0" 4 | authors = [ 5 | "Foo " 6 | ] 7 | license = "INVALID" 8 | 9 | [tool.poetry.dependencies] 10 | python = "*" 11 | pendulum = {"version" = "^2.0.5", allows-prereleases = true} 12 | -------------------------------------------------------------------------------- /tests/repositories/fixtures/installed/lib/python3.7/site-packages/file_pep_610-1.2.3.dist-info/direct_url.json: -------------------------------------------------------------------------------- 1 | { 2 | "url": "file:///path/to/distributions/file-pep-610-1.2.3.tar.gz", 3 | "archive_info": { 4 | "hash": "sha256=2c26b46b68ffc68ff99b453c1d30413413422d706483bfa0f98a5e886266e7ae" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /poetry/plugins/application_plugin.py: -------------------------------------------------------------------------------- 1 | from .base_plugin import BasePlugin 2 | 3 | 4 | class ApplicationPlugin(BasePlugin): 5 | """ 6 | Base class for plugins. 7 | """ 8 | 9 | type = "application.plugin" 10 | 11 | def activate(self, application): 12 | raise NotImplementedError() 13 | -------------------------------------------------------------------------------- /tests/fixtures/project_with_nested_local/quix/pyproject.toml: -------------------------------------------------------------------------------- 1 | [tool.poetry] 2 | name = "quix" 3 | version = "1.2.3" 4 | description = "Some description." 5 | authors = ["Poetry Maintainer "] 6 | license = "MIT" 7 | 8 | # Requirements 9 | [tool.poetry.dependencies] 10 | python = "~2.7 || ^3.4" 11 | -------------------------------------------------------------------------------- /tests/installation/fixtures/remove.test: -------------------------------------------------------------------------------- 1 | [[package]] 2 | name = "A" 3 | version = "1.0" 4 | description = "" 5 | category = "main" 6 | optional = false 7 | python-versions = "*" 8 | 9 | [metadata] 10 | python-versions = "*" 11 | lock-version = "1.1" 12 | content-hash = "123456789" 13 | 14 | [metadata.files] 15 | "A" = [] 16 | -------------------------------------------------------------------------------- /tests/fixtures/inspection/demo_no_setup_pkg_info_no_deps/PKG-INFO: -------------------------------------------------------------------------------- 1 | Metadata-Version: 1.0 2 | Name: demo 3 | Version: 0.1.0 4 | Summary: Demo project. 5 | Home-page: https://github.com/demo/demo 6 | Author: Sébastien Eustace 7 | Author-email: sebastien@eustace.io 8 | License: MIT 9 | Description: UNKNOWN 10 | Platform: UNKNOWN 11 | -------------------------------------------------------------------------------- /tests/fixtures/inspection/demo_only_requires_txt.egg-info/PKG-INFO: -------------------------------------------------------------------------------- 1 | Metadata-Version: 1.0 2 | Name: demo 3 | Version: 0.1.0 4 | Summary: Demo project. 5 | Home-page: https://github.com/demo/demo 6 | Author: Sébastien Eustace 7 | Author-email: sebastien@eustace.io 8 | License: MIT 9 | Description: UNKNOWN 10 | Platform: UNKNOWN 11 | -------------------------------------------------------------------------------- /poetry/console/logging/formatters/__init__.py: -------------------------------------------------------------------------------- 1 | from .builder_formatter import BuilderLogFormatter 2 | 3 | 4 | FORMATTERS = { 5 | "poetry.core.masonry.builders.builder": BuilderLogFormatter(), 6 | "poetry.core.masonry.builders.sdist": BuilderLogFormatter(), 7 | "poetry.core.masonry.builders.wheel": BuilderLogFormatter(), 8 | } 9 | -------------------------------------------------------------------------------- /tests/fixtures/git/github.com/demo/no-dependencies/demo.egg-info/PKG-INFO: -------------------------------------------------------------------------------- 1 | Metadata-Version: 1.0 2 | Name: demo 3 | Version: 0.1.2 4 | Summary: Demo project. 5 | Home-page: https://github.com/demo/demo 6 | Author: Sébastien Eustace 7 | Author-email: sebastien@eustace.io 8 | License: MIT 9 | Description: UNKNOWN 10 | Platform: UNKNOWN 11 | -------------------------------------------------------------------------------- /tests/installation/fixtures/update-with-lock.test: -------------------------------------------------------------------------------- 1 | [[package]] 2 | name = "A" 3 | version = "1.1" 4 | description = "" 5 | category = "main" 6 | optional = false 7 | python-versions = "*" 8 | 9 | [metadata] 10 | python-versions = "*" 11 | lock-version = "1.1" 12 | content-hash = "123456789" 13 | 14 | [metadata.files] 15 | "A" = [] 16 | -------------------------------------------------------------------------------- /tests/utils/fixtures/setups/extras_require_with_vars/setup.py: -------------------------------------------------------------------------------- 1 | from setuptools import setup 2 | 3 | tests_require = ["pytest"] 4 | 5 | setup( 6 | name="extras_require_with_vars", 7 | version="0.0.1", 8 | description="test setup_reader.py", 9 | install_requires=[], 10 | extras_require={"test": tests_require}, 11 | ) 12 | -------------------------------------------------------------------------------- /tests/fixtures/inspection/demo_with_obsolete_egg_info/demo-0.1.0.egg-info/PKG-INFO: -------------------------------------------------------------------------------- 1 | Metadata-Version: 1.0 2 | Name: demo 3 | Version: 0.1.0 4 | Summary: Demo project. 5 | Home-page: https://github.com/demo/demo 6 | Author: Sébastien Eustace 7 | Author-email: sebastien@eustace.io 8 | License: MIT 9 | Description: UNKNOWN 10 | Platform: UNKNOWN 11 | -------------------------------------------------------------------------------- /tests/fixtures/project_with_setup/project_with_setup.egg-info/PKG-INFO: -------------------------------------------------------------------------------- 1 | Metadata-Version: 1.0 2 | Name: project-with-setup 3 | Version: 0.1.2 4 | Summary: Demo project. 5 | Home-page: https://github.com/demo/demo 6 | Author: Sébastien Eustace 7 | Author-email: sebastien@eustace.io 8 | License: MIT 9 | Description: UNKNOWN 10 | Platform: UNKNOWN 11 | -------------------------------------------------------------------------------- /tests/utils/fixtures/setups/setuptools_setup/setup.py: -------------------------------------------------------------------------------- 1 | import setuptools 2 | 3 | setuptools.setup( 4 | name="my_package", 5 | version="0.1.2", 6 | author="John Doe", 7 | author_email="john@example.orh", 8 | description="Just a description", 9 | url="https://example.org", 10 | packages=setuptools.find_packages(), 11 | ) 12 | -------------------------------------------------------------------------------- /poetry/layouts/__init__.py: -------------------------------------------------------------------------------- 1 | from typing import Type 2 | 3 | from .layout import Layout 4 | from .src import SrcLayout 5 | 6 | 7 | _LAYOUTS = {"src": SrcLayout, "standard": Layout} 8 | 9 | 10 | def layout(name: str) -> Type[Layout]: 11 | if name not in _LAYOUTS: 12 | raise ValueError("Invalid layout") 13 | 14 | return _LAYOUTS[name] 15 | -------------------------------------------------------------------------------- /tests/fixtures/project_with_nested_local/foo/pyproject.toml: -------------------------------------------------------------------------------- 1 | [tool.poetry] 2 | name = "foo" 3 | version = "1.2.3" 4 | description = "Some description." 5 | authors = ["Poetry Maintainer "] 6 | license = "MIT" 7 | 8 | # Requirements 9 | [tool.poetry.dependencies] 10 | python = "~2.7 || ^3.4" 11 | bar = { path = "../bar", develop = true } 12 | -------------------------------------------------------------------------------- /tests/fixtures/project_with_nested_local/bar/pyproject.toml: -------------------------------------------------------------------------------- 1 | [tool.poetry] 2 | name = "bar" 3 | version = "1.2.3" 4 | description = "Some description." 5 | authors = ["Poetry Maintainer "] 6 | license = "MIT" 7 | 8 | # Requirements 9 | [tool.poetry.dependencies] 10 | python = "~2.7 || ^3.4" 11 | quix = { path = "../quix", develop = true } 12 | -------------------------------------------------------------------------------- /tests/fixtures/git/github.com/demo/demo/demo.egg-info/PKG-INFO: -------------------------------------------------------------------------------- 1 | Metadata-Version: 2.1 2 | Name: demo 3 | Version: 0.1.2 4 | Summary: Demo project. 5 | Home-page: https://github.com/demo/demo 6 | Author: Sébastien Eustace 7 | Author-email: sebastien@eustace.io 8 | License: MIT 9 | Description: UNKNOWN 10 | Platform: UNKNOWN 11 | Provides-Extra: bar 12 | Provides-Extra: foo 13 | -------------------------------------------------------------------------------- /tests/fixtures/directory/project_with_transitive_file_dependencies/inner-directory-project/pyproject.toml: -------------------------------------------------------------------------------- 1 | [tool.poetry] 2 | name = "inner-directory-project" 3 | version = "1.2.4" 4 | description = "This is a description" 5 | authors = ["Your Name "] 6 | license = "MIT" 7 | 8 | [tool.poetry.dependencies] 9 | python = "*" 10 | 11 | [tool.poetry.dev-dependencies] 12 | -------------------------------------------------------------------------------- /tests/fixtures/git/github.com/demo/prerelease/pyproject.toml: -------------------------------------------------------------------------------- 1 | [tool.poetry] 2 | name = "prerelease" 3 | version = "1.0.0.dev0" 4 | description = "Some description." 5 | authors = [ 6 | "Sébastien Eustace " 7 | ] 8 | license = "MIT" 9 | 10 | # Requirements 11 | [tool.poetry.dependencies] 12 | python = "~2.7 || ^3.4" 13 | 14 | [tool.poetry.dev-dependencies] 15 | -------------------------------------------------------------------------------- /tests/masonry/builders/fixtures/pep_561_stub_only/pyproject.toml: -------------------------------------------------------------------------------- 1 | [tool.poetry] 2 | name = "pep-561-stubs" 3 | version = "0.1" 4 | description = "PEP 561 stub package example" 5 | authors = [ 6 | "Oleg Höfling " 7 | ] 8 | license = "MIT" 9 | packages = [ 10 | {include = "pkg-stubs"} 11 | ] 12 | 13 | [tool.poetry.dependencies] 14 | python = "^3.6" 15 | -------------------------------------------------------------------------------- /tests/fixtures/git/github.com/demo/non-canonical-name/Demo.egg-info/PKG-INFO: -------------------------------------------------------------------------------- 1 | Metadata-Version: 2.1 2 | Name: Demo 3 | Version: 0.1.2 4 | Summary: Demo project. 5 | Home-page: https://github.com/demo/demo 6 | Author: Sébastien Eustace 7 | Author-email: sebastien@eustace.io 8 | License: MIT 9 | Description: UNKNOWN 10 | Platform: UNKNOWN 11 | Provides-Extra: foo 12 | Provides-Extra: bar 13 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/config.yml: -------------------------------------------------------------------------------- 1 | # Ref: https://help.github.com/en/github/building-a-strong-community/configuring-issue-templates-for-your-repository#configuring-the-template-chooser 2 | blank_issues_enabled: true 3 | contact_links: 4 | - name: '💬 Discord Server' 5 | url: https://discordapp.com/invite/awxPgve 6 | about: | 7 | Chat with the community, ask questions and learn about best practices. 8 | -------------------------------------------------------------------------------- /poetry/plugins/plugin.py: -------------------------------------------------------------------------------- 1 | from .base_plugin import BasePlugin 2 | 3 | 4 | class Plugin(BasePlugin): 5 | """ 6 | Generic plugin not related to the console application. 7 | The activate() method must be implemented and receives 8 | the Poetry instance. 9 | """ 10 | 11 | type = "plugin" 12 | 13 | def activate(self, poetry, io): 14 | raise NotImplementedError() 15 | -------------------------------------------------------------------------------- /tests/fixtures/git/github.com/demo/pyproject-demo/pyproject.toml: -------------------------------------------------------------------------------- 1 | [tool.poetry] 2 | name = "demo" 3 | version = "0.1.2" 4 | description = "Some description." 5 | authors = [ 6 | "Sébastien Eustace " 7 | ] 8 | license = "MIT" 9 | 10 | # Requirements 11 | [tool.poetry.dependencies] 12 | python = "~2.7 || ^3.4" 13 | pendulum = '^1.4' 14 | 15 | [tool.poetry.dev-dependencies] 16 | -------------------------------------------------------------------------------- /tests/fixtures/outdated_lock/pyproject.toml: -------------------------------------------------------------------------------- 1 | [tool.poetry] 2 | name = "foobar" 3 | version = "0.1.0" 4 | description = "" 5 | authors = ["Poetry Developer "] 6 | 7 | [tool.poetry.dependencies] 8 | python = "^3.8" 9 | docker = "4.3.1" 10 | 11 | [tool.poetry.dev-dependencies] 12 | 13 | [build-system] 14 | requires = ["poetry-core>=1.0.0"] 15 | build-backend = "poetry.core.masonry.api" 16 | -------------------------------------------------------------------------------- /tests/fixtures/up_to_date_lock/pyproject.toml: -------------------------------------------------------------------------------- 1 | [tool.poetry] 2 | name = "foobar" 3 | version = "0.1.0" 4 | description = "" 5 | authors = ["Poetry Developer "] 6 | 7 | [tool.poetry.dependencies] 8 | python = "^3.8" 9 | docker = "4.3.1" 10 | 11 | [tool.poetry.dev-dependencies] 12 | 13 | [build-system] 14 | requires = ["poetry-core>=1.0.0"] 15 | build-backend = "poetry.core.masonry.api" 16 | -------------------------------------------------------------------------------- /tests/masonry/builders/fixtures/pep_561_stub_only_partial/pyproject.toml: -------------------------------------------------------------------------------- 1 | [tool.poetry] 2 | name = "pep-561-stubs" 3 | version = "0.1" 4 | description = "PEP 561 stub package example with the py.typed marker file" 5 | authors = [ 6 | "Oleg Höfling " 7 | ] 8 | license = "MIT" 9 | packages = [ 10 | {include = "pkg-stubs"} 11 | ] 12 | 13 | [tool.poetry.dependencies] 14 | python = "^3.6" 15 | -------------------------------------------------------------------------------- /tests/masonry/builders/fixtures/pep_561_stub_only_src/pyproject.toml: -------------------------------------------------------------------------------- 1 | [tool.poetry] 2 | name = "pep-561-stubs" 3 | version = "0.1" 4 | description = "PEP 561 stub package example with an src layout" 5 | authors = [ 6 | "Oleg Höfling " 7 | ] 8 | license = "MIT" 9 | packages = [ 10 | {include = "pkg-stubs", from = "src"} 11 | ] 12 | 13 | [tool.poetry.dependencies] 14 | python = "^3.6" 15 | -------------------------------------------------------------------------------- /poetry/repositories/remote_repository.py: -------------------------------------------------------------------------------- 1 | from .repository import Repository 2 | 3 | 4 | class RemoteRepository(Repository): 5 | def __init__(self, url: str) -> None: 6 | self._url = url 7 | 8 | super().__init__() 9 | 10 | @property 11 | def url(self) -> str: 12 | return self._url 13 | 14 | @property 15 | def authenticated_url(self) -> str: 16 | return self._url 17 | -------------------------------------------------------------------------------- /tests/fixtures/old_lock/pyproject.toml: -------------------------------------------------------------------------------- 1 | [tool.poetry] 2 | name = "foobar" 3 | version = "0.1.0" 4 | description = "" 5 | authors = ["Poetry Developer "] 6 | 7 | [tool.poetry.dependencies] 8 | python = "^3.8" 9 | sampleproject = ">=1.3.1" 10 | 11 | [tool.poetry.dev-dependencies] 12 | 13 | [build-system] 14 | requires = ["poetry-core>=1.0.0"] 15 | build-backend = "poetry.core.masonry.api" 16 | -------------------------------------------------------------------------------- /tests/repositories/fixtures/legacy/jupyter.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Links for jupyter 5 | 6 | 7 |

Links for jupyter

8 | jupyter-1.0.0.tar.gz
9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /tests/fixtures/project_with_nested_local/pyproject.toml: -------------------------------------------------------------------------------- 1 | [tool.poetry] 2 | name = "project-with-nested-local" 3 | version = "1.2.3" 4 | description = "Some description." 5 | authors = ["Poetry Maintainer "] 6 | license = "MIT" 7 | 8 | # Requirements 9 | [tool.poetry.dependencies] 10 | python = "~2.7 || ^3.4" 11 | foo = { path = "./foo", develop = true } 12 | bar = { path = "./bar", develop = true } 13 | -------------------------------------------------------------------------------- /tests/utils/fixtures/setups/with-setup-cfg/setup.cfg: -------------------------------------------------------------------------------- 1 | [metadata] 2 | name = with-setup-cfg 3 | version = 1.2.3 4 | 5 | [options] 6 | zip_safe = true 7 | python_requires = >=2.6,!=3.0,!=3.1,!=3.2,!=3.3 8 | setup_requires = setuptools>=36.2.2 9 | install_requires = 10 | six 11 | tomlkit 12 | 13 | [options.extras_require] 14 | validation = 15 | cerberus 16 | tests = 17 | pytest 18 | pytest-xdist 19 | pytest-cov 20 | -------------------------------------------------------------------------------- /poetry/config/source.py: -------------------------------------------------------------------------------- 1 | import dataclasses 2 | 3 | from typing import Dict 4 | from typing import Union 5 | 6 | 7 | @dataclasses.dataclass(order=True, eq=True) 8 | class Source: 9 | name: str 10 | url: str 11 | default: bool = dataclasses.field(default=False) 12 | secondary: bool = dataclasses.field(default=False) 13 | 14 | def to_dict(self) -> Dict[str, Union[str, bool]]: 15 | return dataclasses.asdict(self) 16 | -------------------------------------------------------------------------------- /tests/fixtures/git/github.com/demo/no-dependencies/setup.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | from setuptools import setup 3 | 4 | 5 | kwargs = dict( 6 | name="demo", 7 | license="MIT", 8 | version="0.1.2", 9 | description="Demo project.", 10 | author="Sébastien Eustace", 11 | author_email="sebastien@eustace.io", 12 | url="https://github.com/demo/demo", 13 | packages=["demo"], 14 | ) 15 | 16 | 17 | setup(**kwargs) 18 | -------------------------------------------------------------------------------- /tests/fixtures/with_non_default_source/pyproject.toml: -------------------------------------------------------------------------------- 1 | [tool.poetry] 2 | name = "my-package" 3 | version = "1.2.3" 4 | description = "Some description." 5 | authors = [ 6 | "Your Name " 7 | ] 8 | license = "MIT" 9 | 10 | # Requirements 11 | [tool.poetry.dependencies] 12 | python = "~2.7 || ^3.6" 13 | 14 | [tool.poetry.dev-dependencies] 15 | 16 | [[tool.poetry.source]] 17 | name = "foo" 18 | url = "https://foo.bar/simple/" 19 | -------------------------------------------------------------------------------- /tests/repositories/fixtures/legacy/missing-version.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Links for poetry 5 | 6 | 7 |

Links for poetry

8 | poetry-0.1.0-py3-none-any.whl
9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /tests/fixtures/excluded_subpackage/pyproject.toml: -------------------------------------------------------------------------------- 1 | [tool.poetry] 2 | name = "example" 3 | version = "0.1.0" 4 | description = "" 5 | authors = ["Sébastien Eustace "] 6 | exclude = [ 7 | "**/test/**/*", 8 | ] 9 | 10 | [tool.poetry.dependencies] 11 | python = "^3.6" 12 | 13 | [tool.poetry.dev-dependencies] 14 | pytest = "^3.0" 15 | 16 | [build-system] 17 | requires = ["poetry>=0.12"] 18 | build-backend = "poetry.masonry.api" 19 | -------------------------------------------------------------------------------- /tests/utils/fixtures/setups/ansible/requirements.txt: -------------------------------------------------------------------------------- 1 | # Note: this requirements.txt file is used to specify what dependencies are 2 | # needed to make the package run rather than for deployment of a tested set of 3 | # packages. Thus, this should be the loosest set possible (only required 4 | # packages, not optional ones, and with the widest range of versions that could 5 | # be suitable) 6 | jinja2 7 | PyYAML 8 | paramiko 9 | cryptography 10 | setuptools 11 | -------------------------------------------------------------------------------- /tests/fixtures/git/github.com/demo/namespace-package-one/setup.py: -------------------------------------------------------------------------------- 1 | from setuptools import setup, find_packages 2 | 3 | 4 | setup( 5 | name="namespace_package_one", 6 | version="1.0.0", 7 | description="", 8 | long_description="", 9 | author="Python Poetry", 10 | author_email="noreply@python-poetry.org", 11 | license="MIT", 12 | packages=find_packages(), 13 | namespace_packages=["namespace_package"], 14 | zip_safe=False, 15 | ) 16 | -------------------------------------------------------------------------------- /tests/masonry/builders/fixtures/excluded_subpackage/pyproject.toml: -------------------------------------------------------------------------------- 1 | [tool.poetry] 2 | name = "example" 3 | version = "0.1.0" 4 | description = "" 5 | authors = ["Sébastien Eustace "] 6 | exclude = [ 7 | "**/test/**/*", 8 | ] 9 | 10 | [tool.poetry.dependencies] 11 | python = "^3.6" 12 | 13 | [tool.poetry.dev-dependencies] 14 | pytest = "^3.0" 15 | 16 | [build-system] 17 | requires = ["poetry>=0.12"] 18 | build-backend = "poetry.masonry.api" 19 | -------------------------------------------------------------------------------- /tests/utils/fixtures/setups/with-setup-cfg-attr/setup.cfg: -------------------------------------------------------------------------------- 1 | [metadata] 2 | name = with-setup-cfg-attr 3 | version = attr: with_setup_cfg_attr.__version__ 4 | 5 | [options] 6 | zip_safe = true 7 | python_requires = >=2.6,!=3.0,!=3.1,!=3.2,!=3.3 8 | setup_requires = setuptools>=36.2.2 9 | install_requires = 10 | six 11 | tomlkit 12 | 13 | [options.extras_require] 14 | validation = 15 | cerberus 16 | tests = 17 | pytest 18 | pytest-xdist 19 | pytest-cov 20 | -------------------------------------------------------------------------------- /tests/fixtures/with_non_default_secondary_source/pyproject.toml: -------------------------------------------------------------------------------- 1 | [tool.poetry] 2 | name = "my-package" 3 | version = "1.2.3" 4 | description = "Some description." 5 | authors = [ 6 | "Your Name " 7 | ] 8 | license = "MIT" 9 | 10 | # Requirements 11 | [tool.poetry.dependencies] 12 | python = "~2.7 || ^3.6" 13 | 14 | [tool.poetry.dev-dependencies] 15 | 16 | [[tool.poetry.source]] 17 | name = "foo" 18 | url = "https://foo.bar/simple/" 19 | secondary = true 20 | -------------------------------------------------------------------------------- /tests/fixtures/git/github.com/demo/poetry-plugin/pyproject.toml: -------------------------------------------------------------------------------- 1 | [tool.poetry] 2 | name = "poetry-plugin" 3 | version = "0.1.2" 4 | description = "Some description." 5 | authors = [ 6 | "Sébastien Eustace " 7 | ] 8 | license = "MIT" 9 | 10 | [tool.poetry.dependencies] 11 | python = "^3.6" 12 | pendulum = "^2.0" 13 | tomlkit = {version = "^0.7.0", optional = true} 14 | 15 | [tool.poetry.extras] 16 | foo = ["tomlkit"] 17 | 18 | [tool.poetry.dev-dependencies] 19 | -------------------------------------------------------------------------------- /tests/repositories/fixtures/legacy/pastel.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Links for pastel 5 | 6 | 7 |

Links for pastel

8 | pastel-0.1.0.tar.gz
9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /tests/repositories/fixtures/legacy/black.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Links for black 5 | 6 |

Links for black

7 | black-19.10b0.tar.gz 8 | 9 | 10 | -------------------------------------------------------------------------------- /.github/workflows/code-quality.yaml: -------------------------------------------------------------------------------- 1 | name: Code Quality 2 | 3 | on: 4 | pull_request: 5 | paths-ignore: 6 | - 'docs/**' 7 | - '.cirrus.yml' 8 | push: 9 | branches: [master] 10 | paths-ignore: 11 | - 'docs/**' 12 | - '.cirrus.yml' 13 | 14 | jobs: 15 | pre-commit: 16 | name: Linting 17 | runs-on: ubuntu-latest 18 | steps: 19 | - uses: actions/checkout@v2 20 | - uses: actions/setup-python@v2 21 | - uses: pre-commit/action@v2.0.0 22 | -------------------------------------------------------------------------------- /tests/fixtures/inspection/demo/pyproject.toml: -------------------------------------------------------------------------------- 1 | [tool.poetry] 2 | name = "demo" 3 | version = "0.1.0" 4 | description = "" 5 | authors = ["Sébastien Eustace "] 6 | 7 | [tool.poetry.dependencies] 8 | python = "~2.7 || ^3.4" 9 | pendulum = ">=1.4.4" 10 | cleo = {version = "*", optional = true} 11 | tomlkit = {version = "*", optional = true} 12 | 13 | [tool.poetry.extras] 14 | foo = ["cleo"] 15 | bar = ["tomlkit"] 16 | 17 | [tool.poetry.dev-dependencies] 18 | pytest = "^3.0" 19 | -------------------------------------------------------------------------------- /tests/installation/fixtures/with-dependencies.test: -------------------------------------------------------------------------------- 1 | [[package]] 2 | name = "A" 3 | version = "1.0" 4 | description = "" 5 | category = "main" 6 | optional = false 7 | python-versions = "*" 8 | 9 | [[package]] 10 | name = "B" 11 | version = "1.1" 12 | description = "" 13 | category = "main" 14 | optional = false 15 | python-versions = "*" 16 | 17 | [metadata] 18 | python-versions = "*" 19 | lock-version = "1.1" 20 | content-hash = "123456789" 21 | 22 | [metadata.files] 23 | "A" = [] 24 | "B" = [] 25 | -------------------------------------------------------------------------------- /tests/installation/fixtures/with-prereleases.test: -------------------------------------------------------------------------------- 1 | [[package]] 2 | name = "A" 3 | version = "1.0a2" 4 | description = "" 5 | category = "main" 6 | optional = false 7 | python-versions = "*" 8 | 9 | [[package]] 10 | name = "B" 11 | version = "1.1" 12 | description = "" 13 | category = "main" 14 | optional = false 15 | python-versions = "*" 16 | 17 | [metadata] 18 | python-versions = "*" 19 | lock-version = "1.1" 20 | content-hash = "123456789" 21 | 22 | [metadata.files] 23 | "A" = [] 24 | "B" = [] 25 | -------------------------------------------------------------------------------- /poetry/installation/base_installer.py: -------------------------------------------------------------------------------- 1 | from typing import TYPE_CHECKING 2 | 3 | 4 | if TYPE_CHECKING: 5 | from poetry.core.packages.package import Package 6 | 7 | 8 | class BaseInstaller: 9 | def install(self, package: "Package") -> None: 10 | raise NotImplementedError 11 | 12 | def update(self, source: "Package", target: "Package") -> None: 13 | raise NotImplementedError 14 | 15 | def remove(self, package: "Package") -> None: 16 | raise NotImplementedError 17 | -------------------------------------------------------------------------------- /poetry/console/command_loader.py: -------------------------------------------------------------------------------- 1 | from typing import Callable 2 | 3 | from cleo.exceptions import LogicException 4 | from cleo.loaders.factory_command_loader import FactoryCommandLoader 5 | 6 | 7 | class CommandLoader(FactoryCommandLoader): 8 | def register_factory(self, command_name: str, factory: Callable) -> None: 9 | if command_name in self._factories: 10 | raise LogicException(f'The command "{command_name}" already exists.') 11 | 12 | self._factories[command_name] = factory 13 | -------------------------------------------------------------------------------- /poetry/console/commands/env_command.py: -------------------------------------------------------------------------------- 1 | from typing import TYPE_CHECKING 2 | 3 | from .command import Command 4 | 5 | 6 | if TYPE_CHECKING: 7 | from poetry.utils.env import Env 8 | 9 | 10 | class EnvCommand(Command): 11 | def __init__(self) -> None: 12 | self._env = None 13 | 14 | super(EnvCommand, self).__init__() 15 | 16 | @property 17 | def env(self) -> "Env": 18 | return self._env 19 | 20 | def set_env(self, env: "Env") -> None: 21 | self._env = env 22 | -------------------------------------------------------------------------------- /tests/fixtures/directory/project_with_transitive_file_dependencies/pyproject.toml: -------------------------------------------------------------------------------- 1 | [tool.poetry] 2 | name = "project-with-transitive-file-dependencies" 3 | version = "1.2.3" 4 | description = "This is a description" 5 | authors = ["Your Name "] 6 | license = "MIT" 7 | 8 | [tool.poetry.dependencies] 9 | python = "*" 10 | demo = {path = "../../distributions/demo-0.1.0-py2.py3-none-any.whl"} 11 | inner-directory-project = {path = "./inner-directory-project"} 12 | 13 | [tool.poetry.dev-dependencies] 14 | -------------------------------------------------------------------------------- /tests/fixtures/inspection/demo_with_obsolete_egg_info/pyproject.toml: -------------------------------------------------------------------------------- 1 | [tool.poetry] 2 | name = "demo" 3 | version = "0.1.0" 4 | description = "" 5 | authors = ["Sébastien Eustace "] 6 | 7 | [tool.poetry.dependencies] 8 | python = "~2.7 || ^3.4" 9 | pendulum = ">=1.4.4" 10 | cleo = {version = "*", optional = true} 11 | tomlkit = {version = "*", optional = true} 12 | 13 | [tool.poetry.extras] 14 | foo = ["cleo"] 15 | bar = ["tomlkit"] 16 | 17 | [tool.poetry.dev-dependencies] 18 | pytest = "^3.0" 19 | -------------------------------------------------------------------------------- /tests/fixtures/project_with_extras/pyproject.toml: -------------------------------------------------------------------------------- 1 | [tool.poetry] 2 | name = "project-with-extras" 3 | version = "1.2.3" 4 | description = "This is a description" 5 | authors = ["Your Name "] 6 | license = "MIT" 7 | 8 | [tool.poetry.dependencies] 9 | python = "*" 10 | pendulum = { version = ">=1.4.4", optional = true } 11 | cachy = { version = ">=0.2.0", optional = true } 12 | 13 | [tool.poetry.extras] 14 | extras_a = [ "pendulum" ] 15 | extras_b = [ "cachy" ] 16 | 17 | [tool.poetry.dev-dependencies] 18 | -------------------------------------------------------------------------------- /tests/fixtures/project_with_setup/setup.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | from setuptools import setup 4 | 5 | 6 | kwargs = dict( 7 | name="project-with-setup", 8 | license="MIT", 9 | version="0.1.2", 10 | description="Demo project.", 11 | author="Sébastien Eustace", 12 | author_email="sebastien@eustace.io", 13 | url="https://github.com/demo/demo", 14 | packages=["my_package"], 15 | install_requires=["pendulum>=1.4.4", "cachy[msgpack]>=0.2.0"], 16 | ) 17 | 18 | 19 | setup(**kwargs) 20 | -------------------------------------------------------------------------------- /poetry/masonry/api.py: -------------------------------------------------------------------------------- 1 | from poetry.core.masonry.api import build_sdist 2 | from poetry.core.masonry.api import build_wheel 3 | from poetry.core.masonry.api import get_requires_for_build_sdist 4 | from poetry.core.masonry.api import get_requires_for_build_wheel 5 | from poetry.core.masonry.api import prepare_metadata_for_build_wheel 6 | 7 | 8 | __all__ = [ 9 | "build_sdist", 10 | "build_wheel", 11 | "get_requires_for_build_sdist", 12 | "get_requires_for_build_wheel", 13 | "prepare_metadata_for_build_wheel", 14 | ] 15 | -------------------------------------------------------------------------------- /tests/console/commands/test_about.py: -------------------------------------------------------------------------------- 1 | import pytest 2 | 3 | 4 | @pytest.fixture() 5 | def tester(command_tester_factory): 6 | return command_tester_factory("about") 7 | 8 | 9 | def test_about(tester): 10 | tester.execute() 11 | expected = """\ 12 | Poetry - Package Management for Python 13 | 14 | Poetry is a dependency manager tracking local dependencies of your projects and libraries. 15 | See https://github.com/python-poetry/poetry for more information. 16 | """ 17 | 18 | assert expected == tester.io.fetch_output() 19 | -------------------------------------------------------------------------------- /tests/fixtures/git/github.com/demo/demo/setup.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | from setuptools import setup 3 | 4 | 5 | kwargs = dict( 6 | name="demo", 7 | license="MIT", 8 | version="0.1.2", 9 | description="Demo project.", 10 | author="Sébastien Eustace", 11 | author_email="sebastien@eustace.io", 12 | url="https://github.com/demo/demo", 13 | packages=["demo"], 14 | install_requires=["pendulum>=1.4.4"], 15 | extras_require={"foo": ["cleo"], "bar": ["tomlkit"]}, 16 | ) 17 | 18 | 19 | setup(**kwargs) 20 | -------------------------------------------------------------------------------- /tests/fixtures/project_with_multi_constraints_dependency/pyproject.toml: -------------------------------------------------------------------------------- 1 | [tool.poetry] 2 | name = "project-with-multi-constraints-dependency" 3 | version = "1.2.3" 4 | description = "This is a description" 5 | authors = ["Your Name "] 6 | license = "MIT" 7 | 8 | packages = [ 9 | {include = "project"} 10 | ] 11 | 12 | [tool.poetry.dependencies] 13 | python = "*" 14 | pendulum = [ 15 | { version = "^1.5", python = "<3.4" }, 16 | { version = "^2.0", python = "^3.4" } 17 | ] 18 | 19 | [tool.poetry.dev-dependencies] 20 | -------------------------------------------------------------------------------- /poetry/console/commands/about.py: -------------------------------------------------------------------------------- 1 | from .command import Command 2 | 3 | 4 | class AboutCommand(Command): 5 | 6 | name = "about" 7 | 8 | description = "Shows information about Poetry." 9 | 10 | def handle(self) -> None: 11 | self.line( 12 | """Poetry - Package Management for Python 13 | 14 | Poetry is a dependency manager tracking local dependencies of your projects and libraries. 15 | See https://github.com/python-poetry/poetry for more information.""" 16 | ) 17 | -------------------------------------------------------------------------------- /tests/fixtures/directory/project_with_transitive_directory_dependencies/pyproject.toml: -------------------------------------------------------------------------------- 1 | [tool.poetry] 2 | name = "project-with-transitive-directory-dependencies" 3 | version = "1.2.3" 4 | description = "This is a description" 5 | authors = ["Your Name "] 6 | license = "MIT" 7 | 8 | [tool.poetry.dependencies] 9 | python = "*" 10 | project-with-extras = {path = "../../project_with_extras/"} 11 | project-with-transitive-file-dependencies = {path = "../project_with_transitive_file_dependencies/"} 12 | 13 | [tool.poetry.dev-dependencies] 14 | -------------------------------------------------------------------------------- /tests/installation/fixtures/with-category-change.test: -------------------------------------------------------------------------------- 1 | [[package]] 2 | name = "A" 3 | version = "1.0" 4 | description = "" 5 | category = "main" 6 | optional = false 7 | python-versions = "*" 8 | 9 | [[package]] 10 | name = "B" 11 | version = "1.1" 12 | description = "" 13 | category = "main" 14 | optional = false 15 | python-versions = "*" 16 | 17 | [package.dependencies] 18 | A = "^1.0" 19 | 20 | [metadata] 21 | python-versions = "*" 22 | lock-version = "1.1" 23 | content-hash = "123456789" 24 | 25 | [metadata.files] 26 | "A" = [] 27 | "B" = [] 28 | -------------------------------------------------------------------------------- /tests/fixtures/git/github.com/demo/non-canonical-name/setup.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | from setuptools import setup 3 | 4 | 5 | kwargs = dict( 6 | name="Demo", 7 | license="MIT", 8 | version="0.1.2", 9 | description="Demo project.", 10 | author="Sébastien Eustace", 11 | author_email="sebastien@eustace.io", 12 | url="https://github.com/demo/demo", 13 | packages=["demo"], 14 | install_requires=["pendulum>=1.4.4"], 15 | extras_require={"foo": ["cleo"], "bar": ["tomlkit"]}, 16 | ) 17 | 18 | 19 | setup(**kwargs) 20 | -------------------------------------------------------------------------------- /tests/repositories/fixtures/legacy/tomlkit.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Links for tomlkit 5 | 6 | 7 |

Links for tomlkit

8 | tomlkit-0.5.2.tar.gz
9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /.flake8: -------------------------------------------------------------------------------- 1 | [flake8] 2 | max-line-length = 88 3 | ignore = E501, E203, W503 4 | per-file-ignores = 5 | __init__.py:F401 6 | tests/console/commands/debug/test_resolve.py:W291 7 | exclude = 8 | .git 9 | __pycache__ 10 | setup.py 11 | build 12 | dist 13 | releases 14 | .venv 15 | .tox 16 | .mypy_cache 17 | .pytest_cache 18 | .vscode 19 | .github 20 | poetry/utils/_compat.py 21 | poetry/utils/env_scripts/tags.py 22 | tests/fixtures/ 23 | tests/repositories/fixtures/ 24 | tests/utils/fixtures/ 25 | -------------------------------------------------------------------------------- /tests/fixtures/with_non_default_multiple_sources/pyproject.toml: -------------------------------------------------------------------------------- 1 | [tool.poetry] 2 | name = "my-package" 3 | version = "1.2.3" 4 | description = "Some description." 5 | authors = [ 6 | "Your Name " 7 | ] 8 | license = "MIT" 9 | 10 | # Requirements 11 | [tool.poetry.dependencies] 12 | python = "~2.7 || ^3.6" 13 | 14 | [tool.poetry.dev-dependencies] 15 | 16 | [[tool.poetry.source]] 17 | name = "foo" 18 | url = "https://foo.bar/simple/" 19 | secondary = true 20 | 21 | [[tool.poetry.source]] 22 | name = "bar" 23 | url = "https://bar.baz/simple/" 24 | -------------------------------------------------------------------------------- /tests/repositories/fixtures/legacy/python-language-server.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Links for python-language-server 5 | 6 | 7 |

Links for python-language-server

8 | python-language-server-0.21.2.tar.gz
9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /tests/fixtures/with_non_default_multiple_secondary_sources/pyproject.toml: -------------------------------------------------------------------------------- 1 | [tool.poetry] 2 | name = "my-package" 3 | version = "1.2.3" 4 | description = "Some description." 5 | authors = [ 6 | "Your Name " 7 | ] 8 | license = "MIT" 9 | 10 | # Requirements 11 | [tool.poetry.dependencies] 12 | python = "~2.7 || ^3.6" 13 | 14 | [tool.poetry.dev-dependencies] 15 | 16 | [[tool.poetry.source]] 17 | name = "foo" 18 | url = "https://foo.bar/simple/" 19 | secondary = true 20 | 21 | [[tool.poetry.source]] 22 | name = "bar" 23 | url = "https://bar.baz/simple/" 24 | secondary = true 25 | -------------------------------------------------------------------------------- /poetry/puzzle/exceptions.py: -------------------------------------------------------------------------------- 1 | from typing import Dict 2 | from typing import Tuple 3 | 4 | 5 | class SolverProblemError(Exception): 6 | def __init__(self, error: Exception) -> None: 7 | self._error = error 8 | 9 | super().__init__(str(error)) 10 | 11 | @property 12 | def error(self) -> Exception: 13 | return self._error 14 | 15 | 16 | class OverrideNeeded(Exception): 17 | def __init__(self, *overrides: Dict) -> None: 18 | self._overrides = overrides 19 | 20 | @property 21 | def overrides(self) -> Tuple[Dict]: 22 | return self._overrides 23 | -------------------------------------------------------------------------------- /tests/fixtures/inspection/demo_no_setup_pkg_info_no_deps/pyproject.toml: -------------------------------------------------------------------------------- 1 | # this was copied over and modified from orjson project's pyproject.toml 2 | # https://github.com/ijl/orjson/blob/master/pyproject.toml 3 | [project] 4 | name = "demo" 5 | repository = "https://github.com/demo/demo" 6 | 7 | [build-system] 8 | build-backend = "maturin" 9 | requires = ["maturin>=0.8.1,<0.9"] 10 | 11 | [tool.maturin] 12 | manylinux = "off" 13 | sdist-include = ["Cargo.lock", "json/**/*"] 14 | strip = "on" 15 | 16 | [tool.black] 17 | line-length = 88 18 | target-version = ['py36', 'py37', 'py38'] 19 | include = '\.pyi?$' 20 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.pyc 2 | 3 | # Packages 4 | *.egg 5 | !/tests/**/*.egg 6 | /*.egg-info 7 | /dist/* 8 | build 9 | _build 10 | .cache 11 | *.so 12 | 13 | # Installer logs 14 | pip-log.txt 15 | 16 | # Unit test / coverage reports 17 | .coverage 18 | .tox 19 | .pytest_cache 20 | 21 | .DS_Store 22 | .idea/* 23 | .python-version 24 | .vscode/* 25 | 26 | /test.py 27 | /test_*.* 28 | 29 | /setup.cfg 30 | MANIFEST.in 31 | /setup.py 32 | /docs/site/* 33 | /tests/fixtures/simple_project/setup.py 34 | /tests/fixtures/project_with_extras/setup.py 35 | .mypy_cache 36 | 37 | .venv 38 | /releases/* 39 | pip-wheel-metadata 40 | /poetry.toml 41 | -------------------------------------------------------------------------------- /poetry/locations.py: -------------------------------------------------------------------------------- 1 | import os 2 | 3 | from pathlib import Path 4 | 5 | from .utils.appdirs import user_cache_dir 6 | from .utils.appdirs import user_config_dir 7 | from .utils.appdirs import user_data_dir 8 | 9 | 10 | CACHE_DIR = user_cache_dir("pypoetry") 11 | DATA_DIR = user_data_dir("pypoetry") 12 | CONFIG_DIR = user_config_dir("pypoetry") 13 | 14 | REPOSITORY_CACHE_DIR = Path(CACHE_DIR) / "cache" / "repositories" 15 | 16 | 17 | def data_dir() -> Path: 18 | if os.getenv("POETRY_HOME"): 19 | return Path(os.getenv("POETRY_HOME")).expanduser() 20 | 21 | return Path(user_data_dir("pypoetry", roaming=True)) 22 | -------------------------------------------------------------------------------- /tests/installation/fixtures/with-conditional-dependency.test: -------------------------------------------------------------------------------- 1 | [[package]] 2 | name = "A" 3 | version = "1.0.0" 4 | description = "" 5 | category = "main" 6 | optional = false 7 | python-versions = ">=3.5" 8 | 9 | [package.requirements] 10 | python = ">=3.5,<4.0" 11 | 12 | [[package]] 13 | name = "A" 14 | version = "1.0.1" 15 | description = "" 16 | category = "main" 17 | optional = false 18 | python-versions = ">=3.6" 19 | 20 | [package.requirements] 21 | python = ">=3.6,<4.0" 22 | 23 | [metadata] 24 | python-versions = "~2.7 || ^3.4" 25 | lock-version = "1.1" 26 | content-hash = "123456789" 27 | 28 | [metadata.files] 29 | A = [] 30 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | # Pull Request Check List 2 | 3 | Resolves: #issue-number-here 4 | 5 | 6 | 7 | - [ ] Added **tests** for changed code. 8 | - [ ] Updated **documentation** for changed code. 9 | 10 | 11 | -------------------------------------------------------------------------------- /tests/installation/fixtures/install-no-dev.test: -------------------------------------------------------------------------------- 1 | [[package]] 2 | name = "A" 3 | version = "1.0" 4 | description = "" 5 | category = "main" 6 | optional = false 7 | python-versions = "*" 8 | 9 | [[package]] 10 | name = "B" 11 | version = "1.1" 12 | description = "" 13 | category = "main" 14 | optional = false 15 | python-versions = "*" 16 | 17 | [[package]] 18 | name = "C" 19 | version = "1.2" 20 | description = "" 21 | category = "dev" 22 | optional = false 23 | python-versions = "*" 24 | 25 | [metadata] 26 | python-versions = "*" 27 | lock-version = "1.1" 28 | content-hash = "123456789" 29 | 30 | [metadata.files] 31 | "A" = [] 32 | "B" = [] 33 | "C" = [] 34 | -------------------------------------------------------------------------------- /tests/installation/fixtures/with-wheel-dependency-no-requires-dist.test: -------------------------------------------------------------------------------- 1 | [[package]] 2 | name = "demo" 3 | version = "0.1.0" 4 | description = "" 5 | category = "main" 6 | optional = false 7 | python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" 8 | 9 | [package.source] 10 | type = "file" 11 | url = "tests/fixtures/wheel_with_no_requires_dist/demo-0.1.0-py2.py3-none-any.whl" 12 | 13 | [metadata] 14 | python-versions = "*" 15 | lock-version = "1.1" 16 | content-hash = "123456789" 17 | 18 | [metadata.files] 19 | demo = [ 20 | {file = "demo-0.1.0-py2.py3-none-any.whl", hash = "sha256:c25eb81459126848a1788eb3520d1a32014eb51ce3d3bae88c56bfdde4ce02db"}, 21 | ] 22 | -------------------------------------------------------------------------------- /tests/installation/fixtures/with-python-versions.test: -------------------------------------------------------------------------------- 1 | [[package]] 2 | name = "A" 3 | version = "1.0" 4 | description = "" 5 | category = "main" 6 | optional = false 7 | python-versions = "*" 8 | 9 | [[package]] 10 | name = "B" 11 | version = "1.1" 12 | description = "" 13 | category = "main" 14 | optional = false 15 | python-versions = "*" 16 | 17 | [[package]] 18 | name = "C" 19 | version = "1.2" 20 | description = "" 21 | category = "main" 22 | optional = false 23 | python-versions = "~2.7 || ^3.3" 24 | 25 | [metadata] 26 | python-versions = "~2.7 || ^3.4" 27 | lock-version = "1.1" 28 | content-hash = "123456789" 29 | 30 | [metadata.files] 31 | A = [] 32 | B = [] 33 | C = [] 34 | -------------------------------------------------------------------------------- /poetry/console/commands/env/remove.py: -------------------------------------------------------------------------------- 1 | from cleo.helpers import argument 2 | 3 | from ..command import Command 4 | 5 | 6 | class EnvRemoveCommand(Command): 7 | 8 | name = "env remove" 9 | description = "Removes a specific virtualenv associated with the project." 10 | 11 | arguments = [ 12 | argument("python", "The python executable to remove the virtualenv for.") 13 | ] 14 | 15 | def handle(self) -> None: 16 | from poetry.utils.env import EnvManager 17 | 18 | manager = EnvManager(self.poetry) 19 | venv = manager.remove(self.argument("python")) 20 | 21 | self.line("Deleted virtualenv: {}".format(venv.path)) 22 | -------------------------------------------------------------------------------- /tests/console/commands/env/helpers.py: -------------------------------------------------------------------------------- 1 | from pathlib import Path 2 | from typing import Any 3 | from typing import Union 4 | 5 | from poetry.core.semver.version import Version 6 | 7 | 8 | def build_venv(path: Union[Path, str], **_: Any) -> (): 9 | Path(path).mkdir(parents=True, exist_ok=True) 10 | 11 | 12 | def check_output_wrapper(version=Version.parse("3.7.1")): 13 | def check_output(cmd, *_, **__): 14 | if "sys.version_info[:3]" in cmd: 15 | return version.text 16 | elif "sys.version_info[:2]" in cmd: 17 | return "{}.{}".format(version.major, version.minor) 18 | else: 19 | return str(Path("/prefix")) 20 | 21 | return check_output 22 | -------------------------------------------------------------------------------- /poetry/console/commands/cache/list.py: -------------------------------------------------------------------------------- 1 | import os 2 | 3 | from typing import Optional 4 | 5 | from ..command import Command 6 | 7 | 8 | class CacheListCommand(Command): 9 | 10 | name = "cache list" 11 | description = "List Poetry's caches." 12 | 13 | def handle(self) -> Optional[int]: 14 | from poetry.locations import REPOSITORY_CACHE_DIR 15 | 16 | if os.path.exists(str(REPOSITORY_CACHE_DIR)): 17 | caches = list(sorted(REPOSITORY_CACHE_DIR.iterdir())) 18 | if caches: 19 | for cache in caches: 20 | self.line("{}".format(cache.name)) 21 | return 0 22 | 23 | self.line("No caches found") 24 | -------------------------------------------------------------------------------- /tests/fixtures/directory/project_with_transitive_directory_dependencies/setup.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | from distutils.core import setup 3 | 4 | packages = ["project_with_extras"] 5 | 6 | package_data = {"": ["*"]} 7 | 8 | extras_require = {"extras_a": ["pendulum>=1.4.4"], "extras_b": ["cachy>=0.2.0"]} 9 | 10 | setup_kwargs = { 11 | "name": "project-with-extras", 12 | "version": "1.2.3", 13 | "description": "This is a description", 14 | "long_description": None, 15 | "author": "Your Name", 16 | "author_email": "you@example.com", 17 | "url": None, 18 | "packages": packages, 19 | "package_data": package_data, 20 | "extras_require": extras_require, 21 | } 22 | 23 | 24 | setup(**setup_kwargs) 25 | -------------------------------------------------------------------------------- /tests/utils/fixtures/pyproject.toml: -------------------------------------------------------------------------------- 1 | [tool.poetry] 2 | name = "poetry" 3 | version = "0.2.0" 4 | description = "Python dependency management and packaging made easy." 5 | authors = [ 6 | "Sébastien Eustace " 7 | ] 8 | license = "MIT" 9 | 10 | readme = "README.md" 11 | 12 | homepage = "https://python-poetry.org/" 13 | repository = "https://github.com/python-poetry/poetry" 14 | documentation = "https://python-poetry.org/docs" 15 | 16 | keywords = ["packaging", "dependency", "poetry"] 17 | 18 | # Requirements 19 | [tool.poetry.dependencies] 20 | python = "^3.6" 21 | cleo = "^0.6" 22 | requests = "^2.18" 23 | toml = "^0.9" 24 | cachy = "^0.1.0" 25 | pip-tools = "^1.11" 26 | 27 | [tool.poetry.dev-dependencies] 28 | pytest = "~3.4" 29 | -------------------------------------------------------------------------------- /poetry/mixology/__init__.py: -------------------------------------------------------------------------------- 1 | from typing import TYPE_CHECKING 2 | from typing import Dict 3 | from typing import List 4 | 5 | from .version_solver import VersionSolver 6 | 7 | 8 | if TYPE_CHECKING: 9 | from poetry.core.packages.project_package import ProjectPackage 10 | from poetry.packages import DependencyPackage 11 | from poetry.puzzle.provider import Provider 12 | 13 | from .result import SolverResult 14 | 15 | 16 | def resolve_version( 17 | root: "ProjectPackage", 18 | provider: "Provider", 19 | locked: Dict[str, "DependencyPackage"] = None, 20 | use_latest: List[str] = None, 21 | ) -> "SolverResult": 22 | solver = VersionSolver(root, provider, locked=locked, use_latest=use_latest) 23 | 24 | return solver.solve() 25 | -------------------------------------------------------------------------------- /tests/installation/fixtures/with-optional-dependencies.test: -------------------------------------------------------------------------------- 1 | [[package]] 2 | name = "A" 3 | version = "1.0" 4 | description = "" 5 | category = "main" 6 | optional = true 7 | python-versions = "*" 8 | 9 | [[package]] 10 | name = "C" 11 | version = "1.3" 12 | description = "" 13 | category = "main" 14 | optional = false 15 | python-versions = "*" 16 | 17 | [package.dependencies] 18 | D = "^1.2" 19 | 20 | [[package]] 21 | name = "D" 22 | version = "1.4" 23 | description = "" 24 | category = "main" 25 | optional = false 26 | python-versions = "*" 27 | 28 | [extras] 29 | foo = ["A"] 30 | 31 | [metadata] 32 | python-versions = "~2.7 || ^3.4" 33 | lock-version = "1.1" 34 | content-hash = "123456789" 35 | 36 | [metadata.files] 37 | A = [] 38 | C = [] 39 | D = [] 40 | -------------------------------------------------------------------------------- /tests/fixtures/extended_project/pyproject.toml: -------------------------------------------------------------------------------- 1 | [tool.poetry] 2 | name = "extended-project" 3 | version = "1.2.3" 4 | description = "Some description." 5 | authors = [ 6 | "Sébastien Eustace " 7 | ] 8 | license = "MIT" 9 | 10 | readme = "README.rst" 11 | 12 | homepage = "https://python-poetry.org" 13 | repository = "https://github.com/python-poetry/poetry" 14 | documentation = "https://python-poetry.org/docs" 15 | 16 | keywords = ["packaging", "dependency", "poetry"] 17 | 18 | classifiers = [ 19 | "Topic :: Software Development :: Build Tools", 20 | "Topic :: Software Development :: Libraries :: Python Modules" 21 | ] 22 | 23 | build = "build.py" 24 | 25 | # Requirements 26 | [tool.poetry.dependencies] 27 | python = "~2.7 || ^3.4" 28 | -------------------------------------------------------------------------------- /make-nix-release.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -ex 4 | 5 | RUNTIMES[0]="${PYTHON27:+-P "2.7:$PYTHON27"}" 6 | RUNTIMES[1]="${PYTHON35:+-P "3.5:$PYTHON35"}" 7 | RUNTIMES[2]="${PYTHON36:+-P "3.6:$PYTHON36"}" 8 | RUNTIMES[3]="${PYTHON37:+-P "3.7:$PYTHON37"}" 9 | RUNTIMES[4]="${PYTHON38:+-P "3.8:$PYTHON38"}" 10 | 11 | test -n "$PYTHON" || PYTHON="python3" 12 | 13 | if [ "$OSTYPE" == "linux-gnu" ]; then 14 | $PYTHON get-poetry.py -y --preview 15 | POETRY="$PYTHON $HOME/.poetry/bin/poetry" 16 | RUNTIMES[5]="${PYTHON39:+-P "3.9:$PYTHON39"}" 17 | else 18 | $PYTHON -m pip install poetry -U --pre 19 | POETRY="$PYTHON -m poetry" 20 | fi 21 | 22 | $POETRY config virtualenvs.in-project true 23 | $POETRY install --no-dev 24 | $POETRY run python sonnet make release ${RUNTIMES[@]} 25 | -------------------------------------------------------------------------------- /tests/installation/fixtures/with-duplicate-dependencies-update.test: -------------------------------------------------------------------------------- 1 | [[package]] 2 | name = "A" 3 | version = "1.1" 4 | description = "" 5 | category = "main" 6 | optional = false 7 | python-versions = "*" 8 | 9 | [package.dependencies] 10 | B = "^2.0" 11 | 12 | [[package]] 13 | name = "B" 14 | version = "2.0" 15 | description = "" 16 | category = "main" 17 | optional = false 18 | python-versions = "*" 19 | 20 | [package.dependencies] 21 | C = "1.5" 22 | 23 | [[package]] 24 | name = "C" 25 | version = "1.5" 26 | description = "" 27 | category = "main" 28 | optional = false 29 | python-versions = "*" 30 | 31 | [metadata] 32 | python-versions = "*" 33 | lock-version = "1.1" 34 | content-hash = "123456789" 35 | 36 | [metadata.files] 37 | A = [] 38 | B = [] 39 | C = [] 40 | -------------------------------------------------------------------------------- /tests/repositories/fixtures/legacy/relative.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Links for poetry 5 | 6 | 7 |

Links for poetry

8 | poetry-0.1.0-py3-none-any.whl
9 | poetry-0.1.0.tar.gz
10 | poetry-0.1.1.tar.bz
11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /poetry/console/commands/env/use.py: -------------------------------------------------------------------------------- 1 | from cleo.helpers import argument 2 | 3 | from ..command import Command 4 | 5 | 6 | class EnvUseCommand(Command): 7 | 8 | name = "env use" 9 | description = "Activates or creates a new virtualenv for the current project." 10 | 11 | arguments = [argument("python", "The python executable to use.")] 12 | 13 | def handle(self) -> None: 14 | from poetry.utils.env import EnvManager 15 | 16 | manager = EnvManager(self.poetry) 17 | 18 | if self.argument("python") == "system": 19 | manager.deactivate(self._io) 20 | 21 | return 22 | 23 | env = manager.activate(self.argument("python"), self._io) 24 | 25 | self.line("Using virtualenv: {}".format(env.path)) 26 | -------------------------------------------------------------------------------- /tests/utils/test_pip.py: -------------------------------------------------------------------------------- 1 | import subprocess 2 | 3 | import pytest 4 | 5 | from poetry.utils.pip import pip_install 6 | 7 | 8 | def test_pip_install_successful(tmp_dir, tmp_venv, fixture_dir): 9 | file_path = fixture_dir("distributions/demo-0.1.0-py2.py3-none-any.whl") 10 | result = pip_install(file_path, tmp_venv) 11 | 12 | assert "Successfully installed demo-0.1.0" in result 13 | 14 | 15 | def test_pip_install_with_keyboard_interrupt(tmp_dir, tmp_venv, fixture_dir, mocker): 16 | file_path = fixture_dir("distributions/demo-0.1.0-py2.py3-none-any.whl") 17 | mocker.patch("subprocess.run", side_effect=KeyboardInterrupt()) 18 | with pytest.raises(KeyboardInterrupt): 19 | pip_install(file_path, tmp_venv) 20 | subprocess.run.assert_called_once() 21 | -------------------------------------------------------------------------------- /tests/installation/fixtures/with-dependencies-extras.test: -------------------------------------------------------------------------------- 1 | [[package]] 2 | name = "A" 3 | version = "1.0" 4 | description = "" 5 | category = "main" 6 | optional = false 7 | python-versions = "*" 8 | 9 | [[package]] 10 | name = "B" 11 | version = "1.0" 12 | description = "" 13 | category = "main" 14 | optional = false 15 | python-versions = "*" 16 | 17 | [package.dependencies] 18 | C = {version = "^1.0", optional = true} 19 | 20 | [package.extras] 21 | foo = ["C (>=1.0,<2.0)"] 22 | 23 | [[package]] 24 | name = "C" 25 | version = "1.0" 26 | description = "" 27 | category = "main" 28 | optional = false 29 | python-versions = "*" 30 | 31 | [metadata] 32 | python-versions = "*" 33 | lock-version = "1.1" 34 | content-hash = "123456789" 35 | 36 | [metadata.files] 37 | "A" = [] 38 | "B" = [] 39 | "C" = [] 40 | -------------------------------------------------------------------------------- /poetry/mixology/result.py: -------------------------------------------------------------------------------- 1 | from typing import TYPE_CHECKING 2 | from typing import List 3 | 4 | 5 | if TYPE_CHECKING: 6 | from poetry.core.packages.package import Package 7 | from poetry.core.packages.project_package import ProjectPackage 8 | 9 | 10 | class SolverResult: 11 | def __init__( 12 | self, 13 | root: "ProjectPackage", 14 | packages: List["Package"], 15 | attempted_solutions: int, 16 | ) -> None: 17 | self._root = root 18 | self._packages = packages 19 | self._attempted_solutions = attempted_solutions 20 | 21 | @property 22 | def packages(self) -> List["Package"]: 23 | return self._packages 24 | 25 | @property 26 | def attempted_solutions(self) -> int: 27 | return self._attempted_solutions 28 | -------------------------------------------------------------------------------- /tests/installation/fixtures/with-url-dependency.test: -------------------------------------------------------------------------------- 1 | [[package]] 2 | name = "demo" 3 | version = "0.1.0" 4 | description = "" 5 | category = "main" 6 | optional = false 7 | python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" 8 | 9 | [package.source] 10 | type = "url" 11 | url = "https://python-poetry.org/distributions/demo-0.1.0-py2.py3-none-any.whl" 12 | 13 | [package.dependencies] 14 | pendulum = ">=1.4.4" 15 | 16 | [package.extras] 17 | bar = ["tomlkit"] 18 | foo = ["cleo"] 19 | 20 | [[package]] 21 | name = "pendulum" 22 | version = "1.4.4" 23 | description = "" 24 | category = "main" 25 | optional = false 26 | python-versions = "*" 27 | 28 | [metadata] 29 | python-versions = "*" 30 | lock-version = "1.1" 31 | content-hash = "123456789" 32 | 33 | [metadata.files] 34 | demo = [] 35 | pendulum = [] 36 | -------------------------------------------------------------------------------- /tests/repositories/fixtures/legacy/absolute.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Links for poetry 5 | 6 | 7 |

Links for poetry

8 | poetry-0.1.0-py3-none-any.whl
9 | poetry-0.1.0.tar.gz
10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /tests/repositories/fixtures/legacy/futures.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Links for futures 5 | 6 | 7 |

Links for futures

8 | futures-3.2.0-py2-none-any.whl
9 | futures-3.2.0.tar.gz
10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /tests/fixtures/extended_project_without_setup/pyproject.toml: -------------------------------------------------------------------------------- 1 | [tool.poetry] 2 | name = "extended-project" 3 | version = "1.2.3" 4 | description = "Some description." 5 | authors = [ 6 | "Sébastien Eustace " 7 | ] 8 | license = "MIT" 9 | 10 | readme = "README.rst" 11 | 12 | homepage = "https://python-poetry.org" 13 | repository = "https://github.com/python-poetry/poetry" 14 | documentation = "https://python-poetry.org/docs" 15 | 16 | keywords = ["packaging", "dependency", "poetry"] 17 | 18 | classifiers = [ 19 | "Topic :: Software Development :: Build Tools", 20 | "Topic :: Software Development :: Libraries :: Python Modules" 21 | ] 22 | 23 | [tool.poetry.build] 24 | script = "build.py" 25 | generate-setup-file = false 26 | 27 | # Requirements 28 | [tool.poetry.dependencies] 29 | python = "~2.7 || ^3.4" 30 | -------------------------------------------------------------------------------- /poetry/console/logging/io_handler.py: -------------------------------------------------------------------------------- 1 | import logging 2 | 3 | from typing import TYPE_CHECKING 4 | 5 | 6 | if TYPE_CHECKING: 7 | from logging import LogRecord 8 | 9 | from cleo.io.io import IO # noqa 10 | 11 | 12 | class IOHandler(logging.Handler): 13 | def __init__(self, io: "IO") -> None: 14 | self._io = io 15 | 16 | super(IOHandler, self).__init__() 17 | 18 | def emit(self, record: "LogRecord") -> None: 19 | try: 20 | msg = self.format(record) 21 | level = record.levelname.lower() 22 | err = level in ("warning", "error", "exception", "critical") 23 | if err: 24 | self._io.write_error_line(msg) 25 | else: 26 | self._io.write_line(msg) 27 | except Exception: 28 | self.handleError(record) 29 | -------------------------------------------------------------------------------- /tests/installation/fixtures/extras.test: -------------------------------------------------------------------------------- 1 | [[package]] 2 | name = "A" 3 | version = "1.0" 4 | description = "" 5 | category = "main" 6 | optional = false 7 | python-versions = "*" 8 | 9 | [[package]] 10 | name = "B" 11 | version = "1.0" 12 | description = "" 13 | category = "main" 14 | optional = false 15 | python-versions = "*" 16 | 17 | [[package]] 18 | name = "C" 19 | version = "1.0" 20 | description = "" 21 | category = "main" 22 | optional = false 23 | python-versions = "*" 24 | 25 | [[package]] 26 | name = "D" 27 | version = "1.1" 28 | description = "" 29 | category = "main" 30 | optional = true 31 | python-versions = "*" 32 | 33 | [extras] 34 | foo = ["D"] 35 | 36 | [metadata] 37 | python-versions = "*" 38 | lock-version = "1.1" 39 | content-hash = "123456789" 40 | 41 | [metadata.files] 42 | A = [] 43 | B = [] 44 | C = [] 45 | D = [] 46 | -------------------------------------------------------------------------------- /.pre-commit-config.yaml: -------------------------------------------------------------------------------- 1 | repos: 2 | - repo: https://github.com/psf/black 3 | rev: 20.8b1 4 | hooks: 5 | - id: black 6 | 7 | - repo: https://gitlab.com/pycqa/flake8 8 | rev: 3.8.4 9 | hooks: 10 | - id: flake8 11 | 12 | - repo: https://github.com/timothycrosley/isort 13 | rev: 5.7.0 14 | hooks: 15 | - id: isort 16 | additional_dependencies: [toml] 17 | exclude: ^.*/?setup\.py$ 18 | 19 | - repo: https://github.com/pre-commit/pre-commit-hooks 20 | rev: v3.4.0 21 | hooks: 22 | - id: trailing-whitespace 23 | exclude: | 24 | (?x)( 25 | ^tests/.*/fixtures/.* 26 | | ^tests/console/commands/debug/test_resolve.py 27 | ) 28 | - id: end-of-file-fixer 29 | exclude: ^tests/.*/fixtures/.* 30 | - id: debug-statements 31 | -------------------------------------------------------------------------------- /tests/console/commands/test_run.py: -------------------------------------------------------------------------------- 1 | import pytest 2 | 3 | 4 | @pytest.fixture 5 | def tester(command_tester_factory): 6 | return command_tester_factory("run") 7 | 8 | 9 | @pytest.fixture(autouse=True) 10 | def patches(mocker, env): 11 | mocker.patch("poetry.utils.env.EnvManager.get", return_value=env) 12 | 13 | 14 | def test_run_passes_all_args(app_tester, env): 15 | app_tester.execute("run python -V") 16 | assert [["python", "-V"]] == env.executed 17 | 18 | 19 | def test_run_keeps_options_passed_before_command(app_tester, env): 20 | app_tester.execute("-V --no-ansi run python", decorated=True) 21 | 22 | assert not app_tester.io.is_decorated() 23 | assert app_tester.io.fetch_output() == app_tester.io.remove_format( 24 | app_tester.application.long_version + "\n" 25 | ) 26 | assert [] == env.executed 27 | -------------------------------------------------------------------------------- /poetry/console/logging/formatters/builder_formatter.py: -------------------------------------------------------------------------------- 1 | import re 2 | 3 | from .formatter import Formatter 4 | 5 | 6 | class BuilderLogFormatter(Formatter): 7 | def format(self, msg: str) -> str: 8 | if msg.startswith("Building "): 9 | msg = re.sub("Building (.+)", " - Building \\1", msg) 10 | elif msg.startswith("Built "): 11 | msg = re.sub("Built (.+)", " - Built \\1", msg) 12 | elif msg.startswith("Adding: "): 13 | msg = re.sub("Adding: (.+)", " - Adding: \\1", msg) 14 | elif msg.startswith("Executing build script: "): 15 | msg = re.sub( 16 | "Executing build script: (.+)", 17 | " - Executing build script: \\1", 18 | msg, 19 | ) 20 | 21 | return msg 22 | -------------------------------------------------------------------------------- /tests/fixtures/git/github.com/demo/no-version/setup.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | import ast 3 | import os 4 | 5 | from setuptools import setup 6 | 7 | 8 | def read_version(): 9 | with open(os.path.join(os.path.dirname(__file__), "demo", "__init__.py")) as f: 10 | for line in f: 11 | if line.startswith("__version__ = "): 12 | return ast.literal_eval(line[len("__version__ = ") :].strip()) 13 | 14 | 15 | kwargs = dict( 16 | name="demo", 17 | license="MIT", 18 | version=read_version(), 19 | description="Demo project.", 20 | author="Sébastien Eustace", 21 | author_email="sebastien@eustace.io", 22 | url="https://github.com/demo/demo", 23 | packages=["demo"], 24 | install_requires=["pendulum>=1.4.4"], 25 | extras_require={"foo": ["cleo"]}, 26 | ) 27 | 28 | 29 | setup(**kwargs) 30 | -------------------------------------------------------------------------------- /tests/repositories/fixtures/installed/src/bender/bender.egg-info/PKG-INFO: -------------------------------------------------------------------------------- 1 | Metadata-Version: 2.1 2 | Name: bender 3 | Version: 2.0.5 4 | Summary: Python datetimes made easy 5 | License: MIT 6 | Keywords: cli,commands 7 | Author: Leela 8 | Author-email: leela@planetexpress.com 9 | Requires-Python: >=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.* 10 | Classifier: License :: OSI Approved :: MIT License 11 | Classifier: Programming Language :: Python :: 2 12 | Classifier: Programming Language :: Python :: 2.7 13 | Classifier: Programming Language :: Python :: 3 14 | Classifier: Programming Language :: Python :: 3.4 15 | Classifier: Programming Language :: Python :: 3.5 16 | Classifier: Programming Language :: Python :: 3.6 17 | Classifier: Programming Language :: Python :: 3.7 18 | Classifier: Programming Language :: Python :: 3.8 19 | Description-Content-Type: text/x-rst 20 | -------------------------------------------------------------------------------- /poetry/console/commands/debug/info.py: -------------------------------------------------------------------------------- 1 | import sys 2 | 3 | from ..command import Command 4 | 5 | 6 | class DebugInfoCommand(Command): 7 | 8 | name = "debug info" 9 | description = "Shows debug information." 10 | 11 | def handle(self) -> int: 12 | poetry_python_version = ".".join(str(s) for s in sys.version_info[:3]) 13 | 14 | self.line("") 15 | self.line("Poetry") 16 | self.line( 17 | "\n".join( 18 | [ 19 | "Version: {}".format(self.poetry.VERSION), 20 | "Python: {}".format( 21 | poetry_python_version 22 | ), 23 | ] 24 | ) 25 | ) 26 | command = self.application.get("env info") 27 | 28 | return command.run(self._io) 29 | -------------------------------------------------------------------------------- /poetry/console/commands/search.py: -------------------------------------------------------------------------------- 1 | from cleo.helpers import argument 2 | 3 | from .command import Command 4 | 5 | 6 | class SearchCommand(Command): 7 | 8 | name = "search" 9 | description = "Searches for packages on remote repositories." 10 | 11 | arguments = [argument("tokens", "The tokens to search for.", multiple=True)] 12 | 13 | def handle(self) -> None: 14 | from poetry.repositories.pypi_repository import PyPiRepository 15 | 16 | results = PyPiRepository().search(self.argument("tokens")) 17 | 18 | for result in results: 19 | self.line("") 20 | name = "{}".format(result.name) 21 | 22 | name += " ({})".format(result.version) 23 | 24 | self.line(name) 25 | 26 | if result.description: 27 | self.line(" {}".format(result.description)) 28 | -------------------------------------------------------------------------------- /tests/repositories/fixtures/legacy/pytest.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Links for pytest 5 | 6 | 7 |

Links for pytest

pytest-3.5.0-py2.py3-none-any.whl
8 | pytest-3.5.0.tar.gz
9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /tests/fixtures/old_lock/poetry.lock: -------------------------------------------------------------------------------- 1 | [[package]] 2 | category = "main" 3 | description = "A sample Python project" 4 | name = "sampleproject" 5 | optional = false 6 | python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, <4" 7 | version = "1.3.1" 8 | 9 | [metadata] 10 | content-hash = "c8c2c9d899e47bac3972e029ef0e71b75d5df98a28eebef25a75640a19aac177" 11 | lock-version = "1.0" 12 | python-versions = "^3.8" 13 | 14 | [metadata.files] 15 | sampleproject = [ 16 | {file = "sampleproject-1.3.1-py2.py3-none-any.whl", hash = "sha256:26c9172e08244873b0e09c574a229bf2c251c67723a05e08fd3ec0c5ee423796"}, 17 | {file = "sampleproject-1.3.1-py3-none-any.whl", hash = "sha256:75bb5bb4e74a1b77dc0cff25ebbacb54fe1318aaf99a86a036cefc86ed885ced"}, 18 | {file = "sampleproject-1.3.1.tar.gz", hash = "sha256:3593ca2f1e057279d70d6144b14472fb28035b1da213dde60906b703d6f82c55"}, 19 | ] 20 | -------------------------------------------------------------------------------- /tests/repositories/fixtures/installed/lib64/python3.7/site-packages/bender-2.0.5.dist-info/METADATA: -------------------------------------------------------------------------------- 1 | Metadata-Version: 2.1 2 | Name: bender 3 | Version: 2.0.5 4 | Summary: Python datetimes made easy 5 | License: MIT 6 | Keywords: cli,commands 7 | Author: Leela 8 | Author-email: leela@planetexpress.com 9 | Requires-Python: >=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.* 10 | Classifier: License :: OSI Approved :: MIT License 11 | Classifier: Programming Language :: Python :: 2 12 | Classifier: Programming Language :: Python :: 2.7 13 | Classifier: Programming Language :: Python :: 3 14 | Classifier: Programming Language :: Python :: 3.4 15 | Classifier: Programming Language :: Python :: 3.5 16 | Classifier: Programming Language :: Python :: 3.6 17 | Classifier: Programming Language :: Python :: 3.7 18 | Classifier: Programming Language :: Python :: 3.8 19 | Description-Content-Type: text/x-rst 20 | -------------------------------------------------------------------------------- /poetry/console/commands/command.py: -------------------------------------------------------------------------------- 1 | from typing import TYPE_CHECKING 2 | from typing import Optional 3 | 4 | from cleo.commands.command import Command as BaseCommand 5 | 6 | 7 | if TYPE_CHECKING: 8 | from poetry.console.application import Application 9 | from poetry.poetry import Poetry 10 | 11 | 12 | class Command(BaseCommand): 13 | loggers = [] 14 | 15 | _poetry: Optional["Poetry"] = None 16 | 17 | @property 18 | def poetry(self) -> "Poetry": 19 | if self._poetry is None: 20 | return self.get_application().poetry 21 | 22 | return self._poetry 23 | 24 | def set_poetry(self, poetry: "Poetry") -> None: 25 | self._poetry = poetry 26 | 27 | def get_application(self) -> "Application": 28 | return self.application 29 | 30 | def reset_poetry(self) -> None: 31 | self.get_application().reset_poetry() 32 | -------------------------------------------------------------------------------- /tests/installation/fixtures/with-directory-dependency-poetry.test: -------------------------------------------------------------------------------- 1 | [[package]] 2 | description = "" 3 | category = "main" 4 | name = "pendulum" 5 | optional = false 6 | python-versions = "*" 7 | version = "1.4.4" 8 | 9 | [[package]] 10 | category = "main" 11 | description = "This is a description" 12 | develop = false 13 | name = "project-with-extras" 14 | optional = false 15 | python-versions = "*" 16 | version = "1.2.3" 17 | 18 | [package.dependencies] 19 | pendulum = {version = ">=1.4.4", optional = true} 20 | 21 | [package.extras] 22 | extras_a = ["pendulum (>=1.4.4)"] 23 | extras_b = ["cachy (>=0.2.0)"] 24 | 25 | [package.source] 26 | type = "directory" 27 | url = "tests/fixtures/project_with_extras" 28 | 29 | [metadata] 30 | content-hash = "123456789" 31 | lock-version = "1.1" 32 | python-versions = "*" 33 | 34 | [metadata.files] 35 | project-with-extras = [] 36 | pendulum = [] 37 | -------------------------------------------------------------------------------- /tests/repositories/fixtures/installed/lib64/python3.7/site-packages/lib64-2.3.4.dist-info/METADATA: -------------------------------------------------------------------------------- 1 | Metadata-Version: 2.1 2 | Name: lib64 3 | Version: 2.3.4 4 | Summary: lib64 description. 5 | License: MIT 6 | Keywords: cli,commands 7 | Author: Foo Bar 8 | Author-email: foo@bar.com 9 | Requires-Python: >=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.* 10 | Classifier: License :: OSI Approved :: MIT License 11 | Classifier: Programming Language :: Python :: 2 12 | Classifier: Programming Language :: Python :: 2.7 13 | Classifier: Programming Language :: Python :: 3 14 | Classifier: Programming Language :: Python :: 3.4 15 | Classifier: Programming Language :: Python :: 3.5 16 | Classifier: Programming Language :: Python :: 3.6 17 | Classifier: Programming Language :: Python :: 3.7 18 | Classifier: Programming Language :: Python :: 3.8 19 | Description-Content-Type: text/x-rst 20 | 21 | lib64 22 | #### 23 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/---documentation.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: "\U0001F4DA Documentation" 3 | about: Did you find errors, problems, or anything unintelligible in the docs (https://python-poetry.org/docs)? 4 | title: '' 5 | labels: Documentation, Triage 6 | assignees: '' 7 | 8 | --- 9 | 10 | 17 | 18 | 19 | - [ ] I have searched the [issues](https://github.com/python-poetry/poetry/issues) of this repo and believe that this is not a duplicate. 20 | 21 | ## Issue 22 | 23 | -------------------------------------------------------------------------------- /tests/repositories/fixtures/installed/lib/python3.7/site-packages/editable-2.3.4.dist-info/METADATA: -------------------------------------------------------------------------------- 1 | Metadata-Version: 2.1 2 | Name: editable 3 | Version: 2.3.4 4 | Summary: Editable description. 5 | License: MIT 6 | Keywords: cli,commands 7 | Author: Foo Bar 8 | Author-email: foo@bar.com 9 | Requires-Python: >=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.* 10 | Classifier: License :: OSI Approved :: MIT License 11 | Classifier: Programming Language :: Python :: 2 12 | Classifier: Programming Language :: Python :: 2.7 13 | Classifier: Programming Language :: Python :: 3 14 | Classifier: Programming Language :: Python :: 3.4 15 | Classifier: Programming Language :: Python :: 3.5 16 | Classifier: Programming Language :: Python :: 3.6 17 | Classifier: Programming Language :: Python :: 3.7 18 | Classifier: Programming Language :: Python :: 3.8 19 | Description-Content-Type: text/x-rst 20 | 21 | Editable 22 | #### 23 | -------------------------------------------------------------------------------- /tests/repositories/fixtures/installed/lib/python3.7/site-packages/standard-1.2.3.dist-info/METADATA: -------------------------------------------------------------------------------- 1 | Metadata-Version: 2.1 2 | Name: standard 3 | Version: 1.2.3 4 | Summary: Standard description. 5 | License: MIT 6 | Keywords: cli,commands 7 | Author: Foo Bar 8 | Author-email: foo@bar.com 9 | Requires-Python: >=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.* 10 | Classifier: License :: OSI Approved :: MIT License 11 | Classifier: Programming Language :: Python :: 2 12 | Classifier: Programming Language :: Python :: 2.7 13 | Classifier: Programming Language :: Python :: 3 14 | Classifier: Programming Language :: Python :: 3.4 15 | Classifier: Programming Language :: Python :: 3.5 16 | Classifier: Programming Language :: Python :: 3.6 17 | Classifier: Programming Language :: Python :: 3.7 18 | Classifier: Programming Language :: Python :: 3.8 19 | Description-Content-Type: text/x-rst 20 | 21 | Editable 22 | #### 23 | -------------------------------------------------------------------------------- /poetry/console/commands/env/list.py: -------------------------------------------------------------------------------- 1 | from cleo.helpers import option 2 | 3 | from ..command import Command 4 | 5 | 6 | class EnvListCommand(Command): 7 | 8 | name = "env list" 9 | description = "Lists all virtualenvs associated with the current project." 10 | 11 | options = [option("full-path", None, "Output the full paths of the virtualenvs.")] 12 | 13 | def handle(self) -> None: 14 | from poetry.utils.env import EnvManager 15 | 16 | manager = EnvManager(self.poetry) 17 | current_env = manager.get() 18 | 19 | for venv in manager.list(): 20 | name = venv.path.name 21 | if self.option("full-path"): 22 | name = str(venv.path) 23 | 24 | if venv == current_env: 25 | self.line("{} (Activated)".format(name)) 26 | 27 | continue 28 | 29 | self.line(name) 30 | -------------------------------------------------------------------------------- /tests/installation/fixtures/extras-with-dependencies.test: -------------------------------------------------------------------------------- 1 | [[package]] 2 | name = "A" 3 | version = "1.0" 4 | description = "" 5 | category = "main" 6 | optional = false 7 | python-versions = "*" 8 | 9 | [[package]] 10 | name = "B" 11 | version = "1.0" 12 | description = "" 13 | category = "main" 14 | optional = false 15 | python-versions = "*" 16 | 17 | [[package]] 18 | name = "C" 19 | version = "1.0" 20 | description = "" 21 | category = "main" 22 | optional = true 23 | python-versions = "*" 24 | 25 | [package.dependencies] 26 | D = "^1.0" 27 | 28 | [[package]] 29 | name = "D" 30 | version = "1.1" 31 | description = "" 32 | category = "main" 33 | optional = true 34 | python-versions = "*" 35 | 36 | [extras] 37 | foo = ["C"] 38 | 39 | [metadata] 40 | python-versions = "*" 41 | lock-version = "1.1" 42 | content-hash = "123456789" 43 | 44 | [metadata.files] 45 | A = [] 46 | B = [] 47 | C = [] 48 | D = [] 49 | -------------------------------------------------------------------------------- /.github/workflows/skip.yml: -------------------------------------------------------------------------------- 1 | # workaround for https://github.com/actions/virtual-environments/issues/1281 2 | name: Skip All Jobs 3 | 4 | on: 5 | push: 6 | paths: 7 | - '!**' 8 | - 'docs/**' 9 | - '.cirrus.yml' 10 | branches: 11 | - master 12 | - develop 13 | pull_request: 14 | paths: 15 | - '!**' 16 | - 'docs/**' 17 | - '.cirrus.yml' 18 | branches: 19 | - '**' 20 | 21 | jobs: 22 | pre-commit: 23 | name: Linting 24 | runs-on: ubuntu-latest 25 | steps: 26 | - run: exit 0 27 | 28 | tests: 29 | name: ${{ matrix.os }} / ${{ matrix.python-version }} 30 | # we do not need os specific runners here, using linux is quicker 31 | runs-on: ubuntu-latest 32 | strategy: 33 | matrix: 34 | os: [Ubuntu, MacOS, Windows] 35 | python-version: [3.6, 3.7, 3.8, 3.9] 36 | steps: 37 | - run: exit 0 38 | -------------------------------------------------------------------------------- /poetry/packages/project_package.py: -------------------------------------------------------------------------------- 1 | from typing import TYPE_CHECKING 2 | from typing import Optional 3 | from typing import Union 4 | 5 | from poetry.core.packages.project_package import ProjectPackage as _ProjectPackage 6 | 7 | 8 | if TYPE_CHECKING: 9 | from poetry.core.semver.version import Version # noqa 10 | 11 | 12 | class ProjectPackage(_ProjectPackage): 13 | def set_version( 14 | self, version: Union[str, "Version"], pretty_version: Optional[str] = None 15 | ) -> "ProjectPackage": 16 | from poetry.core.semver.version import Version # noqa 17 | 18 | if not isinstance(version, Version): 19 | self._version = Version.parse(version) 20 | self._pretty_version = pretty_version or version 21 | else: 22 | self._version = version 23 | self._pretty_version = pretty_version or version.text 24 | 25 | return self 26 | -------------------------------------------------------------------------------- /tests/installation/fixtures/with-platform-dependencies.test: -------------------------------------------------------------------------------- 1 | [[package]] 2 | name = "A" 3 | version = "1.0" 4 | description = "" 5 | category = "main" 6 | optional = true 7 | python-versions = "*" 8 | 9 | [[package]] 10 | name = "B" 11 | version = "1.1" 12 | description = "" 13 | category = "main" 14 | optional = false 15 | python-versions = "*" 16 | 17 | [[package]] 18 | name = "C" 19 | version = "1.3" 20 | description = "" 21 | category = "main" 22 | optional = false 23 | python-versions = "*" 24 | 25 | [package.dependencies] 26 | D = "^1.2" 27 | 28 | [[package]] 29 | name = "D" 30 | version = "1.4" 31 | description = "" 32 | category = "main" 33 | optional = false 34 | python-versions = "*" 35 | 36 | [extras] 37 | foo = ["A"] 38 | 39 | [metadata] 40 | python-versions = "*" 41 | lock-version = "1.1" 42 | content-hash = "123456789" 43 | 44 | [metadata.files] 45 | A = [] 46 | B = [] 47 | C = [] 48 | D = [] 49 | -------------------------------------------------------------------------------- /poetry/console/commands/installer_command.py: -------------------------------------------------------------------------------- 1 | from typing import TYPE_CHECKING 2 | 3 | from .env_command import EnvCommand 4 | 5 | 6 | if TYPE_CHECKING: 7 | from poetry.installation.installer import Installer 8 | from poetry.installation.installer import Optional 9 | 10 | 11 | class InstallerCommand(EnvCommand): 12 | def __init__(self) -> None: 13 | self._installer: Optional["Installer"] = None 14 | 15 | super(InstallerCommand, self).__init__() 16 | 17 | def reset_poetry(self) -> None: 18 | super(InstallerCommand, self).reset_poetry() 19 | 20 | self._installer.set_package(self.poetry.package) 21 | self._installer.set_locker(self.poetry.locker) 22 | 23 | @property 24 | def installer(self) -> "Installer": 25 | return self._installer 26 | 27 | def set_installer(self, installer: "Installer") -> None: 28 | self._installer = installer 29 | -------------------------------------------------------------------------------- /tests/installation/fixtures/with-sub-dependencies.test: -------------------------------------------------------------------------------- 1 | [[package]] 2 | name = "A" 3 | version = "1.0" 4 | description = "" 5 | category = "main" 6 | optional = false 7 | python-versions = "*" 8 | 9 | [package.dependencies] 10 | D = "^1.0" 11 | 12 | [[package]] 13 | name = "B" 14 | version = "1.1" 15 | description = "" 16 | category = "main" 17 | optional = false 18 | python-versions = "*" 19 | 20 | [package.dependencies] 21 | C = "~1.2" 22 | 23 | [[package]] 24 | name = "C" 25 | version = "1.2" 26 | description = "" 27 | category = "main" 28 | optional = false 29 | python-versions = "*" 30 | 31 | [[package]] 32 | name = "D" 33 | version = "1.3" 34 | description = "" 35 | category = "main" 36 | optional = false 37 | python-versions = "*" 38 | 39 | [metadata] 40 | python-versions = "*" 41 | lock-version = "1.1" 42 | content-hash = "123456789" 43 | 44 | [metadata.files] 45 | A = [] 46 | B = [] 47 | C = [] 48 | D = [] 49 | -------------------------------------------------------------------------------- /tests/repositories/fixtures/installed/lib/python3.7/site-packages/editable-with-import-2.3.4.dist-info/METADATA: -------------------------------------------------------------------------------- 1 | Metadata-Version: 2.1 2 | Name: editable-with-import 3 | Version: 2.3.4 4 | Summary: Editable description. 5 | License: MIT 6 | Keywords: cli,commands 7 | Author: Foo Bar 8 | Author-email: foo@bar.com 9 | Requires-Python: >=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.* 10 | Classifier: License :: OSI Approved :: MIT License 11 | Classifier: Programming Language :: Python :: 2 12 | Classifier: Programming Language :: Python :: 2.7 13 | Classifier: Programming Language :: Python :: 3 14 | Classifier: Programming Language :: Python :: 3.4 15 | Classifier: Programming Language :: Python :: 3.5 16 | Classifier: Programming Language :: Python :: 3.6 17 | Classifier: Programming Language :: Python :: 3.7 18 | Classifier: Programming Language :: Python :: 3.8 19 | Description-Content-Type: text/x-rst 20 | 21 | Editable 22 | #### 23 | -------------------------------------------------------------------------------- /.cirrus.yml: -------------------------------------------------------------------------------- 1 | freebsd_instance: 2 | image_family: freebsd-12-2 3 | 4 | test_task: 5 | name: "Tests / FreeBSD / " 6 | only_if: $CIRRUS_TAG == '' 7 | skip: "!changesInclude('.cirrus.yml', 'poetry.lock', 'pyproject.toml', '**.json','**.py')" 8 | env: 9 | matrix: 10 | - PYTHON: python3.6 11 | - PYTHON: python3.8 12 | python_script: 13 | - PYPACKAGE=$(printf '%s' $PYTHON | tr -d '.') 14 | - SQLPACKAGE=$(printf '%s-sqlite3' $PYPACKAGE | sed 's/thon//') 15 | - pkg install -y git-lite $PYPACKAGE $SQLPACKAGE 16 | pip_script: 17 | - $PYTHON -m ensurepip 18 | - $PYTHON -m pip install -U pip tox 19 | - $PYTHON -m pip install -U --pre poetry 20 | - poetry config virtualenvs.in-project true 21 | tox_script: $PYTHON -m tox -e py -- -q --junitxml=junit.xml tests 22 | on_failure: 23 | annotate_failure_artifacts: 24 | path: junit.xml 25 | format: junit 26 | type: text/xml 27 | -------------------------------------------------------------------------------- /poetry/console/logging/io_formatter.py: -------------------------------------------------------------------------------- 1 | import logging 2 | 3 | from typing import TYPE_CHECKING 4 | 5 | from .formatters import FORMATTERS 6 | 7 | 8 | if TYPE_CHECKING: 9 | from logging import LogRecord 10 | 11 | 12 | class IOFormatter(logging.Formatter): 13 | 14 | _colors = { 15 | "error": "fg=red", 16 | "warning": "fg=yellow", 17 | "debug": "debug", 18 | "info": "fg=blue", 19 | } 20 | 21 | def format(self, record: "LogRecord") -> str: 22 | if not record.exc_info: 23 | level = record.levelname.lower() 24 | msg = record.msg 25 | 26 | if record.name in FORMATTERS: 27 | msg = FORMATTERS[record.name].format(msg) 28 | elif level in self._colors: 29 | msg = "<{}>{}".format(self._colors[level], msg) 30 | 31 | return msg 32 | 33 | return super(IOFormatter, self).format(record) 34 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/---feature-request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: "\U0001F381 Feature Request" 3 | about: Do you have ideas for new features and improvements? 4 | title: '' 5 | labels: Feature, Triage 6 | assignees: '' 7 | 8 | --- 9 | 10 | 17 | 18 | 19 | - [ ] I have searched the [issues](https://github.com/python-poetry/poetry/issues) of this repo and believe that this is not a duplicate. 20 | - [ ] I have searched the [documentation](https://python-poetry.org/docs/) and believe that my question is not covered. 21 | 22 | ## Feature Request 23 | 24 | -------------------------------------------------------------------------------- /tests/mixology/version_solver/test_python_constraint.py: -------------------------------------------------------------------------------- 1 | from poetry.factory import Factory 2 | 3 | from ..helpers import add_to_repo 4 | from ..helpers import check_solver_result 5 | 6 | 7 | def test_dependency_does_not_match_root_python_constraint(root, provider, repo): 8 | provider.set_package_python_versions("^3.6") 9 | root.add_dependency(Factory.create_dependency("foo", "*")) 10 | 11 | add_to_repo(repo, "foo", "1.0.0", python="<3.5") 12 | 13 | error = """The current project's Python requirement (>=3.6,<4.0) \ 14 | is not compatible with some of the required packages Python requirement: 15 | - foo requires Python <3.5, so it will not be satisfied for Python >=3.6,<4.0 16 | 17 | Because no versions of foo match !=1.0.0 18 | and foo (1.0.0) requires Python <3.5, foo is forbidden. 19 | So, because myapp depends on foo (*), version solving failed.""" 20 | 21 | check_solver_result(root, provider, error=error) 22 | -------------------------------------------------------------------------------- /tests/installation/fixtures/with-file-dependency.test: -------------------------------------------------------------------------------- 1 | [[package]] 2 | name = "demo" 3 | version = "0.1.0" 4 | description = "" 5 | category = "main" 6 | optional = false 7 | python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" 8 | 9 | [package.source] 10 | type = "file" 11 | url = "tests/fixtures/distributions/demo-0.1.0-py2.py3-none-any.whl" 12 | 13 | [package.dependencies] 14 | pendulum = ">=1.4.4" 15 | 16 | [package.extras] 17 | bar = ["tomlkit"] 18 | foo = ["cleo"] 19 | 20 | [[package]] 21 | name = "pendulum" 22 | version = "1.4.4" 23 | description = "" 24 | category = "main" 25 | optional = false 26 | python-versions = "*" 27 | 28 | [metadata] 29 | python-versions = "*" 30 | lock-version = "1.1" 31 | content-hash = "123456789" 32 | 33 | [metadata.files] 34 | demo = [ 35 | {file = "demo-0.1.0-py2.py3-none-any.whl", hash = "sha256:70e704135718fffbcbf61ed1fc45933cfd86951a744b681000eaaa75da31f17a"}, 36 | ] 37 | pendulum = [] 38 | -------------------------------------------------------------------------------- /tests/installation/fixtures/with-dependencies-nested-extras.test: -------------------------------------------------------------------------------- 1 | [[package]] 2 | name = "A" 3 | version = "1.0" 4 | description = "" 5 | category = "main" 6 | optional = false 7 | python-versions = "*" 8 | 9 | [package.dependencies] 10 | B = {version = "^1.0", optional = true, extras = ["C"]} 11 | 12 | [package.extras] 13 | B = ["B[C] (>=1.0,<2.0)"] 14 | 15 | [[package]] 16 | name = "B" 17 | version = "1.0" 18 | description = "" 19 | category = "main" 20 | optional = false 21 | python-versions = "*" 22 | 23 | [package.dependencies] 24 | C = {version = "^1.0", optional = true} 25 | 26 | [package.extras] 27 | C = ["C (>=1.0,<2.0)"] 28 | 29 | [[package]] 30 | name = "C" 31 | version = "1.0" 32 | description = "" 33 | category = "main" 34 | optional = false 35 | python-versions = "*" 36 | 37 | [metadata] 38 | python-versions = "*" 39 | lock-version = "1.1" 40 | content-hash = "123456789" 41 | 42 | [metadata.files] 43 | "A" = [] 44 | "B" = [] 45 | "C" = [] 46 | -------------------------------------------------------------------------------- /tests/fixtures/simple_project/pyproject.toml: -------------------------------------------------------------------------------- 1 | [tool.poetry] 2 | name = "simple-project" 3 | version = "1.2.3" 4 | description = "Some description." 5 | authors = [ 6 | "Sébastien Eustace " 7 | ] 8 | license = "MIT" 9 | 10 | readme = "README.rst" 11 | 12 | homepage = "https://python-poetry.org" 13 | repository = "https://github.com/python-poetry/poetry" 14 | documentation = "https://python-poetry.org/docs" 15 | 16 | keywords = ["packaging", "dependency", "poetry"] 17 | 18 | classifiers = [ 19 | "Topic :: Software Development :: Build Tools", 20 | "Topic :: Software Development :: Libraries :: Python Modules" 21 | ] 22 | 23 | # Requirements 24 | [tool.poetry.dependencies] 25 | python = "~2.7 || ^3.4" 26 | 27 | [tool.poetry.scripts] 28 | foo = "foo:bar" 29 | baz = "bar:baz.boom.bim" 30 | fox = "fuz.foo:bar.baz" 31 | 32 | 33 | [build-system] 34 | requires = ["poetry-core>=1.0.2"] 35 | build-backend = "poetry.core.masonry.api" 36 | -------------------------------------------------------------------------------- /poetry/repositories/base_repository.py: -------------------------------------------------------------------------------- 1 | from typing import TYPE_CHECKING 2 | from typing import List 3 | from typing import Optional 4 | 5 | 6 | if TYPE_CHECKING: 7 | from poetry.core.packages.dependency import Dependency 8 | from poetry.core.packages.package import Package 9 | 10 | 11 | class BaseRepository: 12 | def __init__(self) -> None: 13 | self._packages = [] 14 | 15 | @property 16 | def packages(self) -> List["Package"]: 17 | return self._packages 18 | 19 | def has_package(self, package: "Package") -> None: 20 | raise NotImplementedError() 21 | 22 | def package( 23 | self, name: str, version: str, extras: Optional[List[str]] = None 24 | ) -> None: 25 | raise NotImplementedError() 26 | 27 | def find_packages(self, dependency: "Dependency") -> None: 28 | raise NotImplementedError() 29 | 30 | def search(self, query: str) -> None: 31 | raise NotImplementedError() 32 | -------------------------------------------------------------------------------- /tests/console/commands/source/test_remove.py: -------------------------------------------------------------------------------- 1 | import pytest 2 | 3 | 4 | @pytest.fixture 5 | def tester(command_tester_factory, poetry_with_source, add_multiple_sources): 6 | return command_tester_factory("source remove", poetry=poetry_with_source) 7 | 8 | 9 | def test_source_remove_simple( 10 | tester, poetry_with_source, source_existing, source_one, source_two 11 | ): 12 | tester.execute(f"{source_existing.name}") 13 | assert ( 14 | tester.io.fetch_output().strip() 15 | == f"Removing source with name {source_existing.name}." 16 | ) 17 | 18 | poetry_with_source.pyproject.reload() 19 | sources = poetry_with_source.get_sources() 20 | assert sources == [source_one, source_two] 21 | 22 | assert tester.status_code == 0 23 | 24 | 25 | def test_source_remove_error(tester): 26 | tester.execute("error") 27 | assert tester.io.fetch_error().strip() == "Source with name error was not found." 28 | assert tester.status_code == 1 29 | -------------------------------------------------------------------------------- /tests/installation/fixtures/with-directory-dependency-setuptools.test: -------------------------------------------------------------------------------- 1 | [[package]] 2 | name = "cachy" 3 | version = "0.2.0" 4 | description = "" 5 | category = "main" 6 | optional = false 7 | python-versions = "*" 8 | 9 | [[package]] 10 | name = "pendulum" 11 | version = "1.4.4" 12 | description = "" 13 | category = "main" 14 | optional = false 15 | python-versions = "*" 16 | 17 | [[package]] 18 | name = "project-with-setup" 19 | version = "0.1.2" 20 | develop = false 21 | description = "Demo project." 22 | category = "main" 23 | optional = false 24 | python-versions = "*" 25 | 26 | [package.source] 27 | type = "directory" 28 | url = "tests/fixtures/project_with_setup" 29 | 30 | [package.dependencies] 31 | cachy = {version = ">=0.2.0", extras = ["msgpack"]} 32 | pendulum = ">=1.4.4" 33 | 34 | [metadata] 35 | python-versions = "*" 36 | lock-version = "1.1" 37 | content-hash = "123456789" 38 | 39 | [metadata.files] 40 | cachy = [] 41 | project-with-setup = [] 42 | pendulum = [] 43 | -------------------------------------------------------------------------------- /tests/mixology/version_solver/conftest.py: -------------------------------------------------------------------------------- 1 | import pytest 2 | 3 | from cleo.io.null_io import NullIO 4 | 5 | from poetry.core.packages.project_package import ProjectPackage 6 | from poetry.puzzle.provider import Provider as BaseProvider 7 | from poetry.repositories import Pool 8 | from poetry.repositories import Repository 9 | 10 | 11 | class Provider(BaseProvider): 12 | def set_package_python_versions(self, python_versions): 13 | self._package.python_versions = python_versions 14 | self._python_constraint = self._package.python_constraint 15 | 16 | 17 | @pytest.fixture 18 | def repo(): 19 | return Repository() 20 | 21 | 22 | @pytest.fixture 23 | def pool(repo): 24 | pool = Pool() 25 | pool.add_repository(repo) 26 | 27 | return pool 28 | 29 | 30 | @pytest.fixture 31 | def root(): 32 | return ProjectPackage("myapp", "0.0.0") 33 | 34 | 35 | @pytest.fixture 36 | def provider(pool, root): 37 | return Provider(root, pool, NullIO()) 38 | -------------------------------------------------------------------------------- /tests/repositories/fixtures/legacy/isort.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Links for isort 5 | 6 | 7 |

Links for isort

8 | isort-4.3.4-py2-none-any.whl
9 | isort-4.3.4-py3-none-any.whl
10 | isort-4.3.4.tar.gz
11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /tests/repositories/fixtures/legacy/pyyaml.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Links for python-language-server 5 | 6 | 7 |

Links for python-language-server

8 | PyYAML-3.13-cp37-cp37m-win32.whl
9 | PyYAML-3.13.tar.gz
10 | PyYAML-4.2b2.tar.gz
11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /.github/stale.yml: -------------------------------------------------------------------------------- 1 | exemptProjects: true 2 | exemptMilestones: true 3 | 4 | staleLabel: stale 5 | 6 | markComment: > 7 | This issue has been automatically marked as stale because it has not had 8 | recent activity. It will be closed if no further activity occurs. Thank you 9 | for your contributions. 10 | 11 | closeComment: > 12 | Closing this issue automatically because it has not had any activity since 13 | it has been marked as stale. If you think it is still relevant and should 14 | be addressed, feel free to open a new one. 15 | 16 | pulls: 17 | markComment: > 18 | This pull request has been automatically marked as stale because it has not had 19 | recent activity. It will be closed if no further activity occurs. Thank you 20 | for your contributions. 21 | 22 | closeComment: > 23 | Closing this pull request automatically because it has not had any activity since 24 | it has been marked as stale. If you think it is still relevant and should 25 | be addressed, feel free to open a new one. 26 | -------------------------------------------------------------------------------- /tests/config/test_config.py: -------------------------------------------------------------------------------- 1 | import os 2 | 3 | import pytest 4 | 5 | 6 | @pytest.mark.parametrize( 7 | ("name", "value"), [("installer.parallel", True), ("virtualenvs.create", True)] 8 | ) 9 | def test_config_get_default_value(config, name, value): 10 | assert config.get(name) is value 11 | 12 | 13 | def test_config_get_processes_depended_on_values(config, config_cache_dir): 14 | assert str(config_cache_dir / "virtualenvs") == config.get("virtualenvs.path") 15 | 16 | 17 | @pytest.mark.parametrize( 18 | ("name", "env_value", "value"), 19 | [ 20 | ("installer.parallel", "true", True), 21 | ("installer.parallel", "false", False), 22 | ("virtualenvs.create", "true", True), 23 | ("virtualenvs.create", "false", False), 24 | ], 25 | ) 26 | def test_config_get_from_environment_variable(config, environ, name, env_value, value): 27 | env_var = "POETRY_{}".format("_".join(k.upper() for k in name.split("."))) 28 | os.environ[env_var] = env_value 29 | assert config.get(name) is value 30 | -------------------------------------------------------------------------------- /tests/installation/fixtures/update-with-locked-extras.test: -------------------------------------------------------------------------------- 1 | [[package]] 2 | name = "A" 3 | version = "1.0" 4 | description = "" 5 | category = "main" 6 | optional = false 7 | python-versions = "*" 8 | 9 | [package.dependencies] 10 | "B" = {version = "^1.0", optional = true} 11 | "C" = {version = "^1.0", markers = "python_version >= \"2.7\" and python_version < \"2.8\""} 12 | 13 | [package.extras] 14 | foo = ["b"] 15 | 16 | [[package]] 17 | name = "B" 18 | version = "1.0" 19 | description = "" 20 | category = "main" 21 | optional = false 22 | python-versions = "*" 23 | 24 | [[package]] 25 | name = "C" 26 | version = "1.1" 27 | description = "" 28 | category = "main" 29 | optional = false 30 | python-versions = "*" 31 | 32 | [[package]] 33 | name = "D" 34 | version = "1.1" 35 | description = "" 36 | category = "main" 37 | optional = false 38 | python-versions = "*" 39 | 40 | [metadata] 41 | python-versions = "*" 42 | lock-version = "1.1" 43 | content-hash = "123456789" 44 | 45 | [metadata.files] 46 | "A" = [] 47 | "B" = [] 48 | "C" = [] 49 | "D" = [] 50 | -------------------------------------------------------------------------------- /poetry/console/commands/check.py: -------------------------------------------------------------------------------- 1 | from pathlib import Path 2 | 3 | from poetry.core.pyproject.toml import PyProjectTOML 4 | from poetry.factory import Factory 5 | 6 | from .command import Command 7 | 8 | 9 | class CheckCommand(Command): 10 | 11 | name = "check" 12 | description = "Checks the validity of the pyproject.toml file." 13 | 14 | def handle(self) -> int: 15 | # Load poetry config and display errors, if any 16 | poetry_file = Factory.locate(Path.cwd()) 17 | config = PyProjectTOML(poetry_file).poetry_config 18 | check_result = Factory.validate(config, strict=True) 19 | if not check_result["errors"] and not check_result["warnings"]: 20 | self.info("All set!") 21 | 22 | return 0 23 | 24 | for error in check_result["errors"]: 25 | self.line("Error: {}".format(error)) 26 | 27 | for error in check_result["warnings"]: 28 | self.line("Warning: {}".format(error)) 29 | 30 | return 1 31 | -------------------------------------------------------------------------------- /poetry/installation/operations/install.py: -------------------------------------------------------------------------------- 1 | from typing import TYPE_CHECKING 2 | from typing import Optional 3 | 4 | from .operation import Operation 5 | 6 | 7 | if TYPE_CHECKING: 8 | from poetry.core.packages.package import Package 9 | 10 | 11 | class Install(Operation): 12 | def __init__( 13 | self, package: "Package", reason: Optional[str] = None, priority: int = 0 14 | ) -> None: 15 | super(Install, self).__init__(reason, priority=priority) 16 | 17 | self._package = package 18 | 19 | @property 20 | def package(self) -> "Package": 21 | return self._package 22 | 23 | @property 24 | def job_type(self) -> str: 25 | return "install" 26 | 27 | def __str__(self) -> str: 28 | return "Installing {} ({})".format( 29 | self.package.pretty_name, self.format_version(self.package) 30 | ) 31 | 32 | def __repr__(self) -> str: 33 | return "".format( 34 | self.package.pretty_name, self.format_version(self.package) 35 | ) 36 | -------------------------------------------------------------------------------- /poetry/installation/noop_installer.py: -------------------------------------------------------------------------------- 1 | from typing import TYPE_CHECKING 2 | from typing import List 3 | 4 | from .base_installer import BaseInstaller 5 | 6 | 7 | if TYPE_CHECKING: 8 | from poetry.core.packages.package import Package 9 | 10 | 11 | class NoopInstaller(BaseInstaller): 12 | def __init__(self) -> None: 13 | self._installs = [] 14 | self._updates = [] 15 | self._removals = [] 16 | 17 | @property 18 | def installs(self) -> List["Package"]: 19 | return self._installs 20 | 21 | @property 22 | def updates(self) -> List["Package"]: 23 | return self._updates 24 | 25 | @property 26 | def removals(self) -> List["Package"]: 27 | return self._removals 28 | 29 | def install(self, package: "Package") -> None: 30 | self._installs.append(package) 31 | 32 | def update(self, source: "Package", target: "Package") -> None: 33 | self._updates.append((source, target)) 34 | 35 | def remove(self, package: "Package") -> None: 36 | self._removals.append(package) 37 | -------------------------------------------------------------------------------- /tests/console/commands/test_install.py: -------------------------------------------------------------------------------- 1 | import pytest 2 | 3 | 4 | @pytest.fixture 5 | def tester(command_tester_factory): 6 | return command_tester_factory("install") 7 | 8 | 9 | def test_group_options_are_passed_to_the_installer(tester, mocker): 10 | """ 11 | Group options are passed properly to the installer. 12 | """ 13 | mocker.patch.object(tester.command.installer, "run", return_value=1) 14 | 15 | tester.execute("--with foo,bar --without baz --without bim --only bam") 16 | 17 | assert tester.command.installer._with_groups == ["foo", "bar"] 18 | assert tester.command.installer._without_groups == ["baz", "bim"] 19 | assert tester.command.installer._only_groups == ["bam"] 20 | 21 | 22 | def test_sync_option_is_passed_to_the_installer(tester, mocker): 23 | """ 24 | The --sync option is passed properly to the installer. 25 | """ 26 | mocker.patch.object(tester.command.installer, "run", return_value=1) 27 | 28 | tester.execute("--sync") 29 | 30 | assert tester.command.installer._requires_synchronization 31 | -------------------------------------------------------------------------------- /tests/console/commands/test_check.py: -------------------------------------------------------------------------------- 1 | from pathlib import Path 2 | 3 | import pytest 4 | 5 | 6 | @pytest.fixture() 7 | def tester(command_tester_factory): 8 | return command_tester_factory("check") 9 | 10 | 11 | def test_check_valid(tester): 12 | tester.execute() 13 | 14 | expected = """\ 15 | All set! 16 | """ 17 | 18 | assert expected == tester.io.fetch_output() 19 | 20 | 21 | def test_check_invalid(mocker, tester): 22 | mocker.patch( 23 | "poetry.factory.Factory.locate", 24 | return_value=Path(__file__).parent.parent.parent 25 | / "fixtures" 26 | / "invalid_pyproject" 27 | / "pyproject.toml", 28 | ) 29 | 30 | tester.execute() 31 | 32 | expected = """\ 33 | Error: 'description' is a required property 34 | Warning: A wildcard Python dependency is ambiguous. Consider specifying a more explicit one. 35 | Warning: The "pendulum" dependency specifies the "allows-prereleases" property, which is deprecated. Use "allow-prereleases" instead. 36 | """ 37 | 38 | assert expected == tester.io.fetch_output() 39 | -------------------------------------------------------------------------------- /tests/puzzle/conftest.py: -------------------------------------------------------------------------------- 1 | import shutil 2 | 3 | from pathlib import Path 4 | 5 | import pytest 6 | 7 | 8 | try: 9 | import urllib.parse as urlparse 10 | except ImportError: 11 | import urlparse 12 | 13 | 14 | def mock_clone(self, source, dest): 15 | # Checking source to determine which folder we need to copy 16 | parts = urlparse.urlparse(source) 17 | 18 | folder = ( 19 | Path(__file__).parent.parent 20 | / "fixtures" 21 | / "git" 22 | / parts.netloc 23 | / parts.path.lstrip("/").rstrip(".git") 24 | ) 25 | 26 | shutil.rmtree(str(dest)) 27 | shutil.copytree(str(folder), str(dest)) 28 | 29 | 30 | @pytest.fixture(autouse=True) 31 | def setup(mocker): 32 | # Patch git module to not actually clone projects 33 | mocker.patch("poetry.core.vcs.git.Git.clone", new=mock_clone) 34 | mocker.patch("poetry.core.vcs.git.Git.checkout", new=lambda *_: None) 35 | p = mocker.patch("poetry.core.vcs.git.Git.rev_parse") 36 | p.return_value = "9cf87a285a2d3fbb0b9fa621997b3acc3631ed24" 37 | 38 | yield 39 | -------------------------------------------------------------------------------- /tests/installation/fixtures/with-multiple-updates.test: -------------------------------------------------------------------------------- 1 | [[package]] 2 | name = "A" 3 | version = "1.1" 4 | description = "" 5 | category = "main" 6 | optional = false 7 | python-versions = "*" 8 | 9 | [package.dependencies] 10 | B = ">=1.0.1" 11 | C = [ 12 | {version = "^1.0", markers = "python_version >= \"2.7\" and python_version < \"2.8\""}, 13 | {version = "^2.0", markers = "python_version >= \"3.4\" and python_version < \"4.0\""}, 14 | ] 15 | 16 | [[package]] 17 | name = "B" 18 | version = "1.1.0" 19 | description = "" 20 | category = "main" 21 | optional = false 22 | python-versions = "*" 23 | 24 | [[package]] 25 | name = "C" 26 | version = "1.0" 27 | description = "" 28 | category = "main" 29 | optional = false 30 | python-versions = "*" 31 | 32 | [[package]] 33 | name = "C" 34 | version = "2.0" 35 | description = "" 36 | category = "main" 37 | optional = false 38 | python-versions = "*" 39 | 40 | [metadata] 41 | python-versions = "~2.7 || ^3.4" 42 | lock-version = "1.1" 43 | content-hash = "123456789" 44 | 45 | [metadata.files] 46 | A = [] 47 | B = [] 48 | C = [] 49 | -------------------------------------------------------------------------------- /poetry/packages/package_collection.py: -------------------------------------------------------------------------------- 1 | from typing import TYPE_CHECKING 2 | from typing import List 3 | from typing import Union 4 | 5 | from .dependency_package import DependencyPackage 6 | 7 | 8 | if TYPE_CHECKING: 9 | from poetry.core.packages.dependency import Dependency 10 | from poetry.core.packages.package import Package 11 | 12 | 13 | class PackageCollection(list): 14 | def __init__( 15 | self, 16 | dependency: "Dependency", 17 | packages: List[Union["Package", DependencyPackage]] = None, 18 | ) -> None: 19 | self._dependency = dependency 20 | 21 | if packages is None: 22 | packages = [] 23 | 24 | super().__init__() 25 | 26 | for package in packages: 27 | self.append(package) 28 | 29 | def append(self, package: Union["Package", DependencyPackage]) -> None: 30 | if isinstance(package, DependencyPackage): 31 | package = package.package 32 | 33 | package = DependencyPackage(self._dependency, package) 34 | 35 | return super().append(package) 36 | -------------------------------------------------------------------------------- /tests/fixtures/project_with_git_dev_dependency/pyproject.toml: -------------------------------------------------------------------------------- 1 | [tool.poetry] 2 | name = "my-package" 3 | version = "1.2.3" 4 | description = "Some description." 5 | authors = [ 6 | "Sébastien Eustace " 7 | ] 8 | license = "MIT" 9 | 10 | homepage = "https://python-poetry.org" 11 | repository = "https://github.com/python-poetry/poetry" 12 | documentation = "https://python-poetry.org/docs" 13 | 14 | keywords = ["packaging", "dependency", "poetry"] 15 | 16 | classifiers = [ 17 | "Topic :: Software Development :: Build Tools", 18 | "Topic :: Software Development :: Libraries :: Python Modules" 19 | ] 20 | 21 | # Requirements 22 | [tool.poetry.dependencies] 23 | python = "~2.7 || ^3.4" 24 | cachy = "^0.1.0" 25 | pendulum = "^2.0.0" 26 | 27 | [tool.poetry.dev-dependencies] 28 | pytest = "~3.4" 29 | demo = { git = "https://github.com/demo/demo.git", rev = "9cf87a285a2d3fbb0b9fa621997b3acc3631ed24" } 30 | 31 | 32 | [tool.poetry.scripts] 33 | my-script = "my_package:main" 34 | 35 | 36 | [tool.poetry.plugins."blogtool.parsers"] 37 | ".rst" = "some_module::SomeClass" 38 | -------------------------------------------------------------------------------- /poetry/json/__init__.py: -------------------------------------------------------------------------------- 1 | import json 2 | import os 3 | 4 | from typing import List 5 | 6 | import jsonschema 7 | 8 | 9 | SCHEMA_DIR = os.path.join(os.path.dirname(__file__), "schemas") 10 | 11 | 12 | class ValidationError(ValueError): 13 | 14 | pass 15 | 16 | 17 | def validate_object(obj: dict, schema_name: str) -> List[str]: 18 | schema = os.path.join(SCHEMA_DIR, f"{schema_name}.json") 19 | 20 | if not os.path.exists(schema): 21 | raise ValueError(f"Schema {schema_name} does not exist.") 22 | 23 | with open(schema, encoding="utf-8") as f: 24 | schema = json.loads(f.read()) 25 | 26 | validator = jsonschema.Draft7Validator(schema) 27 | validation_errors = sorted(validator.iter_errors(obj), key=lambda e: e.path) 28 | 29 | errors = [] 30 | 31 | for error in validation_errors: 32 | message = error.message 33 | if error.path: 34 | message = "[{}] {}".format( 35 | ".".join(str(x) for x in error.absolute_path), message 36 | ) 37 | 38 | errors.append(message) 39 | 40 | return errors 41 | -------------------------------------------------------------------------------- /tests/fixtures/project_with_local_dependencies/pyproject.toml: -------------------------------------------------------------------------------- 1 | [tool.poetry] 2 | name = "my-package" 3 | version = "1.2.3" 4 | description = "Some description." 5 | authors = [ 6 | "Sébastien Eustace " 7 | ] 8 | license = "MIT" 9 | 10 | readme = "README.rst" 11 | 12 | homepage = "https://python-poetry.org" 13 | repository = "https://github.com/python-poetry/poetry" 14 | documentation = "https://python-poetry.org/docs" 15 | 16 | keywords = ["packaging", "dependency", "poetry"] 17 | 18 | classifiers = [ 19 | "Topic :: Software Development :: Build Tools", 20 | "Topic :: Software Development :: Libraries :: Python Modules" 21 | ] 22 | 23 | # Requirements 24 | [tool.poetry.dependencies] 25 | python = "~2.7 || ^3.4" 26 | # File dependency 27 | demo = { path = "../distributions/demo-0.1.0-py2.py3-none-any.whl" } 28 | 29 | # Dir dependency with setup.py 30 | project-with-setup = { path = "../project_with_setup/" } 31 | 32 | 33 | [tool.poetry.scripts] 34 | my-script = "my_package:main" 35 | 36 | 37 | [tool.poetry.plugins."blogtool.parsers"] 38 | ".rst" = "some_module::SomeClass" 39 | -------------------------------------------------------------------------------- /poetry/console/commands/build.py: -------------------------------------------------------------------------------- 1 | from cleo.helpers import option 2 | 3 | from .env_command import EnvCommand 4 | 5 | 6 | class BuildCommand(EnvCommand): 7 | 8 | name = "build" 9 | description = "Builds a package, as a tarball and a wheel by default." 10 | 11 | options = [ 12 | option("format", "f", "Limit the format to either sdist or wheel.", flag=False) 13 | ] 14 | 15 | loggers = [ 16 | "poetry.core.masonry.builders.builder", 17 | "poetry.core.masonry.builders.sdist", 18 | "poetry.core.masonry.builders.wheel", 19 | ] 20 | 21 | def handle(self) -> None: 22 | from poetry.core.masonry.builder import Builder 23 | 24 | fmt = "all" 25 | if self.option("format"): 26 | fmt = self.option("format") 27 | 28 | package = self.poetry.package 29 | self.line( 30 | "Building {} ({})".format( 31 | package.pretty_name, package.version 32 | ) 33 | ) 34 | 35 | builder = Builder(self.poetry) 36 | builder.build(fmt, executable=self.env.python) 37 | -------------------------------------------------------------------------------- /poetry/installation/operations/uninstall.py: -------------------------------------------------------------------------------- 1 | from typing import TYPE_CHECKING 2 | from typing import Optional 3 | 4 | from .operation import Operation 5 | 6 | 7 | if TYPE_CHECKING: 8 | from poetry.core.packages.package import Package 9 | 10 | 11 | class Uninstall(Operation): 12 | def __init__( 13 | self, 14 | package: "Package", 15 | reason: Optional[str] = None, 16 | priority: int = float("inf"), 17 | ) -> None: 18 | super(Uninstall, self).__init__(reason, priority=priority) 19 | 20 | self._package = package 21 | 22 | @property 23 | def package(self) -> "Package": 24 | return self._package 25 | 26 | @property 27 | def job_type(self) -> str: 28 | return "uninstall" 29 | 30 | def __str__(self) -> str: 31 | return "Uninstalling {} ({})".format( 32 | self.package.pretty_name, self.format_version(self._package) 33 | ) 34 | 35 | def __repr__(self) -> str: 36 | return "".format( 37 | self.package.pretty_name, self.format_version(self.package) 38 | ) 39 | -------------------------------------------------------------------------------- /poetry/mixology/solutions/providers/python_requirement_solution_provider.py: -------------------------------------------------------------------------------- 1 | import re 2 | 3 | from typing import List 4 | 5 | from crashtest.contracts.has_solutions_for_exception import HasSolutionsForException 6 | from crashtest.contracts.solution import Solution 7 | 8 | 9 | class PythonRequirementSolutionProvider(HasSolutionsForException): 10 | def can_solve(self, exception: Exception) -> bool: 11 | from poetry.puzzle.exceptions import SolverProblemError 12 | 13 | if not isinstance(exception, SolverProblemError): 14 | return False 15 | 16 | m = re.match( 17 | "^The current project's Python requirement (.+) is not compatible " 18 | "with some of the required packages Python requirement", 19 | str(exception), 20 | ) 21 | 22 | if not m: 23 | return False 24 | 25 | return True 26 | 27 | def get_solutions(self, exception: Exception) -> List[Solution]: 28 | from ..solutions.python_requirement_solution import PythonRequirementSolution 29 | 30 | return [PythonRequirementSolution(exception)] 31 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2018 Sébastien Eustace 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining 4 | a copy of this software and associated documentation files (the 5 | "Software"), to deal in the Software without restriction, including 6 | without limitation the rights to use, copy, modify, merge, publish, 7 | distribute, sublicense, and/or sell copies of the Software, and to 8 | permit persons to whom the Software is furnished to do so, subject to 9 | the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be 12 | included in all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 17 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 18 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 19 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /tests/fixtures/with-include/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2018 Sébastien Eustace 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining 4 | a copy of this software and associated documentation files (the 5 | "Software"), to deal in the Software without restriction, including 6 | without limitation the rights to use, copy, modify, merge, publish, 7 | distribute, sublicense, and/or sell copies of the Software, and to 8 | permit persons to whom the Software is furnished to do so, subject to 9 | the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be 12 | included in all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 17 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 18 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 19 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /poetry/config/dict_config_source.py: -------------------------------------------------------------------------------- 1 | from typing import Any 2 | from typing import Dict 3 | 4 | from .config_source import ConfigSource 5 | 6 | 7 | class DictConfigSource(ConfigSource): 8 | def __init__(self) -> None: 9 | self._config = {} 10 | 11 | @property 12 | def config(self) -> Dict[str, Any]: 13 | return self._config 14 | 15 | def add_property(self, key: str, value: Any) -> None: 16 | keys = key.split(".") 17 | config = self._config 18 | 19 | for i, key in enumerate(keys): 20 | if key not in config and i < len(keys) - 1: 21 | config[key] = {} 22 | 23 | if i == len(keys) - 1: 24 | config[key] = value 25 | break 26 | 27 | config = config[key] 28 | 29 | def remove_property(self, key: str) -> None: 30 | keys = key.split(".") 31 | 32 | config = self._config 33 | for i, key in enumerate(keys): 34 | if key not in config: 35 | return 36 | 37 | if i == len(keys) - 1: 38 | del config[key] 39 | 40 | break 41 | 42 | config = config[key] 43 | -------------------------------------------------------------------------------- /tests/console/commands/plugin/conftest.py: -------------------------------------------------------------------------------- 1 | import pytest 2 | 3 | from poetry.__version__ import __version__ 4 | from poetry.core.packages.package import Package 5 | from poetry.factory import Factory 6 | from poetry.repositories.installed_repository import InstalledRepository 7 | from poetry.repositories.pool import Pool 8 | from poetry.utils.env import EnvManager 9 | 10 | 11 | @pytest.fixture() 12 | def installed(): 13 | repository = InstalledRepository() 14 | 15 | repository.add_package(Package("poetry", __version__)) 16 | 17 | return repository 18 | 19 | 20 | def configure_sources_factory(repo): 21 | def _configure_sources(poetry, sources, config, io): # noqa 22 | pool = Pool() 23 | pool.add_repository(repo) 24 | poetry.set_pool(pool) 25 | 26 | return _configure_sources 27 | 28 | 29 | @pytest.fixture(autouse=True) 30 | def setup_mocks(mocker, env, repo, installed): 31 | mocker.patch.object(EnvManager, "get_system_env", return_value=env) 32 | mocker.patch.object(InstalledRepository, "load", return_value=installed) 33 | mocker.patch.object( 34 | Factory, "configure_sources", side_effect=configure_sources_factory(repo) 35 | ) 36 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/---everything-else.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: "\U0001F5C3 Everything Else" 3 | about: For questions and issues that do not fall in any of the other categories. This 4 | can include questions about Poetry's roadmap. For support questions, please post 5 | on StackOverflow. 6 | title: '' 7 | labels: '' 8 | assignees: '' 9 | 10 | --- 11 | 12 | 13 | 14 | 15 | 16 | - [ ] I have searched the [issues](https://github.com/python-poetry/poetry/issues) of this repo and believe that this is not a duplicate. 17 | - [ ] I have searched the [documentation](https://python-poetry.org/docs/) and believe that my question is not covered. 18 | 19 | ## Issue 20 | 21 | -------------------------------------------------------------------------------- /tests/installation/fixtures/with-duplicate-dependencies.test: -------------------------------------------------------------------------------- 1 | [[package]] 2 | name = "A" 3 | version = "1.0" 4 | description = "" 5 | category = "main" 6 | optional = false 7 | python-versions = "*" 8 | 9 | [package.dependencies] 10 | B = [ 11 | {version = "^1.0", markers = "python_version < \"4.0\""}, 12 | {version = "^2.0", markers = "python_version >= \"4.0\""}, 13 | ] 14 | 15 | [[package]] 16 | name = "B" 17 | version = "1.0" 18 | description = "" 19 | category = "main" 20 | optional = false 21 | python-versions = "*" 22 | 23 | [package.dependencies] 24 | C = "1.2" 25 | 26 | [[package]] 27 | name = "B" 28 | version = "2.0" 29 | description = "" 30 | category = "main" 31 | optional = false 32 | python-versions = "*" 33 | 34 | [package.dependencies] 35 | C = "1.5" 36 | 37 | [[package]] 38 | name = "C" 39 | version = "1.2" 40 | description = "" 41 | category = "main" 42 | optional = false 43 | python-versions = "*" 44 | 45 | [[package]] 46 | name = "C" 47 | version = "1.5" 48 | description = "" 49 | category = "main" 50 | optional = false 51 | python-versions = "*" 52 | 53 | [metadata] 54 | python-versions = "*" 55 | lock-version = "1.1" 56 | content-hash = "123456789" 57 | 58 | [metadata.files] 59 | A = [] 60 | B = [] 61 | C = [] 62 | -------------------------------------------------------------------------------- /tests/console/commands/env/test_list.py: -------------------------------------------------------------------------------- 1 | import pytest 2 | import tomlkit 3 | 4 | from poetry.core.toml.file import TOMLFile 5 | 6 | 7 | @pytest.fixture 8 | def venv_activate_37(venv_cache, venv_name): 9 | envs_file = TOMLFile(venv_cache / "envs.toml") 10 | doc = tomlkit.document() 11 | doc[venv_name] = {"minor": "3.7", "patch": "3.7.0"} 12 | envs_file.write(doc) 13 | 14 | 15 | @pytest.fixture 16 | def tester(command_tester_factory): 17 | return command_tester_factory("env list") 18 | 19 | 20 | def test_none_activated(tester, venvs_in_cache_dirs, mocker, env): 21 | mocker.patch("poetry.utils.env.EnvManager.get", return_value=env) 22 | tester.execute() 23 | expected = "\n".join(venvs_in_cache_dirs).strip() 24 | assert expected == tester.io.fetch_output().strip() 25 | 26 | 27 | def test_activated(tester, venvs_in_cache_dirs, venv_cache, venv_activate_37): 28 | tester.execute() 29 | expected = ( 30 | "\n".join(venvs_in_cache_dirs).strip().replace("py3.7", "py3.7 (Activated)") 31 | ) 32 | assert expected == tester.io.fetch_output().strip() 33 | 34 | 35 | def test_in_project_venv(tester, venvs_in_project_dir): 36 | tester.execute() 37 | expected = ".venv (Activated)\n" 38 | assert expected == tester.io.fetch_output() 39 | -------------------------------------------------------------------------------- /tests/console/commands/env/test_remove.py: -------------------------------------------------------------------------------- 1 | import pytest 2 | 3 | from poetry.core.semver.version import Version 4 | from tests.console.commands.env.helpers import check_output_wrapper 5 | 6 | 7 | @pytest.fixture 8 | def tester(command_tester_factory): 9 | return command_tester_factory("env remove") 10 | 11 | 12 | def test_remove_by_python_version( 13 | mocker, tester, venvs_in_cache_dirs, venv_name, venv_cache 14 | ): 15 | check_output = mocker.patch( 16 | "subprocess.check_output", 17 | side_effect=check_output_wrapper(Version.parse("3.6.6")), 18 | ) 19 | 20 | tester.execute("3.6") 21 | 22 | assert check_output.called 23 | assert not (venv_cache / "{}-py3.6".format(venv_name)).exists() 24 | 25 | expected = "Deleted virtualenv: {}\n".format( 26 | (venv_cache / "{}-py3.6".format(venv_name)) 27 | ) 28 | assert expected == tester.io.fetch_output() 29 | 30 | 31 | def test_remove_by_name(tester, venvs_in_cache_dirs, venv_name, venv_cache): 32 | expected = "" 33 | 34 | for name in venvs_in_cache_dirs: 35 | tester.execute(name) 36 | 37 | assert not (venv_cache / name).exists() 38 | 39 | expected += "Deleted virtualenv: {}\n".format((venv_cache / name)) 40 | 41 | assert expected == tester.io.fetch_output() 42 | -------------------------------------------------------------------------------- /tests/fixtures/complete.toml: -------------------------------------------------------------------------------- 1 | [tool.poetry] 2 | name = "poetry" 3 | version = "0.5.0" 4 | description = "Python dependency management and packaging made easy." 5 | authors = [ 6 | "Sébastien Eustace " 7 | ] 8 | license = "MIT" 9 | 10 | readme = "README.rst" 11 | 12 | homepage = "https://python-poetry.org/" 13 | repository = "https://github.com/python-poetry/poetry" 14 | documentation = "https://python-poetry.org/docs" 15 | 16 | keywords = ["packaging", "dependency", "poetry"] 17 | 18 | # Requirements 19 | [tool.poetry.dependencies] 20 | python = "~2.7 || ^3.2" # Compatible python versions must be declared here 21 | toml = "^0.9" 22 | # Dependencies with extras 23 | requests = { version = "^2.13", extras = [ "security" ] } 24 | # Python specific dependencies with prereleases allowed 25 | pathlib2 = { version = "^2.2", python = "~2.7", allow-prereleases = true } 26 | # Git dependencies 27 | cleo = { git = "https://github.com/sdispater/cleo.git", branch = "master" } 28 | 29 | # Optional dependencies (extras) 30 | pendulum = { version = "^1.4", optional = true } 31 | 32 | [tool.poetry.extras] 33 | time = [ "pendulum" ] 34 | 35 | [tool.poetry.dev-dependencies] 36 | pytest = "^3.0" 37 | pytest-cov = "^2.4" 38 | 39 | [tool.poetry.scripts] 40 | my-script = 'my_package:main' 41 | 42 | 43 | [[tool.poetry.source]] 44 | name = "foo" 45 | url = "https://bar.com" 46 | -------------------------------------------------------------------------------- /poetry/utils/_compat.py: -------------------------------------------------------------------------------- 1 | import sys 2 | 3 | 4 | try: 5 | from importlib import metadata 6 | except ImportError: 7 | # compatibility for python <3.8 8 | import importlib_metadata as metadata # noqa 9 | 10 | WINDOWS = sys.platform == "win32" 11 | 12 | 13 | def decode(string, encodings=None): 14 | if not isinstance(string, bytes): 15 | return string 16 | 17 | encodings = encodings or ["utf-8", "latin1", "ascii"] 18 | 19 | for encoding in encodings: 20 | try: 21 | return string.decode(encoding) 22 | except (UnicodeEncodeError, UnicodeDecodeError): 23 | pass 24 | 25 | return string.decode(encodings[0], errors="ignore") 26 | 27 | 28 | def encode(string, encodings=None): 29 | if isinstance(string, bytes): 30 | return string 31 | 32 | encodings = encodings or ["utf-8", "latin1", "ascii"] 33 | 34 | for encoding in encodings: 35 | try: 36 | return string.encode(encoding) 37 | except (UnicodeEncodeError, UnicodeDecodeError): 38 | pass 39 | 40 | return string.encode(encodings[0], errors="ignore") 41 | 42 | 43 | def to_str(string): 44 | return decode(string) 45 | 46 | 47 | def list_to_shell_command(cmd): 48 | return " ".join( 49 | f'"{token}"' if " " in token and token[0] not in {"'", '"'} else token 50 | for token in cmd 51 | ) 52 | -------------------------------------------------------------------------------- /poetry/console/commands/shell.py: -------------------------------------------------------------------------------- 1 | import sys 2 | 3 | from distutils.util import strtobool 4 | from os import environ 5 | 6 | from .env_command import EnvCommand 7 | 8 | 9 | class ShellCommand(EnvCommand): 10 | 11 | name = "shell" 12 | description = "Spawns a shell within the virtual environment." 13 | 14 | help = """The shell command spawns a shell, according to the 15 | $SHELL environment variable, within the virtual environment. 16 | If one doesn't exist yet, it will be created. 17 | """ 18 | 19 | def handle(self) -> None: 20 | from poetry.utils.shell import Shell 21 | 22 | # Check if it's already activated or doesn't exist and won't be created 23 | venv_activated = strtobool(environ.get("POETRY_ACTIVE", "0")) or getattr( 24 | sys, "real_prefix", sys.prefix 25 | ) == str(self.env.path) 26 | if venv_activated: 27 | self.line( 28 | "Virtual environment already activated: " 29 | "{}".format(self.env.path) 30 | ) 31 | 32 | return 33 | 34 | self.line("Spawning shell within {}".format(self.env.path)) 35 | 36 | # Setting this to avoid spawning unnecessary nested shells 37 | environ["POETRY_ACTIVE"] = "1" 38 | shell = Shell.get() 39 | shell.activate(self.env) 40 | environ.pop("POETRY_ACTIVE") 41 | -------------------------------------------------------------------------------- /tests/console/commands/test_cache.py: -------------------------------------------------------------------------------- 1 | import uuid 2 | 3 | import pytest 4 | 5 | 6 | @pytest.fixture 7 | def repository_cache_dir(monkeypatch, tmpdir): 8 | from pathlib import Path 9 | 10 | import poetry.locations 11 | 12 | path = Path(str(tmpdir)) 13 | monkeypatch.setattr(poetry.locations, "REPOSITORY_CACHE_DIR", path) 14 | return path 15 | 16 | 17 | @pytest.fixture 18 | def repository_one(): 19 | return "01_{}".format(uuid.uuid4()) 20 | 21 | 22 | @pytest.fixture 23 | def repository_two(): 24 | return "02_{}".format(uuid.uuid4()) 25 | 26 | 27 | @pytest.fixture 28 | def mock_caches(repository_cache_dir, repository_one, repository_two): 29 | (repository_cache_dir / repository_one).mkdir() 30 | (repository_cache_dir / repository_two).mkdir() 31 | 32 | 33 | @pytest.fixture 34 | def tester(command_tester_factory): 35 | return command_tester_factory("cache list") 36 | 37 | 38 | def test_cache_list(tester, mock_caches, repository_one, repository_two): 39 | tester.execute() 40 | 41 | expected = """\ 42 | {} 43 | {} 44 | """.format( 45 | repository_one, repository_two 46 | ) 47 | 48 | assert expected == tester.io.fetch_output() 49 | 50 | 51 | def test_cache_list_empty(tester, repository_cache_dir): 52 | tester.execute() 53 | 54 | expected = """\ 55 | No caches found 56 | """ 57 | 58 | assert expected == tester.io.fetch_output() 59 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/---bug-report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: "\U0001F41E Bug Report" 3 | about: Did you find a bug? 4 | title: '' 5 | labels: Bug, Triage 6 | assignees: '' 7 | 8 | --- 9 | 10 | 17 | 18 | 19 | - [ ] I am on the [latest](https://github.com/python-poetry/poetry/releases/latest) Poetry version. 20 | - [ ] I have searched the [issues](https://github.com/python-poetry/poetry/issues) of this repo and believe that this is not a duplicate. 21 | - [ ] If an exception occurs when executing a command, I executed it again in debug mode (`-vvv` option). 22 | 23 | 27 | 28 | - **OS version and name**: 29 | - **Poetry version**: 30 | - **Link of a [Gist](https://gist.github.com/) with the contents of your pyproject.toml file**: 31 | 32 | ## Issue 33 | 34 | -------------------------------------------------------------------------------- /.github/workflows/release.yml: -------------------------------------------------------------------------------- 1 | name: Release 2 | 3 | on: 4 | push: 5 | tags: 6 | - '*.*.*' 7 | 8 | jobs: 9 | Release: 10 | runs-on: ubuntu-latest 11 | 12 | steps: 13 | - name: Checkout code 14 | uses: actions/checkout@v2 15 | 16 | - name: Get tag 17 | id: tag 18 | run: echo ::set-output name=tag::${GITHUB_REF#refs/tags/} 19 | 20 | - name: Set up Python 3.9 21 | uses: actions/setup-python@v2 22 | with: 23 | python-version: "3.9" 24 | 25 | - name: Install Poetry 26 | run: python install-poetry.py -y 27 | 28 | - name: Update PATH 29 | run: echo "$HOME/.local/bin" >> $GITHUB_PATH 30 | 31 | - name: Build project for distribution 32 | run: poetry build 33 | 34 | - name: Check Version 35 | id: check-version 36 | run: | 37 | [[ "$(poetry version --short)" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]] \ 38 | || echo ::set-output name=prerelease::true 39 | 40 | - name: Create Release 41 | uses: ncipollo/release-action@v1 42 | with: 43 | artifacts: "dist/*" 44 | token: ${{ secrets.GITHUB_TOKEN }} 45 | draft: false 46 | prerelease: steps.check-version.outputs.prerelease == 'true' 47 | 48 | - name: Publish to PyPI 49 | env: 50 | POETRY_PYPI_TOKEN_PYPI: ${{ secrets.PYPI_TOKEN }} 51 | run: poetry publish 52 | -------------------------------------------------------------------------------- /tests/console/commands/env/conftest.py: -------------------------------------------------------------------------------- 1 | import os 2 | 3 | from pathlib import Path 4 | 5 | import pytest 6 | 7 | from poetry.utils.env import EnvManager 8 | 9 | 10 | @pytest.fixture 11 | def venv_name(app): 12 | return EnvManager.generate_env_name("simple-project", str(app.poetry.file.parent)) 13 | 14 | 15 | @pytest.fixture 16 | def venv_cache(tmp_dir): 17 | return Path(tmp_dir) 18 | 19 | 20 | @pytest.fixture(scope="module") 21 | def python_versions(): 22 | return ["3.6", "3.7"] 23 | 24 | 25 | @pytest.fixture 26 | def venvs_in_cache_config(app, venv_cache): 27 | app.poetry.config.merge({"virtualenvs": {"path": str(venv_cache)}}) 28 | 29 | 30 | @pytest.fixture 31 | def venvs_in_cache_dirs( 32 | app, venvs_in_cache_config, venv_name, venv_cache, python_versions 33 | ): 34 | directories = [] 35 | for version in python_versions: 36 | directory = venv_cache.joinpath("{}-py{}".format(venv_name, version)) 37 | directory.mkdir(parents=True, exist_ok=True) 38 | directories.append(directory.name) 39 | return directories 40 | 41 | 42 | @pytest.fixture 43 | def venvs_in_project_dir(app): 44 | os.environ.pop("VIRTUAL_ENV", None) 45 | venv_dir = app.poetry.file.parent.joinpath(".venv") 46 | venv_dir.mkdir(exist_ok=True) 47 | app.poetry.config.merge({"virtualenvs": {"in-project": True}}) 48 | 49 | try: 50 | yield venv_dir 51 | finally: 52 | venv_dir.rmdir() 53 | -------------------------------------------------------------------------------- /poetry/installation/operations/operation.py: -------------------------------------------------------------------------------- 1 | from typing import TYPE_CHECKING 2 | from typing import Optional 3 | 4 | 5 | if TYPE_CHECKING: 6 | from poetry.core.packages.package import Package 7 | 8 | 9 | class Operation(object): 10 | def __init__(self, reason: Optional[str] = None, priority: int = 0) -> None: 11 | self._reason = reason 12 | 13 | self._skipped = False 14 | self._skip_reason = None 15 | self._priority = priority 16 | 17 | @property 18 | def job_type(self) -> str: 19 | raise NotImplementedError 20 | 21 | @property 22 | def reason(self) -> str: 23 | return self._reason 24 | 25 | @property 26 | def skipped(self) -> bool: 27 | return self._skipped 28 | 29 | @property 30 | def skip_reason(self) -> Optional[str]: 31 | return self._skip_reason 32 | 33 | @property 34 | def priority(self) -> int: 35 | return self._priority 36 | 37 | @property 38 | def package(self) -> "Package": 39 | raise NotImplementedError() 40 | 41 | def format_version(self, package: "Package") -> str: 42 | return package.full_pretty_version 43 | 44 | def skip(self, reason: str) -> "Operation": 45 | self._skipped = True 46 | self._skip_reason = reason 47 | 48 | return self 49 | 50 | def unskip(self) -> "Operation": 51 | self._skipped = False 52 | self._skip_reason = None 53 | 54 | return self 55 | -------------------------------------------------------------------------------- /poetry/console/commands/lock.py: -------------------------------------------------------------------------------- 1 | from cleo.helpers import option 2 | 3 | from .installer_command import InstallerCommand 4 | 5 | 6 | class LockCommand(InstallerCommand): 7 | 8 | name = "lock" 9 | description = "Locks the project dependencies." 10 | 11 | options = [ 12 | option( 13 | "no-update", None, "Do not update locked versions, only refresh lock file." 14 | ), 15 | option( 16 | "check", 17 | None, 18 | "Check that the poetry.lock file corresponds to the current version " 19 | "of pyproject.toml.", 20 | ), 21 | ] 22 | 23 | help = """ 24 | The lock command reads the pyproject.toml file from the 25 | current directory, processes it, and locks the dependencies in the poetry.lock 26 | file. 27 | 28 | poetry lock 29 | """ 30 | 31 | loggers = ["poetry.repositories.pypi_repository"] 32 | 33 | def handle(self) -> int: 34 | self._installer.use_executor( 35 | self.poetry.config.get("experimental.new-installer", False) 36 | ) 37 | 38 | if self.option("check"): 39 | return ( 40 | 0 41 | if self.poetry.locker.is_locked() and self.poetry.locker.is_fresh() 42 | else 1 43 | ) 44 | 45 | self._installer.lock(update=not self.option("no-update")) 46 | 47 | return self._installer.run() 48 | -------------------------------------------------------------------------------- /tests/console/commands/env/test_info.py: -------------------------------------------------------------------------------- 1 | import sys 2 | 3 | from pathlib import Path 4 | 5 | import pytest 6 | 7 | from poetry.utils.env import MockEnv 8 | 9 | 10 | @pytest.fixture(autouse=True) 11 | def setup(mocker): 12 | mocker.patch( 13 | "poetry.utils.env.EnvManager.get", 14 | return_value=MockEnv( 15 | path=Path("/prefix"), base=Path("/base/prefix"), is_venv=True 16 | ), 17 | ) 18 | 19 | 20 | @pytest.fixture 21 | def tester(command_tester_factory): 22 | return command_tester_factory("env info") 23 | 24 | 25 | def test_env_info_displays_complete_info(tester): 26 | tester.execute() 27 | 28 | expected = """ 29 | Virtualenv 30 | Python: 3.7.0 31 | Implementation: CPython 32 | Path: {prefix} 33 | Executable: {executable} 34 | Valid: True 35 | 36 | System 37 | Platform: darwin 38 | OS: posix 39 | Python: {base_version} 40 | Path: {base_prefix} 41 | Executable: {base_executable} 42 | """.format( 43 | prefix=str(Path("/prefix")), 44 | base_prefix=str(Path("/base/prefix")), 45 | base_version=".".join(str(v) for v in sys.version_info[:3]), 46 | executable=sys.executable, 47 | base_executable="python", 48 | ) 49 | 50 | assert expected == tester.io.fetch_output() 51 | 52 | 53 | def test_env_info_displays_path_only(tester): 54 | tester.execute("--path") 55 | expected = str(Path("/prefix")) 56 | assert expected + "\n" == tester.io.fetch_output() 57 | -------------------------------------------------------------------------------- /tests/repositories/fixtures/legacy/ipython.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Links for ipython 5 | 6 | 7 |

Links for ipython

8 | ipython-5.7.0-py2-none-any.whl
9 | ipython-5.7.0-py3-none-any.whl
10 | ipython-5.7.0.tar.gz
11 | ipython-7.5.0-py3-none-any.whl
12 | ipython-7.5.0.tar.gz
13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /tests/repositories/fixtures/legacy/clikit.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Links for clikit 5 | 6 | 7 |

Links for clikit

8 | clikit-0.2.3-py2.py3-none-any.whl
9 | clikit-0.2.3.tar.gz
10 | clikit-0.2.4-py2.py3-none-any.whl
11 | clikit-0.2.4.tar.gz
12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /tests/fixtures/with-include/pyproject.toml: -------------------------------------------------------------------------------- 1 | [tool.poetry] 2 | name = "with-include" 3 | version = "1.2.3" 4 | description = "Some description." 5 | authors = [ 6 | "Sébastien Eustace " 7 | ] 8 | license = "MIT" 9 | 10 | readme = "README.rst" 11 | 12 | homepage = "https://python-poetry.org/" 13 | repository = "https://github.com/python-poetry/poetry" 14 | documentation = "https://python-poetry.org/docs" 15 | 16 | keywords = ["packaging", "dependency", "poetry"] 17 | 18 | classifiers = [ 19 | "Topic :: Software Development :: Build Tools", 20 | "Topic :: Software Development :: Libraries :: Python Modules" 21 | ] 22 | 23 | packages = [ 24 | { include = "extra_dir/**/*.py" }, 25 | { include = "extra_dir/**/*.py" }, 26 | { include = "my_module.py" }, 27 | { include = "package_with_include" }, 28 | { include = "tests", format = "sdist" }, 29 | { include = "for_wheel_only", format = ["wheel"] }, 30 | { include = "src_package", from = "src"}, 31 | ] 32 | 33 | include = [ 34 | "extra_dir/vcs_excluded.txt", 35 | "notes.txt" 36 | ] 37 | 38 | 39 | # Requirements 40 | [tool.poetry.dependencies] 41 | python = "^3.6" 42 | cleo = "^0.6" 43 | cachy = { version = "^0.2.0", extras = ["msgpack"] } 44 | 45 | pendulum = { version = "^1.4", optional = true } 46 | 47 | [tool.poetry.dev-dependencies] 48 | pytest = "~3.4" 49 | 50 | [tool.poetry.extras] 51 | time = ["pendulum"] 52 | 53 | [tool.poetry.scripts] 54 | my-script = "my_package:main" 55 | my-2nd-script = "my_package:main2" 56 | -------------------------------------------------------------------------------- /tests/utils/fixtures/setups/pendulum/setup.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | from distutils.core import setup 3 | 4 | from build import * 5 | 6 | packages = [ 7 | "pendulum", 8 | "pendulum._extensions", 9 | "pendulum.formatting", 10 | "pendulum.locales", 11 | "pendulum.locales.da", 12 | "pendulum.locales.de", 13 | "pendulum.locales.en", 14 | "pendulum.locales.es", 15 | "pendulum.locales.fa", 16 | "pendulum.locales.fo", 17 | "pendulum.locales.fr", 18 | "pendulum.locales.ko", 19 | "pendulum.locales.lt", 20 | "pendulum.locales.pt_br", 21 | "pendulum.locales.zh", 22 | "pendulum.mixins", 23 | "pendulum.parsing", 24 | "pendulum.parsing.exceptions", 25 | "pendulum.tz", 26 | "pendulum.tz.data", 27 | "pendulum.tz.zoneinfo", 28 | "pendulum.utils", 29 | ] 30 | 31 | package_data = {"": ["*"]} 32 | 33 | install_requires = ["python-dateutil>=2.6,<3.0", "pytzdata>=2018.3"] 34 | 35 | extras_require = {':python_version < "3.5"': ["typing>=3.6,<4.0"]} 36 | 37 | setup_kwargs = { 38 | "name": "pendulum", 39 | "version": "2.0.4", 40 | "description": "Python datetimes made easy", 41 | "author": "Sébastien Eustace", 42 | "author_email": "sebastien@eustace.io", 43 | "url": "https://pendulum.eustace.io", 44 | "packages": packages, 45 | "package_data": package_data, 46 | "install_requires": install_requires, 47 | "extras_require": extras_require, 48 | "python_requires": ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*", 49 | } 50 | 51 | build(setup_kwargs) 52 | 53 | setup(**setup_kwargs) 54 | -------------------------------------------------------------------------------- /tests/mixology/solutions/providers/test_python_requirement_solution_provider.py: -------------------------------------------------------------------------------- 1 | from poetry.core.packages.dependency import Dependency 2 | from poetry.mixology.failure import SolveFailure 3 | from poetry.mixology.incompatibility import Incompatibility 4 | from poetry.mixology.incompatibility_cause import NoVersionsCause 5 | from poetry.mixology.incompatibility_cause import PythonCause 6 | from poetry.mixology.term import Term 7 | from poetry.puzzle.exceptions import SolverProblemError 8 | 9 | 10 | def test_it_can_solve_python_incompatibility_solver_errors(): 11 | from poetry.mixology.solutions.providers import PythonRequirementSolutionProvider 12 | from poetry.mixology.solutions.solutions import PythonRequirementSolution 13 | 14 | incompatibility = Incompatibility( 15 | [Term(Dependency("foo", "^1.0"), True)], PythonCause("^3.5", ">=3.6") 16 | ) 17 | exception = SolverProblemError(SolveFailure(incompatibility)) 18 | provider = PythonRequirementSolutionProvider() 19 | 20 | assert provider.can_solve(exception) 21 | assert isinstance(provider.get_solutions(exception)[0], PythonRequirementSolution) 22 | 23 | 24 | def test_it_cannot_solve_other_solver_errors(): 25 | from poetry.mixology.solutions.providers import PythonRequirementSolutionProvider 26 | 27 | incompatibility = Incompatibility( 28 | [Term(Dependency("foo", "^1.0"), True)], NoVersionsCause() 29 | ) 30 | exception = SolverProblemError(SolveFailure(incompatibility)) 31 | provider = PythonRequirementSolutionProvider() 32 | 33 | assert not provider.can_solve(exception) 34 | -------------------------------------------------------------------------------- /tests/mixology/solutions/solutions/test_python_requirement_solution.py: -------------------------------------------------------------------------------- 1 | from cleo.io.buffered_io import BufferedIO 2 | 3 | from poetry.core.packages.dependency import Dependency 4 | from poetry.mixology.failure import SolveFailure 5 | from poetry.mixology.incompatibility import Incompatibility 6 | from poetry.mixology.incompatibility_cause import PythonCause 7 | from poetry.mixology.term import Term 8 | from poetry.puzzle.exceptions import SolverProblemError 9 | 10 | 11 | def test_it_provides_the_correct_solution(): 12 | from poetry.mixology.solutions.solutions import PythonRequirementSolution 13 | 14 | incompatibility = Incompatibility( 15 | [Term(Dependency("foo", "^1.0"), True)], PythonCause("^3.5", ">=3.6") 16 | ) 17 | exception = SolverProblemError(SolveFailure(incompatibility)) 18 | solution = PythonRequirementSolution(exception) 19 | 20 | title = "Check your dependencies Python requirement." 21 | description = """\ 22 | The Python requirement can be specified via the `python` or `markers` properties 23 | 24 | For foo, a possible solution would be to set the `python` property to ">=3.6,<4.0"\ 25 | """ 26 | links = [ 27 | "https://python-poetry.org/docs/dependency-specification/#python-restricted-dependencies", 28 | "https://python-poetry.org/docs/dependency-specification/#using-environment-markers", 29 | ] 30 | 31 | assert title == solution.solution_title 32 | assert ( 33 | description == BufferedIO().remove_format(solution.solution_description).strip() 34 | ) 35 | assert links == solution.documentation_links 36 | -------------------------------------------------------------------------------- /tests/fixtures/with_local_config/pyproject.toml: -------------------------------------------------------------------------------- 1 | [tool.poetry] 2 | name = "my-package" 3 | version = "1.2.3" 4 | description = "Some description." 5 | authors = [ 6 | "Sébastien Eustace " 7 | ] 8 | license = "MIT" 9 | 10 | readme = "README.rst" 11 | 12 | homepage = "https://python-poetry.org" 13 | repository = "https://github.com/python-poetry/poetry" 14 | documentation = "https://python-poetry.org/docs" 15 | 16 | keywords = ["packaging", "dependency", "poetry"] 17 | 18 | classifiers = [ 19 | "Topic :: Software Development :: Build Tools", 20 | "Topic :: Software Development :: Libraries :: Python Modules" 21 | ] 22 | 23 | # Requirements 24 | [tool.poetry.dependencies] 25 | python = "~2.7 || ^3.6" 26 | cleo = "^0.6" 27 | pendulum = { git = "https://github.com/sdispater/pendulum.git", branch = "2.0" } 28 | requests = { version = "^2.18", optional = true, extras=[ "security" ] } 29 | pathlib2 = { version = "^2.2", python = "~2.7" } 30 | 31 | orator = { version = "^0.9", optional = true } 32 | 33 | # File dependency 34 | demo = { path = "../distributions/demo-0.1.0-py2.py3-none-any.whl" } 35 | 36 | # Dir dependency with setup.py 37 | my-package = { path = "../project_with_setup/" } 38 | 39 | # Dir dependency with pyproject.toml 40 | simple-project = { path = "../simple_project/" } 41 | 42 | 43 | [tool.poetry.extras] 44 | db = [ "orator" ] 45 | 46 | [tool.poetry.dev-dependencies] 47 | pytest = "~3.4" 48 | 49 | 50 | [tool.poetry.scripts] 51 | my-script = "my_package:main" 52 | 53 | 54 | [tool.poetry.plugins."blogtool.parsers"] 55 | ".rst" = "some_module::SomeClass" 56 | -------------------------------------------------------------------------------- /tests/mixology/helpers.py: -------------------------------------------------------------------------------- 1 | from poetry.core.packages.package import Package 2 | from poetry.factory import Factory 3 | from poetry.mixology.failure import SolveFailure 4 | from poetry.mixology.version_solver import VersionSolver 5 | from poetry.packages import DependencyPackage 6 | 7 | 8 | def add_to_repo(repository, name, version, deps=None, python=None): 9 | package = Package(name, version) 10 | if python: 11 | package.python_versions = python 12 | 13 | if deps: 14 | for dep_name, dep_constraint in deps.items(): 15 | package.add_dependency(Factory.create_dependency(dep_name, dep_constraint)) 16 | 17 | repository.add_package(package) 18 | 19 | 20 | def check_solver_result( 21 | root, provider, result=None, error=None, tries=None, locked=None, use_latest=None 22 | ): 23 | if locked is not None: 24 | locked = {k: DependencyPackage(l.to_dependency(), l) for k, l in locked.items()} 25 | 26 | solver = VersionSolver(root, provider, locked=locked, use_latest=use_latest) 27 | 28 | try: 29 | solution = solver.solve() 30 | except SolveFailure as e: 31 | if error: 32 | assert str(e) == error 33 | 34 | if tries is not None: 35 | assert solver.solution.attempted_solutions == tries 36 | 37 | return 38 | 39 | raise 40 | 41 | packages = {} 42 | for package in solution.packages: 43 | packages[package.name] = str(package.version) 44 | 45 | assert result == packages 46 | 47 | if tries is not None: 48 | assert solution.attempted_solutions == tries 49 | -------------------------------------------------------------------------------- /poetry/console/commands/update.py: -------------------------------------------------------------------------------- 1 | from cleo.helpers import argument 2 | from cleo.helpers import option 3 | 4 | from .installer_command import InstallerCommand 5 | 6 | 7 | class UpdateCommand(InstallerCommand): 8 | 9 | name = "update" 10 | description = ( 11 | "Update the dependencies as according to the pyproject.toml file." 12 | ) 13 | 14 | arguments = [ 15 | argument("packages", "The packages to update", optional=True, multiple=True) 16 | ] 17 | options = [ 18 | option("no-dev", None, "Do not update the development dependencies."), 19 | option( 20 | "dry-run", 21 | None, 22 | "Output the operations but do not execute anything " 23 | "(implicitly enables --verbose).", 24 | ), 25 | option("lock", None, "Do not perform operations (only update the lockfile)."), 26 | ] 27 | 28 | loggers = ["poetry.repositories.pypi_repository"] 29 | 30 | def handle(self) -> int: 31 | packages = self.argument("packages") 32 | 33 | self._installer.use_executor( 34 | self.poetry.config.get("experimental.new-installer", False) 35 | ) 36 | 37 | if packages: 38 | self._installer.whitelist({name: "*" for name in packages}) 39 | 40 | if self.option("no-dev"): 41 | self._installer.with_groups(["dev"]) 42 | 43 | self._installer.dry_run(self.option("dry-run")) 44 | self._installer.execute_operations(not self.option("lock")) 45 | 46 | # Force update 47 | self._installer.update(True) 48 | 49 | return self._installer.run() 50 | -------------------------------------------------------------------------------- /tests/console/commands/source/conftest.py: -------------------------------------------------------------------------------- 1 | import pytest 2 | 3 | from poetry.config.source import Source 4 | 5 | 6 | @pytest.fixture 7 | def source_one(): 8 | return Source(name="one", url="https://one.com") 9 | 10 | 11 | @pytest.fixture 12 | def source_two(): 13 | return Source(name="two", url="https://two.com") 14 | 15 | 16 | @pytest.fixture 17 | def source_default(): 18 | return Source(name="default", url="https://default.com", default=True) 19 | 20 | 21 | @pytest.fixture 22 | def source_secondary(): 23 | return Source(name="secondary", url="https://secondary.com", secondary=True) 24 | 25 | 26 | _existing_source = Source(name="existing", url="https://existing.com") 27 | 28 | 29 | @pytest.fixture 30 | def source_existing(): 31 | return _existing_source 32 | 33 | 34 | PYPROJECT_WITH_SOURCES = f""" 35 | [tool.poetry] 36 | name = "source-command-test" 37 | version = "0.1.0" 38 | description = "" 39 | authors = ["Poetry Tester "] 40 | 41 | [tool.poetry.dependencies] 42 | python = "^3.9" 43 | 44 | [tool.poetry.dev-dependencies] 45 | 46 | [[tool.poetry.source]] 47 | name = "{_existing_source.name}" 48 | url = "{_existing_source.url}" 49 | """ 50 | 51 | 52 | @pytest.fixture 53 | def poetry_with_source(project_factory): 54 | return project_factory(pyproject_content=PYPROJECT_WITH_SOURCES) 55 | 56 | 57 | @pytest.fixture 58 | def add_multiple_sources( 59 | command_tester_factory, poetry_with_source, source_one, source_two 60 | ): 61 | add = command_tester_factory("source add", poetry=poetry_with_source) 62 | for source in [source_one, source_two]: 63 | add.execute(f"{source.name} {source.url}") 64 | -------------------------------------------------------------------------------- /tests/utils/test_env_site.py: -------------------------------------------------------------------------------- 1 | import uuid 2 | 3 | from pathlib import Path 4 | 5 | from poetry.utils._compat import decode 6 | from poetry.utils.env import SitePackages 7 | 8 | 9 | def test_env_site_simple(tmp_dir, mocker): 10 | # emulate permission error when creating directory 11 | mocker.patch("pathlib.Path.mkdir", side_effect=OSError()) 12 | site_packages = SitePackages(Path("/non-existent"), fallbacks=[Path(tmp_dir)]) 13 | candidates = site_packages.make_candidates(Path("hello.txt"), writable_only=True) 14 | hello = Path(tmp_dir) / "hello.txt" 15 | 16 | assert len(candidates) == 1 17 | assert candidates[0].as_posix() == hello.as_posix() 18 | 19 | content = decode(str(uuid.uuid4())) 20 | site_packages.write_text(Path("hello.txt"), content, encoding="utf-8") 21 | 22 | assert hello.read_text(encoding="utf-8") == content 23 | 24 | assert not (site_packages.path / "hello.txt").exists() 25 | 26 | 27 | def test_env_site_select_first(tmp_dir): 28 | path = Path(tmp_dir) 29 | fallback = path / "fallback" 30 | fallback.mkdir(parents=True) 31 | 32 | site_packages = SitePackages(path, fallbacks=[fallback]) 33 | candidates = site_packages.make_candidates(Path("hello.txt"), writable_only=True) 34 | 35 | assert len(candidates) == 2 36 | assert len(site_packages.find(Path("hello.txt"))) == 0 37 | 38 | content = decode(str(uuid.uuid4())) 39 | site_packages.write_text(Path("hello.txt"), content, encoding="utf-8") 40 | 41 | assert (site_packages.path / "hello.txt").exists() 42 | assert not (fallback / "hello.txt").exists() 43 | 44 | assert len(site_packages.find(Path("hello.txt"))) == 1 45 | -------------------------------------------------------------------------------- /poetry/installation/operations/update.py: -------------------------------------------------------------------------------- 1 | from typing import TYPE_CHECKING 2 | from typing import Optional 3 | 4 | from .operation import Operation 5 | 6 | 7 | if TYPE_CHECKING: 8 | from poetry.core.packages.package import Package 9 | 10 | 11 | class Update(Operation): 12 | def __init__( 13 | self, 14 | initial: "Package", 15 | target: "Package", 16 | reason: Optional[str] = None, 17 | priority: int = 0, 18 | ) -> None: 19 | self._initial_package = initial 20 | self._target_package = target 21 | 22 | super(Update, self).__init__(reason, priority=priority) 23 | 24 | @property 25 | def initial_package(self) -> "Package": 26 | return self._initial_package 27 | 28 | @property 29 | def target_package(self) -> "Package": 30 | return self._target_package 31 | 32 | @property 33 | def package(self) -> "Package": 34 | return self._target_package 35 | 36 | @property 37 | def job_type(self) -> str: 38 | return "update" 39 | 40 | def __str__(self) -> str: 41 | return "Updating {} ({}) to {} ({})".format( 42 | self.initial_package.pretty_name, 43 | self.format_version(self.initial_package), 44 | self.target_package.pretty_name, 45 | self.format_version(self.target_package), 46 | ) 47 | 48 | def __repr__(self) -> str: 49 | return "".format( 50 | self.initial_package.pretty_name, 51 | self.format_version(self.initial_package), 52 | self.target_package.pretty_name, 53 | self.format_version(self.target_package), 54 | ) 55 | -------------------------------------------------------------------------------- /tests/fixtures/with_default_source/pyproject.toml: -------------------------------------------------------------------------------- 1 | [tool.poetry] 2 | name = "my-package" 3 | version = "1.2.3" 4 | description = "Some description." 5 | authors = [ 6 | "Sébastien Eustace " 7 | ] 8 | license = "MIT" 9 | 10 | readme = "README.rst" 11 | 12 | homepage = "https://python-poetry.org" 13 | repository = "https://github.com/python-poetry/poetry" 14 | documentation = "https://python-poetry.org/docs" 15 | 16 | keywords = ["packaging", "dependency", "poetry"] 17 | 18 | classifiers = [ 19 | "Topic :: Software Development :: Build Tools", 20 | "Topic :: Software Development :: Libraries :: Python Modules" 21 | ] 22 | 23 | # Requirements 24 | [tool.poetry.dependencies] 25 | python = "~2.7 || ^3.6" 26 | cleo = "^0.6" 27 | pendulum = { git = "https://github.com/sdispater/pendulum.git", branch = "2.0" } 28 | requests = { version = "^2.18", optional = true, extras=[ "security" ] } 29 | pathlib2 = { version = "^2.2", python = "~2.7" } 30 | 31 | orator = { version = "^0.9", optional = true } 32 | 33 | # File dependency 34 | demo = { path = "../distributions/demo-0.1.0-py2.py3-none-any.whl" } 35 | 36 | # Dir dependency with setup.py 37 | my-package = { path = "../project_with_setup/" } 38 | 39 | # Dir dependency with pyproject.toml 40 | simple-project = { path = "../simple_project/" } 41 | 42 | 43 | [tool.poetry.extras] 44 | db = [ "orator" ] 45 | 46 | [tool.poetry.dev-dependencies] 47 | pytest = "~3.4" 48 | 49 | 50 | [tool.poetry.scripts] 51 | my-script = "my_package:main" 52 | 53 | 54 | [tool.poetry.plugins."blogtool.parsers"] 55 | ".rst" = "some_module::SomeClass" 56 | 57 | 58 | [[tool.poetry.source]] 59 | name = "foo" 60 | url = "https://foo.bar/simple/" 61 | default = true 62 | -------------------------------------------------------------------------------- /poetry/console/commands/source/remove.py: -------------------------------------------------------------------------------- 1 | from typing import Optional 2 | 3 | from cleo.helpers import argument 4 | from tomlkit import nl 5 | from tomlkit import table 6 | from tomlkit.items import AoT 7 | from tomlkit.items import Table 8 | 9 | from poetry.config.source import Source 10 | from poetry.console.commands.command import Command 11 | 12 | 13 | class SourceRemoveCommand(Command): 14 | 15 | name = "source remove" 16 | description = "Remove source configured for the project." 17 | 18 | arguments = [ 19 | argument( 20 | "name", 21 | "Source repository name.", 22 | ), 23 | ] 24 | 25 | @staticmethod 26 | def source_to_table(source: Source) -> Table: 27 | source_table: Table = table() 28 | for key, value in source.to_dict().items(): 29 | source_table.add(key, value) 30 | source_table.add(nl()) 31 | return source_table 32 | 33 | def handle(self) -> Optional[int]: 34 | name = self.argument("name") 35 | 36 | sources = AoT([]) 37 | removed = False 38 | 39 | for source in self.poetry.get_sources(): 40 | if source.name == name: 41 | self.line(f"Removing source with name {source.name}.") 42 | removed = True 43 | continue 44 | sources.append(self.source_to_table(source)) 45 | 46 | if not removed: 47 | self.line_error( 48 | f"Source with name {name} was not found." 49 | ) 50 | return 1 51 | 52 | self.poetry.pyproject.poetry_config["source"] = sources 53 | self.poetry.pyproject.save() 54 | 55 | return 0 56 | -------------------------------------------------------------------------------- /tests/console/commands/debug/test_resolve.py: -------------------------------------------------------------------------------- 1 | import pytest 2 | 3 | from poetry.factory import Factory 4 | from tests.helpers import get_package 5 | 6 | 7 | @pytest.fixture() 8 | def tester(command_tester_factory): 9 | return command_tester_factory("debug resolve") 10 | 11 | 12 | @pytest.fixture(autouse=True) 13 | def __add_packages(repo): 14 | cachy020 = get_package("cachy", "0.2.0") 15 | cachy020.add_dependency(Factory.create_dependency("msgpack-python", ">=0.5 <0.6")) 16 | 17 | repo.add_package(get_package("cachy", "0.1.0")) 18 | repo.add_package(cachy020) 19 | repo.add_package(get_package("msgpack-python", "0.5.3")) 20 | 21 | repo.add_package(get_package("pendulum", "2.0.3")) 22 | repo.add_package(get_package("cleo", "0.6.5")) 23 | 24 | 25 | def test_debug_resolve_gives_resolution_results(tester): 26 | tester.execute("cachy") 27 | 28 | expected = """\ 29 | Resolving dependencies... 30 | 31 | Resolution results: 32 | 33 | msgpack-python 0.5.3 34 | cachy 0.2.0 35 | """ 36 | 37 | assert expected == tester.io.fetch_output() 38 | 39 | 40 | def test_debug_resolve_tree_option_gives_the_dependency_tree(tester): 41 | tester.execute("cachy --tree") 42 | 43 | expected = """\ 44 | Resolving dependencies... 45 | 46 | Resolution results: 47 | 48 | cachy 0.2.0 49 | └── msgpack-python >=0.5 <0.6 50 | """ 51 | 52 | assert expected == tester.io.fetch_output() 53 | 54 | 55 | def test_debug_resolve_git_dependency(tester): 56 | tester.execute("git+https://github.com/demo/demo.git") 57 | 58 | expected = """\ 59 | Resolving dependencies... 60 | 61 | Resolution results: 62 | 63 | pendulum 2.0.3 64 | demo 0.1.2 65 | """ 66 | 67 | assert expected == tester.io.fetch_output() 68 | -------------------------------------------------------------------------------- /tests/fixtures/sample_project/pyproject.toml: -------------------------------------------------------------------------------- 1 | [tool.poetry] 2 | name = "my-package" 3 | version = "1.2.3" 4 | description = "Some description." 5 | authors = [ 6 | "Sébastien Eustace " 7 | ] 8 | license = "MIT" 9 | 10 | readme = "README.rst" 11 | 12 | homepage = "https://python-poetry.org" 13 | repository = "https://github.com/python-poetry/poetry" 14 | documentation = "https://python-poetry.org/docs" 15 | 16 | keywords = ["packaging", "dependency", "poetry"] 17 | 18 | classifiers = [ 19 | "Topic :: Software Development :: Build Tools", 20 | "Topic :: Software Development :: Libraries :: Python Modules" 21 | ] 22 | 23 | # Requirements 24 | [tool.poetry.dependencies] 25 | python = "~2.7 || ^3.6" 26 | cleo = "^0.6" 27 | pendulum = { git = "https://github.com/sdispater/pendulum.git", branch = "2.0" } 28 | requests = { version = "^2.18", optional = true, extras=[ "security" ] } 29 | pathlib2 = { version = "^2.2", python = "~2.7" } 30 | 31 | orator = { version = "^0.9", optional = true } 32 | 33 | # File dependency 34 | demo = { path = "../distributions/demo-0.1.0-py2.py3-none-any.whl" } 35 | 36 | # Dir dependency with setup.py 37 | my-package = { path = "../project_with_setup/" } 38 | 39 | # Dir dependency with pyproject.toml 40 | simple-project = { path = "../simple_project/" } 41 | 42 | # Dependency with markers 43 | functools32 = { version = "^3.2.3", markers = "python_version ~= '2.7' and sys_platform == 'win32' or python_version in '3.4 3.5'" } 44 | 45 | 46 | [tool.poetry.extras] 47 | db = [ "orator" ] 48 | 49 | [tool.poetry.group.dev.dependencies] 50 | pytest = "~3.4" 51 | 52 | 53 | [tool.poetry.scripts] 54 | my-script = "my_package:main" 55 | 56 | 57 | [tool.poetry.plugins."blogtool.parsers"] 58 | ".rst" = "some_module::SomeClass" 59 | -------------------------------------------------------------------------------- /poetry/packages/dependency_package.py: -------------------------------------------------------------------------------- 1 | from typing import Any 2 | from typing import List 3 | from typing import Union 4 | 5 | from poetry.core.packages.dependency import Dependency 6 | from poetry.core.packages.package import Package 7 | 8 | 9 | class DependencyPackage: 10 | def __init__(self, dependency: Dependency, package: Package) -> None: 11 | self._dependency = dependency 12 | self._package = package 13 | 14 | @property 15 | def dependency(self) -> Dependency: 16 | return self._dependency 17 | 18 | @property 19 | def package(self) -> Package: 20 | return self._package 21 | 22 | def clone(self) -> "DependencyPackage": 23 | return self.__class__(self._dependency, self._package.clone()) 24 | 25 | def with_features(self, features: List[str]) -> "DependencyPackage": 26 | return self.__class__(self._dependency, self._package.with_features(features)) 27 | 28 | def without_features(self) -> "DependencyPackage": 29 | return self.with_features([]) 30 | 31 | def __getattr__(self, name: str) -> Any: 32 | return getattr(self._package, name) 33 | 34 | def __setattr__(self, key: str, value: Any) -> None: 35 | if key in {"_dependency", "_package"}: 36 | return super().__setattr__(key, value) 37 | 38 | setattr(self._package, key, value) 39 | 40 | def __str__(self) -> str: 41 | return str(self._package) 42 | 43 | def __repr__(self) -> str: 44 | return repr(self._package) 45 | 46 | def __hash__(self) -> int: 47 | return hash(self._package) 48 | 49 | def __eq__(self, other: Union[Package, "DependencyPackage"]) -> bool: 50 | if isinstance(other, DependencyPackage): 51 | other = other.package 52 | 53 | return self._package == other 54 | --------------------------------------------------------------------------------