GithubHelp home page GithubHelp logo

ddedalus / poetry-auto-export Goto Github PK

View Code? Open in Web Editor NEW
12.0 1.0 0.0 234 KB

Automatically create requirements.txt on every poetry lock

License: MIT License

Python 100.00%
dependency-manager pip poetry poetry-python

poetry-auto-export's People

Contributors

ddedalus avatar dependabot[bot] avatar hubert-springbok avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

poetry-auto-export's Issues

Not creating the requirements.txt file

Summary

requirements.txt file was not being auto-generated when running poetry lock after installing the plugin

Background:

  1. Setup the export in the pyproject.toml file like so:
[[tool.poetry-auto-export.exports]]
output = "requirements-dev.txt"
without_hashes = true


[[tool.poetry-auto-export.exports]]
output = "requirements.txt"
without = ["dev"]
without_hashes = true
  1. Installed the plugin via pipx inject poetry poetry-auto-export

  2. Checked that the plugin was installed using poetry self show plugins

Result:

Was not getting the requirements.txt and requirements-dev.txt files being generated when running poetry lock

Potential fix:

When I commented out the following lines in the plugin, it worked fine. I'm not sure why that check exists.

https://github.com/Ddedalus/poetry-auto-export/blob/ce6593567a617ec88878442134b9d330310b82db/poetry_auto_export/plugin.py#L31C1-L32C27

PS - thank you so much for creating this plugin - I'd finally gotten fed up after forgetting to update this way too many times when working with docker and your plugin magically showed up when I did a search for something like this.

Poetry can't run in directories without `pyproject.toml` after installing plugin

I started to use this plugin midway in my previous project and it worked very well.
But when I tried to create a new project, an error poped up.

Poetry could not find a pyproject.toml file in <CURRENT DIRECTORY> or its parents

Before installing the plugin, this only occorred when I typed somthing like poetry version where pyproject.toml was necessary.
In this case I simply typed the poetry command, just to see the help messages.

Stack trace (-vvv):

 Stack trace:
  8  ~/.local/pipx/venvs/poetry/lib/python3.12/site-packages/cleo/application.py:327 in run
      325│ 
      326│             try:
    → 327│                 exit_code = self._run(io)
      328│             except BrokenPipeError:
      329│                 # If we are piped to another process, it may close early and send a
  7  ~/.local/pipx/venvs/poetry/lib/python3.12/site-packages/poetry/console/application.py:188 in _run
      186│         self._disable_cache = io.input.has_parameter_option("--no-cache")
      187│ 
    → 188│         self._load_plugins(io)
      189│ 
      190│         exit_code: int = super()._run(io)
  6  ~/.local/pipx/venvs/poetry/lib/python3.12/site-packages/poetry/console/application.py:355 in _load_plugins
      353│             manager = PluginManager(ApplicationPlugin.group)
      354│             manager.load_plugins()
    → 355│             manager.activate(self)
      356│ 
      357│             # We have to override the command from poetry-plugin-export
  5  ~/.local/pipx/venvs/poetry/lib/python3.12/site-packages/poetry/plugins/plugin_manager.py:71 in activate
       69│     def activate(self, *args: Any, **kwargs: Any) -> None:
       70│         for plugin in self._plugins:
    →  71│             plugin.activate(*args, **kwargs)
       72│ 
       73│     def _load_plugin_entry_point(self, ep: metadata.EntryPoint) -> None:
  4  ~/.local/pipx/venvs/poetry/lib/python3.12/site-packages/poetry_auto_export/plugin.py:22 in activate
       20│         if not application.event_dispatcher:
       21│             return
    →  22│         self.configs = self._parse_pyproject(application.poetry.pyproject.data)
       23│         application.event_dispatcher.add_listener(TERMINATE, self.run_exports)
       24│         return super().activate(application)
  3  ~/.local/pipx/venvs/poetry/lib/python3.12/site-packages/poetry/console/application.py:129 in poetry
      127│             project_path = self._io.input.option("directory")
      128│ 
    → 129│         self._poetry = Factory().create_poetry(
      130│             cwd=project_path,
      131│             io=self._io,
  2  ~/.local/pipx/venvs/poetry/lib/python3.12/site-packages/poetry/factory.py:58 in create_poetry
       56│             io = NullIO()
       57│ 
    →  58│         base_poetry = super().create_poetry(cwd=cwd, with_groups=with_groups)
       59│ 
       60│         poetry_file = base_poetry.pyproject_path
  1  ~/.local/pipx/venvs/poetry/lib/python3.12/site-packages/poetry/core/factory.py:50 in create_poetry
       48│         from poetry.core.pyproject.toml import PyProjectTOML
       49│ 
    →  50│         poetry_file = self.locate(cwd)
       51│         local_config = PyProjectTOML(path=poetry_file).poetry_config
       52│ 
  RuntimeError
  Poetry could not find a pyproject.toml file in <CURRENT DIRECTORY> or its parents
  at ~/.local/pipx/venvs/poetry/lib/python3.12/site-packages/poetry/core/factory.py:507 in locate
      503│             if poetry_file.exists():
      504│                 return poetry_file
      505│ 
      506│         else:
    → 507│             raise RuntimeError(
      508│                 f"Poetry could not find a pyproject.toml file in {cwd} or its parents"
      509│             )
      510│ 

Possible solution

It seem like the problem is related to parsing the config in activate()
If the parsing of config is delayed (ex: parse the config in run_exports), the problem sould be solved :)

Allow multiple exports

Hi, first of all, thanks for this plugin, I have been long waiting for this. I would suggest to add multiple export configurations. In our case, we have different requirements for regular building (no dev dependencies) and for testing (that includes dev dependencies).

This is our current structure, that could be similar to other projects:

.
├── README.md
├── poetry.lock
├── pyproject.toml
├── src
│   ├── my_package
│   │   ├── __init__.py
│   │   ├── package_1
│   │   │   ├── __init__.py
│   │   │   └── app.py
│   └── requirements.txt
└── tests
    ├── requirements-dev.txt
    └── unit
        └── test_1.py

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.