0

Currently doing a JetBrains Academy project, it added the following line to my requirement.txt file:

https://github.com/hyperskill/hs-test-python/archive/release.tar.gz

Works fine with pip, however, when I want to install my package using pip install . I get the following error:

SystemExit: error in JetBrain Academy - Numeric Matrix Processor setup command: 'install_requires' must be a string or list of strings containing valid project/version requirement specifiers; Parse error at "'://githu'": Expected stringEnd

My setup.py is the following:

import setuptools

REQS_FILENAME = "requirements.txt"
SETUP_FILENAME = "requirements-setup.txt"


def make_deps(filename):
    """Generate the install_requires parameter."""
    with open(filename) as fhandle:
        return fhandle.readlines()


def main():
    """Main setup function"""
    setuptools.setup(
        name='JetBrain Academy - Numeric Matrix Processor',
        url="https://hyperskill.org/projects/96",
        author='Zangdar',
        description='Doing a Matrix processor from scratch',
        packages=setuptools.find_packages(exclude=("tests",)),
        install_requires=make_deps(REQS_FILENAME),
        python_requires='>= 3.8',
        setup_requires=make_deps(SETUP_FILENAME),
    )


if __name__ == '__main__':
    main()

And it can no longer run. The output of make_deps(REQS_FILENAME) is:

['https://github.com/hyperskill/hs-test-python/archive/release.tar.gz\n', '\n']

What can I do to make it work together ?

EDIT:

Here is my new pyproject.toml as suggested by Sinoroc:

[build-system]
requires = ["poetry_core>=1.1.4"]
build-backend = "poetry.core.masonry.api"

[tool.poetry]
name = "NumericMatrixProcessor"
version = "0.1.0"
description = "JetBrainAcademy Project - Doind a matrix calculator from scratch."
authors = ["Zangdaarr"]
readme = "README.md"
repository = ""
homepage = "https://hyperskill.org/projects/96"

packages = [
    { include = "numeric_matrix_processor"}
]

[tool.poetry.dependencies]
python = "^3.8"

[tool.poetry.dev-dependencies]
pytest = "*"
pytest-cov = "*"
pytest-lazy-fixture = "*"
pytest-mock = "*"
mock = "*"
sphinx = "*"
sphinx_rtd_theme = "*"
pylint = "*"
Milan
  • 1,547
  • 1
  • 24
  • 47
  • 1
    You can not have a project name with empty spaces. Reading `requirements.txt` from `setup.py` is quite a bad practice. using `setup_requoires` is a bad practice as well (deprecated, use `pyproject.toml` / _PEP517_ instead). – sinoroc Dec 28 '20 at 18:23
  • You are probably right but your comment is not helpful, how should I proceed from this ? So far I had no issue with project name, maybe it's because it is not made to be published – Milan Dec 28 '20 at 18:42
  • This is the best way I know of to do what you are trying to do. Unless there are some more details that are not disclosed in the question. -- All in all, you probably should ask your question to the authors / maintainers of the course you are following (I am assuming it is a course). I try to provide the best answers I can that will help the most people, I can't provide answers tailored to specific courses I know nothing of. – sinoroc Dec 28 '20 at 18:51
  • The problem is link to the fact that an url is present in the req.txt file, I will have a look to pyproject.toml. I had a look to the question provided above, I do not feel at ease with putting requirements directly in the setup.py file. Not only it clutters it, but it also prevent to pip install locally without duplicating the information. – Milan Dec 29 '20 at 02:05
  • "_I do not feel at ease with putting requirements directly in the setup.py file. Not only it clutters it, but it also prevent to pip install locally without duplicating the information._" -- The information in the `install_requires` of `setup.py` and the information in `requirements.txt` should be different to begin with. They serve different purposes. Read those: https://stackoverflow.com/a/43659126 & https://caremad.io/posts/2013/07/setup-vs-requirement/ -- To install the project in the current directory (via its `setup.py`): `python -m pip installl .`. – sinoroc Dec 29 '20 at 09:31
  • Also if you don't want to clutter your `setup.py` then I would recommend placing as much info as possible in the companion `setup.cfg` file: https://setuptools.readthedocs.io/en/latest/userguide/declarative_config.html – sinoroc Dec 29 '20 at 09:42
  • Thank you for this precision about requirements.txt. At the moment we use requirements-dev.txt for packages required for dev but this will change in the future. I will make sure to investigate setup.cfg – Milan Dec 29 '20 at 15:21
  • You should move the dependencies listed in `requirements-setup.txt` to the `requires` list of the `[build-system]` section of `pyproject.toml`. – sinoroc Jan 02 '21 at 21:34
  • You should still be able to edit your question, you could add the content of your `pyproject.toml` there. – sinoroc Jan 02 '21 at 21:34
  • Done ! The pyproject.toml is there – Milan Jan 05 '21 at 23:13
  • OK, but why did you change your "_build back-end_" from _setuptools_ to _poetry_? In this situation, there is no more need for a `setup.py` or a `setup.cfg`. Maybe read this: https://stackoverflow.com/a/64151860/11138259 – sinoroc Jan 06 '21 at 10:16
  • there's no longer a setup.py nor setup.cfg, and there's a single requirement file for dev packages – Milan Jan 06 '21 at 14:27
  • I know. I'm just surprised you did that change. I meant for you to add a `pyproject.toml` while still using _setuptools_. Doesn't matter... -- Is there anything else we can help with? So much has changed since the original question, you should open new questions if needed. – sinoroc Jan 06 '21 at 14:40
  • Huh, actually, wait... You still have to duplicate your requirements in both `pyproject.toml` and some `requirements.txt` file. How is that any better than before? – sinoroc Jan 06 '21 at 14:41
  • 1
    I don't, the only thing in requirements.txt is the zip file that JetBrains add. Well know it is working fine but since it's my first pyproject.toml if you have any remarks about things to change in there I'll gladly take them – Milan Jan 06 '21 at 14:46

0 Answers0