chipsalliance / fasm

FPGA Assembly (FASM) Parser and Generator
https://fasm.readthedocs.io
Apache License 2.0
88 stars 29 forks source link

Broken installation due to probable circular import #57

Closed Mattia9875 closed 3 years ago

Mattia9875 commented 3 years ago

Hi, i'm currently using docker to try and make a container out of symbiflow but i am encountering this issue when i try and call for the fasm command. Here is the dockerfile

FROM continuumio/miniconda3 
WORKDIR /symb
ENV INSTALL_DIR=/symb
ENV FPGA_FAM=xc7
RUN apt update && \
    apt install -y git wget picocom xz-utils
RUN git clone https://github.com/SymbiFlow/symbiflow-examples && \
    cd symbiflow-examples
RUN conda env create -f ${INSTALL_DIR}/symbiflow-examples/${FPGA_FAM}/environment.yml
RUN mkdir -p $INSTALL_DIR/xc7/install && \
    wget -qO- https://storage.googleapis.com/symbiflow-arch-defs/artifacts/prod/foss-fpga-tools/symbiflow-arch-defs/continuous/install/112/20201208-080919/symbiflow-arch-defs-install-7c1267b7.tar.xz | tar -xJC $INSTALL_DIR/xc7/install       && \
    wget -qO- https://storage.googleapis.com/symbiflow-arch-defs/artifacts/prod/foss-fpga-tools/symbiflow-arch-defs/continuous/install/112/20201208-080919/symbiflow-arch-defs-xc7a50t_test-7c1267b7.tar.xz | tar -xJC $INSTALL_DIR/xc7/install
RUN echo "source activate xc7" > ~/.bashrc
ENV PATH="$PATH:/symb/xc7/install/bin"

Here is the issue

(xc7) root@caaa33124948:/symb# fasm
/opt/conda/envs/xc7/lib/python3.7/site-packages/fasm/parser/__init__.py:27: RuntimeWarning: 
Falling back on slower textX parser implementation:
  ImportError: cannot import name 'antlr_to_tuple' from 'fasm.parser' (/opt/conda/envs/xc7/lib/python3.7/site-packages/fasm/parser/__init__.py)
Please install all dependencies and reinstall with:
  pip uninstall
  pip install -v fasm
  '  pip install -v fasm'.format(e), RuntimeWarning)
Traceback (most recent call last):
  File "/opt/conda/envs/xc7/bin/fasm", line 5, in <module>
    from fasm import main
ImportError: cannot import name 'main' from 'fasm' (/opt/conda/envs/xc7/lib/python3.7/site-packages/fasm/__init__.py)

While trying to use the repo in an isolated environment i get the same issue but with a Circular Import warning hence the name of the issue

mithro commented 3 years ago

@Mattia9875 -- Ignore the ImportWarning for now. Could you include the output of the dockerfile run?

(BTW You want to wrap your output in triple backticks to make github format it correctly.)

Mattia9875 commented 3 years ago

I am testing in interactive mode, i have no other output sorry

litghost commented 3 years ago

fasm/__init__.py has no main method, which is why the import failed. The interactive module of fasm is fasm.tool, like json.tool. The error is not causes by a circular import, but instead is caused by setup.py pointing to the wrong entry point, see: https://github.com/SymbiFlow/fasm/blob/8fb1946b73cdb3222877a246a0e032f1b37d754c/setup.py#L253

Mattia9875 commented 3 years ago

Is there something i can do to fix it in my installation or is it a general issue?

litghost commented 3 years ago

Is there something i can do to fix it in my installation or is it a general issue?

Nothing is broken per say. None of the downstream tooling depends on the console script. Rather than invoking the fasm tool with fasm, just invoke python3 -mfasm.tool. You are welcome to submit a PR changing setup.py and verifying it addresses your original issue.

mithro commented 3 years ago

@Mattia9875 - A pull request which changes the setup.py line to fasm=fasm.tool:main (I think?) and potentially adds a test to the CI would be very welcome!

Mattia9875 commented 3 years ago

Thank you,should i submit a issue pointing to this one in symbiflow-examples? beacuse with the current makefile the examples are not buildable

litghost commented 3 years ago

Thank you,should i submit a issue pointing to this one in symbiflow-examples? beacuse with the current makefile the examples are not buildable

I don't believe any of the makefiles in symbiflow-examples depend on the console script being correct. Do you have an example where that is the case?

Mattia9875 commented 3 years ago

My bad, i've mistaken the warning for an error, thanks for the support and the kindness!

mithro commented 3 years ago

Should be fixed soon by https://github.com/SymbiFlow/fasm/pull/62